At this moment I have a build.gradle
file that successfuly compiles and tests (using JUnit4) a very very simple java project.
My next step is to add JSF2 support (in order to have a web JSF2 application) to this build. The idea is to host the application in my local JBoss 7.1 container. Now things became a little fuzzy to me.
What I did was to add JSF2 support to my buid by adding some dependencies, so the dependencies
block is like this now:
dependencies {
compile 'org.jboss.weld.se:weld-se-core:'+weldVersion
compile 'br.gov.frameworkdemoiselle:demoiselle-core:'+demoiselleVersion
compile 'br.gov.frameworkdemoiselle:demoiselle-jsf:'+demoiselleVersion
runtime 'javax.servlet:javax.servlet-api:3.1.0'
runtime 'javax.enterprise:cdi-api:1.0-SP1'
runtime 'org.jboss.weld.servlet:weld-servlet:'+weldVersion
runtime 'com.sun.faces:jsf-api:2.2.8-02'
runtime 'org.slf4j:slf4j-log4j12:1.7.7'
testCompile 'junit:junit:4.11'
testCompile 'org.jboss.arquillian.junit:arquillian-junit-container:'+arquillianVersion
testCompile 'br.gov.frameworkdemoiselle.component:demoiselle-junit:2.3.1'
}
First strange thing that I noticed is that after refreshing the project with Gradle (by using Gradle > Refresh All
menu), JBoss is unable to see it. I noticed that (it seems) Gradle disabled the use of facets in the project. If I manually activate facets and set the runtime to JBoss 7.1, then I'll be able to add it to JBoss (but I would prefer not to have to do it manually anymore).
After adding it to JBoss I can run the server, and the log says the module corresponding to my web application was correctly loaded by JBoss, however when I type it's url in a browser, the server responds with HTTP status 404.
In src/main/webapp
I have the simple index.html
file (shown below), so what I expected was just to see it's content in the browser, but that does not happen.
<html>
<body>
<h1>Hello world!</h1>
</body>
</html>
What am I missing?
After some study I finally understood that things were much simpler. That I was missing to understand is that I was using the wrong Gradle plug-in. I had to replace
eclipse
plug-in byeclipse-wtp
and then specify which facets and runtime I wanted to use in my application.The final build.gradle file is below:
I hope this may help some other people!