Wtp-eclipse plugin: wb-resources not generated correctly when using task "eclipse"


(Nikolaus Krismer) #1

I am using the eclipse-wtp plugin (together with the war and the java plugin) which generates my web deployment assembly. I am mostly using default settings and even tried to strip down my build.gradle to essentials, but the problem seems to be related to the eclipse-wtp plugin itself.

When using the eclipse task I would expect the file “.settings/org.eclipse.wst.common.component” to be generated with the following content:

<?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0">
 <wb-module deploy-name="myDeployName">
  <property name="context-root" value="myContextRoot"/>
  <wb-resource deploy-path="/WEB-INF/classes" source-path="src/main/resources"/>
  <wb-resource deploy-path="/WEB-INF/classes" source-path="src/main/java"/>
  <wb-resource deploy-path="/" source-path="src/main/webapp"/>
// some dependent modules
...
 </wb-module>
</project-modules>

But in fact it is generated with this content:

<?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0">
 <wb-module deploy-name="myDeployName">
  <property name="context-root" value="myContextRoot"/>
  <wb-resource deploy-path="/WEB-INF/classes" source-path="src/main/resources"/>
  <wb-resource deploy-path="/WEB-INF/classes" source-path="src/main/java"/>
  <wb-resource deploy-path="/" source-path="src/main/webapp"/>
        <wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
        <wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/>
        <wb-resource deploy-path="/WEB-INF/classes" source-path="/src/test/java"/>
        <wb-resource deploy-path="/WEB-INF/classes" source-path="/src/test/resources"/>
// some dependent modules
...
 </wb-module>
</project-modules>

What’s even more suprising: When creating the file with the eclipseWtpComponent task everything works as expected. The problem only occurs when using the task “eclipse” to generate everything needed by the IDE,

I tested this with gradle-1.10 and gradle-1.11 but none of the two version works as expected.


(Todd Gerspacher) #2

This sounds like a similar problem I had with the eclipse-wtp plugin. Check out the forum topic “Eclipse - Glassfish - Struts 2.x” Basically I was using Gradle to manage all my jar dependencies, but I wanted to run the web application through Eclipse using the Glassfish server.

apply plugin: 'java'
apply plugin: 'war'
apply plugin: 'eclipse-wtp'
  repositories {
 mavenLocal()
 mavenCentral()
}
  dependencies {
    // ...
}
  eclipse {
  wtp {
    component {
      resource deployPath: '/', sourcePath: '/WebContent'
      resource deployPath: '/WEB-INF/classes', sourcePath: '/src'
    }
  }
}
  sourceSets {
    main {
        java {
            srcDirs "src"
        }
          resources {
            srcDir "src"
        }
    }
}

Next run the eclipse task and then import the project into Eclipse. Right clicked on the project, select Project Facets and click on the Runtimes tab. Put a check mark on the GlassFish runtime. Select the “Default Configuration for GlassFish” from the Configuration drop down box and then clicked ok.


Separate src/main and src/test sourceSets
(Nikolaus Krismer) #3

Just found out by accident that the eclipse component file is created correctly when executing gradle on the command line

This issue might be related to the eclipse gradle plugin (provided by Spring)


(Nikolaus Krismer) #4

The problem seems to be related to eclipse… not gradle. I think that gradle (and the eclipse plugin) create the right content, but the file is messed up on eclipse project refresh (or workspace refresh)