Gradle equivalent of Surefire classpathDependencyExclude

I am trying to migrate a java project from maven to gradle. The problem is the very complex configuration of classpath dependencies for tests.

Our maven-surefire-plugin configuration:

 <includes>
     <include>**/SomeTest1.java</include>
 </includes>
 <classpathDependencyExcludes>
     <classpathDependencyExclude>com.sun.jersey:jersey-core</classpathDependencyExclude>
 </classpathDependencyExcludes>

There are different cool classes for different test classes. How can I implement it using Gradle?

+4
source share
2 answers

, . , org.foo.test.rest , . , otherTest, :

sourceSets {
    otherTest {
        java {
            srcDir 'src/test/java'
            include 'org/foo/test/rest/**'
        }
        resources {
            srcDir 'src/test/java'
        }
    }
    test {
        java {
            srcDir 'src/test/java'
            exclude 'org/foo/rest/test/**'
        }
        resources {
            srcDir 'src/test/java'
        }
    }
}

, otherTest , :

otherTestCompile sourceSets.main.output
otherTestCompile configurations.testCompile
otherTestCompile sourceSets.test.output
otherTestRuntime configurations.testRuntime + configurations.testCompile

, ( ) test:

configurations {
    testRuntime {
        exclude group: 'org.conflicting.library'
    }
}

Gradle otherTest:

task otherTest(type: Test) {
    testClassesDir = sourceSets.otherTest.output.classesDir
    classpath += sourceSets.otherTest.runtimeClasspath
}

check.dependsOn otherTest
+4

:

  • sourceSet
  • dependOn
  • html:)

+2

All Articles