Skip to content

Commit a8acf91

Browse files
committed
Add test for javadoc in combination with 'requires /*runtime*/'
1 parent 8d8f9b7 commit a8acf91

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

src/test/groovy/org/gradlex/javamodule/dependencies/test/RequiresRuntimeTest.groovy

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package org.gradlex.javamodule.dependencies.test
22

3+
import org.gradle.testkit.runner.TaskOutcome
34
import org.gradlex.javamodule.dependencies.test.fixture.GradleBuild
45
import spock.lang.Specification
56

@@ -115,4 +116,40 @@ class RequiresRuntimeTest extends Specification {
115116
then:
116117
result.output.contains("error: package org.slf4j does not exist")
117118
}
119+
120+
def "generates javadoc with runtime only dependencies in module-info"() {
121+
given:
122+
appBuildFile << '''
123+
java.withJavadocJar()
124+
dependencies.constraints {
125+
javaModuleDependencies {
126+
implementation(gav("org.slf4j", "2.0.3"))
127+
implementation(gav("org.slf4j.simple", "2.0.3"))
128+
}
129+
}
130+
// TODO ideally, this should not be necessary
131+
tasks.javadoc {
132+
classpath = sourceSets.main.get().runtimeClasspath
133+
}
134+
'''
135+
appModuleInfoFile << '''
136+
module org.gradlex.test.app {
137+
requires org.slf4j;
138+
requires /*runtime*/ org.slf4j.simple;
139+
140+
exports org.gradlex.test.app;
141+
}
142+
'''
143+
file("app/src/main/java/org/gradlex/test/app/Main.java") << """
144+
package org.gradlex.test.app;
145+
146+
public class Main {}
147+
"""
148+
149+
when:
150+
def result = build()
151+
152+
then:
153+
result.task(':app:javadoc').outcome == TaskOutcome.SUCCESS
154+
}
118155
}

0 commit comments

Comments
 (0)