Skip to content

Commit 2670557

Browse files
authored
Merge pull request #33 from TheMrMilchmann/tmm-coordinates-compile-classpath
Support 'group:name' notation for compile-only dependencies
2 parents bb936d1 + aeaf8f4 commit 2670557

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

src/main/java/de/jjohannes/gradle/javamodules/ExtraModuleInfoPlugin.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,11 @@ private void configureTransform(Project project, ExtraModuleInfoPluginExtension
5959
m.getMergedJars().stream()).filter(s -> s.contains(":")).forEach(s ->
6060
d.add(project.getDependencies().create(s))));
6161

62-
// Automatically get versions from the runtime classpath
62+
// Automatically get versions from the compile and runtime classpath
6363
if (GradleVersion.current().compareTo(GradleVersion.version("6.8")) >= 0) {
64+
//noinspection UnstableApiUsage
65+
c.shouldResolveConsistentlyWith(project.getConfigurations().getByName(JavaPlugin.COMPILE_CLASSPATH_CONFIGURATION_NAME));
66+
6467
//noinspection UnstableApiUsage
6568
c.shouldResolveConsistentlyWith(project.getConfigurations().getByName(JavaPlugin.RUNTIME_CLASSPATH_CONFIGURATION_NAME));
6669
}

src/test/groovy/de/jjohannes/gradle/javamodules/test/ConfigurationDetailsFunctionalTest.groovy

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,19 +214,25 @@ class ConfigurationDetailsFunctionalTest extends Specification {
214214
module org.gradle.sample.app {
215215
requires org.apache.commons.cli;
216216
requires org.apache.commons.collections;
217+
218+
requires static jsr305;
217219
}
218220
"""
219221
buildFile << """
220222
dependencies {
221223
implementation("commons-cli:commons-cli:1.4")
222224
implementation("commons-collections:commons-collections:3.2.2")
225+
226+
compileOnly("com.google.code.findbugs:jsr305:3.0.2")
223227
}
224228
225229
extraJavaModuleInfo {
226230
module("${libs.commonsCli}", "org.apache.commons.cli") {
227231
exports("org.apache.commons.cli")
228232
}
229233
module("${libs.commonsCollections}", "org.apache.commons.collections")
234+
235+
automaticModule("${libs.jsr305}", "jsr305")
230236
}
231237
"""
232238

src/test/groovy/de/jjohannes/gradle/javamodules/test/fixture/LegacyLibraries.groovy

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ class LegacyLibraries {
1515
def commonsLogging = jarNameOnly ? "commons-logging-1.2.jar" : "commons-logging:commons-logging"
1616
def groovyAll = jarNameOnly ? "groovy-all-2.4.15.jar" : "org.codehaus.groovy:groovy-all"
1717
def javaxInject = jarNameOnly ? "javax.inject-1.jar" : "javax.inject:javax.inject"
18+
def jsr305 = jarNameOnly ? "jsr305-3.0.2.jar" : "com.google.code.findbugs:jsr305"
1819
def log4jCore = jarNameOnly ? "log4j-core-2.14.0.jar" : "org.apache.logging.log4j:log4j-core"
1920
def sac = jarNameOnly ? "sac-1.3.jar" : "org.w3c.css:sac"
2021
def slf4jApi = jarNameOnly ? "slf4j-api-1.7.32.jar" : "org.slf4j:slf4j-api"

0 commit comments

Comments
 (0)