I’m trying to write a plugin where instead of using long GAV, I can simply write the artifact, or some other short name I’ve defined. so instead of
dependencies {
implementation("org.immutables:value")
implementation("org.immutables:builder")
implementation("org.springframework.boot:spring-boot-starter-logging")
}
I could write
dependencies {
implementation("immutables")
implementation("logging")
}
So far though all I get is
Supplied String module notation 'immutables' is invalid. Example notations: 'org.gradle:gradle-core:2.2', 'org.mockito:mockito-core:1.9.5:javadoc'.
I’ve tried variations on, but no luck
conf.getResolutionStrategy().dependencySubstitution( ds -> {
ds.all( dep -> {
ComponentSelector requested = dep.getRequested();
if ( requested instanceof ModuleComponentSelector && "immutables".equals( requested.getDisplayName() ) ) {
dep.useTarget( "org.immutables:value" );
}
} );
} );
conf.withDependencies( ds -> {
log.info( "ds: {}", ds );
HashMap<String, String> map = new HashMap<>();
map.put( "module", "immutables" );
map.put( "group", "immutables" );
conf.exclude( map );
conf.getIncoming().beforeResolve( rd -> {
conf.getResolutionStrategy().eachDependency( drd -> {
log.info( "drd: {}", drd.getRequested() );
ModuleVersionSelector requested = drd.getRequested();
requested.getName();
} );
} );
} );
} );