diff --git a/native-maven-plugin/src/functionalTest/groovy/org/graalvm/buildtools/maven/JavaApplicationWithTestsFunctionalTest.groovy b/native-maven-plugin/src/functionalTest/groovy/org/graalvm/buildtools/maven/JavaApplicationWithTestsFunctionalTest.groovy index 80e6f5c18..a7ca1d4e6 100644 --- a/native-maven-plugin/src/functionalTest/groovy/org/graalvm/buildtools/maven/JavaApplicationWithTestsFunctionalTest.groovy +++ b/native-maven-plugin/src/functionalTest/groovy/org/graalvm/buildtools/maven/JavaApplicationWithTestsFunctionalTest.groovy @@ -41,6 +41,7 @@ package org.graalvm.buildtools.maven +import spock.lang.IgnoreIf import spock.lang.Issue class JavaApplicationWithTestsFunctionalTest extends AbstractGraalVMMavenFunctionalTest { @@ -153,4 +154,32 @@ class JavaApplicationWithTestsFunctionalTest extends AbstractGraalVMMavenFunctio outputContains "SurefirePlugin - Tests run: 8, Failures: 0, Errors: 0, Skipped: 0" } + @IgnoreIf({ os.windows }) + def "dependencies with scope provided are on classpath for test binary"() { + withSample("java-application-with-tests") + + when: + mvn '-Pnative', '-DquickBuild', 'test' + + def expectedOutput = ["local-repo", "org", "apache", "commons", "commons-lang3", "3.12.0", "commons-lang3-3.12.0.jar"].join(File.separator) + + then: + buildSucceeded + outputContains expectedOutput + } + + @IgnoreIf({ os.windows }) + def "dependencies with scope provided are not on classpath for main binary"() { + withSample("java-application-with-tests") + + when: + mvn '-Pnative', '-DquickBuild', '-DskipNativeTests', 'package' + + def expectedOutput = ["local-repo", "org", "apache", "commons", "commons-lang3", "3.12.0", "commons-lang3-3.12.0.jar"].join(File.separator) + + then: + buildSucceeded + outputDoesNotContain expectedOutput + } + } diff --git a/native-maven-plugin/src/main/java/org/graalvm/buildtools/maven/NativeTestMojo.java b/native-maven-plugin/src/main/java/org/graalvm/buildtools/maven/NativeTestMojo.java index a59009a57..353370829 100644 --- a/native-maven-plugin/src/main/java/org/graalvm/buildtools/maven/NativeTestMojo.java +++ b/native-maven-plugin/src/main/java/org/graalvm/buildtools/maven/NativeTestMojo.java @@ -113,7 +113,8 @@ protected List getDependencyScopes() { Artifact.SCOPE_COMPILE, Artifact.SCOPE_RUNTIME, Artifact.SCOPE_TEST, - Artifact.SCOPE_COMPILE_PLUS_RUNTIME + Artifact.SCOPE_COMPILE_PLUS_RUNTIME, + Artifact.SCOPE_PROVIDED ); } diff --git a/samples/java-application-with-tests/pom.xml b/samples/java-application-with-tests/pom.xml index a5631def4..19b088af7 100644 --- a/samples/java-application-with-tests/pom.xml +++ b/samples/java-application-with-tests/pom.xml @@ -59,6 +59,12 @@ + + org.apache.commons + commons-lang3 + 3.12.0 + provided + org.junit.jupiter junit-jupiter