Problem with processTestResources and unit tests with TestNG


(Björn Schmitz) #1

Hi,

I have following problem: I try to start unit tests with the task “test”. But I’ve got an error, because the runtime classpath of the tests contains my “persistence.xml” two times. Looking into the directories “build/resources/main” and “build/resouces/test”, both directories contain the files from “src/main/resources”. Is this the correct behavior? My expectation would be that “build/resources/main” contains only files from “src/main/resources” and “build/resources/test” only files from “build/resources/test”…

Following the expectation mentioned above, only “build/resource/test” should be in my test classpath…

What could be my problem?

Some parts of my build.gradle:

apply plugin: 'java'
apply plugin: 'eclipse-wtp'
apply plugin: 'war'
apply plugin: 'gwt'
apply plugin: 'compass'
apply plugin: 'checkstyle'
  buildscript {
    repositories {
        mavenCentral()
        maven { url 'http://dl.bintray.com/robfletcher/gradle-plugins' }
    }
    dependencies {
        classpath 'org.gradle.plugins:gradle-compass:1.0.7'
        classpath 'com.jcraft:jsch:0.1.50'
    }
}
  def generatedSourcesGwtJava = "${project.buildDir}/generated-sources/gwt-java"
def generatedSourcesGwtJS = "${project.buildDir}/generated-sources/gwt"
  targetCompatibility = 1.7
sourceCompatibility = 1.7
version = '1.0'
  repositories {
    mavenCentral()
    maven { url 'myurl' }
}
  dependencies {
[...]
}
  test {
 useTestNG()
}
  gwt {
// Self written. Does not manipulate the classpath.
}
  compass {
 cssDir = file('apath')
 sassDir = file('apath')
 outputStyle = "expanded"
 noLineComments = true
 debugInfo = false
}
  sourceSets {
        main {
                output.dir(builtBy: 'gwtI18NConstants', generatedSourcesGwtJava)
                  java {
                 srcDir generatedSourcesGwtJava
                }
        }
}
  war {
 from generatedSourcesGwtJS
}
  checkstyleMain {
 showViolations = false
}
  eclipse {
[...]
}

(Björn Schmitz) #2

OK, I’ve found the error. It’s in the self written gwt plugin… (Sorry.)

This was the wrong code:

project.sourceSets.test {
 project.sourceSets.main.java.srcDirs.each {
  java.srcDirs it
 }
 project.sourceSets.main.resources.srcDirs.each {
  resources.srcDirs it
 }
 resources.srcDirs.each {
  java.srcDirs it
 }
}