2

I just started using Gradle and so far I think it is a great tool but currently I'm having a problem to generate a web application which works with eclipse.

My folders structure looks like this:

/WebGradle
    /src
        /main
            /java
            /resources
            /webapp
                /WEB-INF
        /test

My build.gradle file:

apply plugin: 'java'
apply plugin: 'war'
apply plugin: 'eclipse-wtp'

sourceCompatibility = 1.6

repositories {
    mavenCentral()
}

dependencies {
    compile 'org.springframework:spring-webmvc:4.0.6.RELEASE'
    providedCompile 'javax.servlet:servlet-api:2.5'
}

My problem is that, when I run gradle eclipse the resulting .classpath file is missing the webapp folder, thus when I import the project in eclipse it tells me something is missing.

Am I doing something wrong?

Thanks in advance!

Paco Lagunas
  • 320
  • 1
  • 13
  • 1
    No, you did everything correct as the ```.classpath``` file will never contain the webapp dir. Why do you need that? – Andreas Schmid Dec 23 '14 at 18:39
  • @Andreas yes, you are right. I was confused because after running "gradle war" the resulting war file didn't contained anything I was placing inside the webapp directory and I thought this was the problem. After a while I realized I needed to rebuild my project; did that and my war file was fine. Thank you so much for your comment. – Paco Lagunas Dec 23 '14 at 22:04

1 Answers1

1

I was generating my war file using gradle war directly from eclipse and the resulting war file didn't contained anything that I placed inside the webapp folder, so I thought the problem was the webapp folder was not being properly referenced (I was wrong).

After some tests, I find out that I needed to run gradle build and then gradle war and my war file was properly generated.

If I run gradle war from command line the war file is generated without a single problem, I guess it automatically does a build before generating the war.

Paco Lagunas
  • 320
  • 1
  • 13