Questions about customizing build of a war


(vincent richomme) #1

Hi,

I have a project with the following tree architecture :

├── build │ ├── classes │ │ └── main │ │

└── com │ └── dependency-cache ├── data │ └── db ├── doc ├── gradle │ └── wrapper ├── misc │ └── docs │

└── imap_logs └── src

├── main

│ ├── java

│ │ └── com

│ └── webapp

├── Categories

├── Components

├── Controllers

├── Frameworks

├── Mail.orgxcodeproj

├── Models

├── Resources

├── templates-hidden

├── Views

└── WEB-INF

└── test

└── java

and with the following build.gradle:

apply plugin: ‘java’ apply plugin: ‘war’ apply plugin: ‘jetty’ apply plugin: “eclipse”

// Project properties version = ‘1.2’ //webAppDirName = ‘src/main/webapp/Build/Deployment/Mail’

jettyRun.contextPath = “/”

repositories {

mavenCentral()

flatDir name: ‘localRepository’, dirs: “lib” }

dependencies {

compile group: ‘commons-collections’, name: ‘commons-collections’, version: ‘3.2’

testCompile group: ‘junit’, name: ‘junit’, version: ‘4.7’

compile ‘commons-lang:commons-lang:2.4’,

‘org.mortbay.jetty:jetty:6.1.22’,

‘org.mortbay.jetty:jetty-util:6.1.22’,

‘org.mortbay.jetty:jetty-management:6.1.22’,

‘log4j:log4j:1.2.16’,

‘javax.mail:mail:1.4.5’,

‘commons-fileupload:commons-fileupload:1.2’,

‘commons-io:commons-io:2.1’,

‘org.mongodb:mongo-java-driver:2.7.3’

//‘net.sf.json-lib:json-lib:2.4’

providedCompile ‘javax.servlet:servlet-api:2.5’ //, ‘org.eclipse.jetty:jetty-websocket:7.4.4.v20110707’

compile group: ‘net.sf.json-lib’, name: ‘json-lib’, version: ‘2.4’, classifier: ‘jdk15’ }

/* task jakeDeploy(type:Exec) {

workingDir ‘src/main/webapp’

commandLine ‘jake’

args ‘deploy’ }

war.dependsOn jakeDeploy

war {

exclude ‘.xCodeSupport’ } */

// File: build.gradle task wrapper(type: Wrapper) {

gradleVersion = ‘1.4’ }

/*sourceSets {

main {

java {

srcDir ‘src’

}

} }*/

/*task(runSimple, dependsOn: ‘classes’, type: JavaExec) {

main = ‘com.smartmobili.other.MyMain’

classpath = sourceSets.main.runtimeClasspath

//args ‘argz’

//systemProperty ‘simple.message’, 'Hello ’ }

defaultTasks ‘runSimple’

jar {

manifest.attributes(“Main-Class”: “test4.MyMain”) } */

My webcontent directory is specific and is located into ‘src/main/webapp/Build/Deployment/Mail’ but generally it doesn’t exist until I execute a command to generate it. Generally I am working on my project in debug mode and I don’t want to deploy it so I have to comment the line webAppDirName because if I don’t don’t every time I start ./gradlew jettyRun it complains about the missing folder :

FAILURE: Build failed with an exception.

  • What went wrong: A problem was found with the configuration of task ‘:jettyRun’. > Directory ‘C:\Developer\cygwin\home\v.richomme\kairos\src\main\webapp\Build\Deployment\Mail’ specified for property ‘webAppSourceDirectory’ does not exist.

So what I don’t understand is why when I try to launch jettyRun it tries to build a war ??? What is the relationshhip between these two operations ?

It means that when I am in debug I have to comment the line and once I want to deploy I uncomment it after having generated the webcontent folder. Wouldn’t be possible to let the line uncommented and that when I launch jettyRun Gradle doesn’t try to see if my webAppDirName exists ?

Thanks