Note that there are some explanatory texts on larger screens.

plurals
  1. POSplitting main and test in gradle's eclipse builds
    text
    copied!<p>Today I tried to switch an project with integration tests from maven to gradle. All worked fine except I have a serious problem with testng.</p> <p>The project uses hibernate/JPA2 for database access and has a couple of tests that depend on a persistence unit in the test/resources/META-INF/persistence.xml. When I run the test suite using gradle all works fine. But when I run the xml (or any test class by itself) from eclipse it seems that it tries to use the main/resources/META-INF/persistence.xml. </p> <p>Because I do most of my work using TDD, I realy need to run/debug tests from eclipse. When I add the persistence unit to the production persistence.xml it works (it even gets some other resources from the "test" dir). It would be a workaround, but I realy don't like the idea of adding test resources to "main/resources"</p> <p>Same project works fine when I import it using the old pom.xml from maven.</p> <p>build.gradle</p> <pre><code>apply plugin: 'java' apply plugin: 'eclipse' sourceCompatibility = 1.7 version = '0.1' jar { manifest { attributes 'Implementation-Title': 'md', 'Implementation-Version': version } } repositories { mavenCentral() } dependencies { compile 'org.slf4j:slf4j-api:1.7.5' compile 'com.google.guava:guava:14.0.1' compile 'org.hibernate:hibernate-entitymanager:4.2.2.Final' compile 'org.hibernate.javax.persistence:hibernate-jpa-2.0-api:1.0.1.Final' testCompile 'ch.qos.logback:logback-classic:1.0.13' testCompile 'org.testng:testng:6.8.5' testCompile 'org.dbunit:dbunit:2.4.9' testCompile 'org.mockito:mockito-all:1.9.5' testCompile 'org.easytesting:fest-assert-core:2.0M10' testCompile 'org.hsqldb:hsqldb:2.2.9' } test { useTestNG(){ suites 'src/test/resources/testng.xml' } } </code></pre> <p>Update:</p> <p>Generated classpath file looks like this:</p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;classpath&gt; &lt;classpathentry kind="src" path="src/main/java"/&gt; &lt;classpathentry kind="src" path="src/main/resources"/&gt; &lt;classpathentry kind="src" path="src/test/java"/&gt; &lt;classpathentry kind="src" path="src/test/resources"/&gt; &lt;classpathentry exported="true" kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/&gt; &lt;classpathentry exported="true" kind="con" path="org.springsource.ide.eclipse.gradle.classpathcontainer"/&gt; &lt;classpathentry kind="output" path="bin"/&gt; &lt;/classpath&gt; </code></pre> <p>It seems it merges all into the bin folder and doesn't differentiate between main and test like the .classpath file generated by maven.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload