EAR Project BOM Resolution not working

Hi all,

i defined a new configuration in WebshereEAR project called “bom” with a platform dependency.


configurations{
    bom
    implementation.extendsFrom bom
    earlib.extendsFrom bom
}
dependencies {
    bom platform('org.springframework.boot:spring-boot-dependencies:2.1.2.RELEASE')
    //earlib 'org.junit.jupiter:junit-jupiter-api:5.6.0'
    //deploy 'org.junit.jupiter:junit-jupiter-engine:5.6.0'
    deploy project(path:":lib1")
    earlib project(path:":lib1")
    earlib 'org.springframework.boot:spring-boot-test'
}


}

i will use the versions defined in bom file but they can not be resolved

Execution failed for task ':WebsphereEAR:ear'.
> Could not resolve all files for configuration ':WebsphereEAR:earlib'.
> Could not find org.springframework.boot:spring-boot-test:.
Required by:
project :WebsphereEAR
project :WebsphereEAR > project :lib1

Possible solution:
- Declare repository providing the artifact, see the documentation at https://docs.gradle.org/current/userguide/declaring_repositories.html
}

if i also apply the java plugin to the EAR project it works as excepted, but why ? versions should be resolved via a bom file.

Sample could bei found here:

use branch: earlib-dependency-resolution

thanks
Andreas

I’ve actually updated the example, the bom configuration has nothing to do with that problem so I’ve removed that.

There seems to be a general issue with the ear plugin that resolving transitive dependencies without explicit versioning of another project in the same build does only work until you also add the java plugin to the ear project. (ATTENTION this will cause other serious problems - see below!)

If any of the core devs could clarify what’s goin on that would be super interesting.

Update: The setup got broken from gradle 6.4.1 (still working) to 6.5.0-rc-1 (broken) (not sure how to test the previous milestones :frowning:

We’ve had some long debugging sessions especially because eclipseWtp for ear projects got broken.
When applying the JavaPlugin not a single earlib dependency was added to the deployment assembly resulting in ClassNotFoundExceptions all over the place.

We finally found out that applying the JavaPlatformPlugin solved the BOM issue and fixed EclipseWtp. In the end we nailed it down to these two lines of code that seem to be absolutely necessary to get the ear plugin working again:

    public void apply(final Project project) {
        final PluginManager pluginManager = project.getPluginManager();

        pluginManager.apply(EarPlugin.class);
        configureVariantDerivationStrategy(project);

    }

    private static void configureVariantDerivationStrategy(Project project) {
        ComponentMetadataHandlerInternal metadataHandler = (ComponentMetadataHandlerInternal) project.getDependencies().getComponents();
        metadataHandler.setVariantDerivationStrategy(JavaEcosystemVariantDerivationStrategy.getInstance());
    }

I don’t understand what’s going on here and why this is necessary, but maybe a core dev can clarify that and help to integrate it into gradle-core as currently the ear plugin is in a very bad shape. Also I don’t feel compfortable requiring a Internal interface in our code.

kind regards
Daniel