Problem/Motivation

8.x-1.x currently does not merge require-dev values from modules' Composer files. This is slightly problematic when setting up integration tests for a module. The test build can of course add dependencies itself, but it's less maintainable and completely bypasses Composer.

Proposed resolution

Merge require-dev values just like require values are merged already.

Remaining tasks

N/A.

User interface changes

None.

API changes

None.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Xano’s picture

Assigned: Unassigned » Xano

I'll post a patch.

At first glance this seems to be a regression when compared to 7.x-2.x. Is there a specific reason this merge was left out?

Xano’s picture

Assigned: Xano » Unassigned
Status: Active » Needs review
FileSize
2.22 KB

I performed a manual test locally and this works. I did have to remove the check for require values, as my module does not have any regular Composer dependencies, but only require-dev ones.

It does look like Composer Manager cannot handle conflicting dependencies: it simply merges all dependencies based on their name and not the version constraints, which dependencies cannot be fully checked when running composer install and code has the potential to fail during runtime.

Xano’s picture

FileSize
4.02 KB

Fixed the tests too.

Could someone enable automated testing for this project so the patch can be reviewed?

bojanz’s picture

We should check if the composer file has a require or require-dev dependency, instead of removing the require check.
Most modules will ship with composer.json files, but many won't have any composer dependencies, so they don't need to be merged in.

The rest looks fine.

It does look like Composer Manager cannot handle conflicting dependencies: it simply merges all dependencies based on their name and not the version constraints, which dependencies cannot be fully checked when running composer install and code has the potential to fail during runtime.

Correct. We have access to Composer classes so we could resolve dependencies, but it's probably not worth it to spend the time since we're working on actively making composer_manager unnecessary.

Xano’s picture

FileSize
4.06 KB
bojanz’s picture

Status: Needs review » Fixed

Committed, thanks.

  • bojanz committed 9892f9e on 8.x-1.x authored by Xano
    Issue #2490480 by Xano: Support require-dev
    

  • bojanz committed f16f3c2 on 8.x-1.x
    Revert "Issue #2490480 by Xano: Support require-dev"
    
    This reverts...
bojanz’s picture

Status: Fixed » Needs work

I had to revert this :(
It breaks Composer when require-dev is empty, cause the braces are not curly enough:
" [Composer\Json\JsonValidationException]
"./composer.json" does not match the expected JSON schema:
- require-dev : array value found, but an object is required "

https://travis-ci.org/commerceguys/commerce/jobs/63786299

caseyfw’s picture

This is just an issue because json_encode has no idea if an empty config element should be an array or an object. A solution would be to strip empty config elements out before writing the JSON.

caseyfw’s picture

Status: Needs work » Needs review
caseyfw’s picture

Missed an erroneous bit of boolean logic in RootPackageBuilder.

joshtaylor’s picture

This patch makes composer_manager work again with core.

CalebD’s picture

Status: Needs review » Reviewed & tested by the community

Can we get composer_manager_2490480_12.patch committed and a new release for 8.x published?

I just spent the last couple hours confusedly trying to get composer and Composer Manager to work, not realizing that the current release has the older patch applied, the 8.x-1.x branch has the older patch reverted, and this patch is against 8.x-1.x and doesn't apply to the current 8.x-1.0-beta2 release.

After sorting through all this, I was able to get things working. As it stands right now, 8.x-1.0-beta2 is broken and 8.x-1.x with this patch works well.

  • bojanz committed 0240c9b on 8.x-1.x authored by caseyfw
    Issue #2490480 by Xano, caseyfw: Support require-dev
    
bojanz’s picture

Status: Reviewed & tested by the community » Fixed

Recommitted, thanks everyone.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.