Thanks Jerod Lass for the tip about accessing the war task!!! At least I was
able to figure out how to include the public_html files. This sort of thing
should definitely be documented more clearly.

*** updated contents of ./csl/wars/build.gradle

dependsOnChildren()

subprojects {
  usePlugin('war')
  sourceCompatibility = project(':').getProperty("sourceCompatibility")
  targetCompatibility = project(':').getProperty("targetCompatibility")
  compile {
    options.deprecation =
project(':').getProperty("compile.options.deprecation")
    options.warnings    =
project(':').getProperty("compile.options.warnings")
  }
  libs {
    War war = project.task( project.name + '_war')
    war.fileSet( dir: new File( project.srcRoot, 'main/public_html' )) {
      exclude( 'WEB-INF' )
      include( '**/*' )
    }
  }
}


Dominick More wrote:
> 
> While evaluating Gradle I've run into a dead end with the usage of the war
> plugin. The "usePlugin('war')" directive is in the file
> ./csl/wars/build.gradle but the war file source is actually in
> ./csl/wars/mywarproject and dependencies are defined in
> ./csl/wars/mywarproject/build.gradle
> 
> Two things stump me with the war file:
> 
> 1) Files not within the war file ./WEB-INF directory are not included in
> the war file. Typically our wars contain other content in the archive root
> folder (i.e. jsps, images, etc.). The problem is the war file gernerated
> out of gradle just contains the WEB-INF content. I was trying to figure
> out how to append filesets to the war object within the build.gradle
> script but couldn't manage.
> 
> The snippet:
> 
> subprojects {
>   usePlugin('war')
>   dists {
>     war() {
>       fileSet(dir: 'src/public_html') {
>         excludes('WEB-INF')
>         includes('**/*')
>       }
>     }
>   }
> }
> 
> results in the error message:
> 
> Exception: org.gradle.api.GradleScriptException:
> org.gradle.api.InvalidUserDataException: A task with this name already
> exists!
> 
> The documentation mentions examples such as
> "myZipTask.files('path_to_file1', 'path_to_file2')" but fails to mention
> how to get a reference to myZipTask.
> 
> How do I access the 'war' task at runtime so that I can manipulate the
> archive content?
> 
> 2) The war build.gradle file contains the dependency "compile
> project(':csl:jars:myjarproject')" which is automatically added to the war
> lib directory. While this is sometimes desired we don't want to blow up
> our distribution so we put the project jars in the shared classpath. How
> do I prevent gradle from added "dependency" jars to the war lib folder?
> 
> 
> |-csl
> | |
> | |-jars
> | | |
> | | |-myjarproject
> | | | |
> | | | |-src
> | | | | |
> | | | | |-main
> | | | | | |
> | | | | | |-java
> | | | | | |
> | | | | | |-resources
> | | | | |
> | | | | |-test
> | | | |   |
> | | | |   |-java
> | | | |   |
> | | | |   |-resources
> | | | |
> | | | |-build.gradle
> | | |
> | | |-build.gradle
> | |
> | |-wars
> | | |
> | | |-mywarproject
> | | | |
> | | | |-src
> | | | | |
> | | | | |-main
> | | | | | |
> | | | | | |-java
> | | | | | |
> | | | | | |-resources
> | | | | | |
> | | | | | |-webapp
> | | | | |
> | | | | |-test
> | | | |   |
> | | | |   |-java
> | | | |   |
> | | | |   |-resources
> | | | |
> | | | |-build.gradle
> | | |
> | | |-build.gradle
> | |
> | |-build.gradle
> |
> |-local_maven_repo
> |
> |-build.gradle
> |
> |-settings.gradle
> 
> *** contents of ./setting.gradle
> 
> include 'csl', 'csl:jars', 'csl:wars', 'csl:jars',
>   'csl:jars:myjarproject', 'csl:wars:mywarproject'
> 
> *** contents of ./build.gradle
> 
> childrenDependOnMe()
> dependsOnChildren()
> 
> private static final boolean javacDeprecationFlag      = false
> private static final boolean javacWarningFlag          = false
> private static final String  javacSourceCompatibility  = "1.4"
> private static final String  javacTargetCompatibility  = "1.4"
> private static final String  axnArchivePrefix          = "axn"
> private static final String  axnGroup                  = "com.audatex.axn"
> private static final String  axnVersion                = "6.2"
> 
> allprojects {
>   group = axnGroup
>   version = axnVersion
>   archivesBaseName = axnArchivePrefix + project.archivesBaseName
>   setProperty("sourceCompatibility", javacSourceCompatibility)
>   setProperty("targetCompatibility", javacTargetCompatibility)
>   setProperty("compile.options.deprecation", javacDeprecationFlag)
>   setProperty("compile.options.warnings", javacWarningFlag)
>   dependencies {
>     classpathResolvers.add([ name: 'local_maven_repo', url: new File(
> rootDir, 'local_maven_repo' ).toURL().toString()])
>     classpathResolvers.add([ name:
> DependencyManager.DEFAULT_MAVEN_REPO_NAME, url:
> DependencyManager.MAVEN_REPO_URL ])
>   }
> }
> 
> *** contents of ./csl/build.gradle
> 
> childrenDependOnMe()
> dependsOnChildren()
> 
> subprojects {}
> 
> *** contents of ./csl/jars/build.gradle
> 
> childrenDependOnMe()
> dependsOnChildren()
> 
> subprojects {
>   usePlugin('java')
>   sourceCompatibility = project(':').getProperty("sourceCompatibility")
>   targetCompatibility = project(':').getProperty("targetCompatibility")
>   compile {
>     options.deprecation =
> project(':').getProperty("compile.options.deprecation")
>     options.warnings    =
> project(':').getProperty("compile.options.warnings")
>   }
> }
> 
> *** contents of ./csl/wars/build.gradle
> 
> childrenDependOnMe()
> dependsOnChildren()
> 
> subprojects {
>   usePlugin('war')
>   sourceCompatibility = project(':').getProperty("sourceCompatibility")
>   targetCompatibility = project(':').getProperty("targetCompatibility")
>   compile {
>     options.deprecation =
> project(':').getProperty("compile.options.deprecation")
>     options.warnings    =
> project(':').getProperty("compile.options.warnings")
>   }
>   dists {
>     war() {
>       fileSet(dir: 'src/public_html') {
>         excludes('WEB-INF')
>         includes('**/*')
>       }
>     }
>   }
> }
> 
> *** contents of ./csl/jars/myjarproject/build.gradle
> 
> type = 'jar'
> 
> dependencies {
>   compile "junit:junit:3.8.2"
> }
> 
> *** contents of ./csl/wars/mywarproject/build.gradle
> 
> type = 'war'
> 
> dependencies {
>   compile project(':csl:jars:myjarproject')
>   compile "javax.servlet:servlet-api:2.4"
> }
> 

-- 
View this message in context: 
http://www.nabble.com/War-Plugin-problems-tp18232294p18255648.html
Sent from the gradle-user mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply via email to