On Jul 2, 2008, at 10:03 AM, 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.

To understand: You have everything in src/webapp but only src/webapp/ WEB-INF is included? That would be obviously bug. I gonna check this myself today and would provide a fix ASAP.

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?

usually:

mywarproject_war {
   // configure
}

If you don't want the project name as a default name for your archive task you can set the project property: archivesBaseName (which defaults to the project name) The basename of the task is also the default name of the actual archive file. You can always change the name of the archive file with:

mywarproject_war {
   baseName = 'othername'
}


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?

Nice and important use case ;).

Ivy can of course handle such a situation. Our DSL on top of Ivy has more constraints and is waiting for use cases to become more powerful ;). I gonna provide an improvement for this during the course of this day and let you know.

I have commented your attached build script. See below.

- Hans



|-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'

You may skip declaring inbetween projects like csl, csl:wars and csl:jars. They are included anyway.


*** contents of ./build.gradle

childrenDependOnMe()
dependsOnChildren()

These declarations are either or. For your use case you can leave this out completely.


private static final boolean javacDeprecationFlag      = false

javaDeprecationFlag = false (see Discussion in user's guide Appendix A1)

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)

sourceCompatibility = javacSourceCompatibility // does the same job

  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()

Can be deleted. See comment above.


subprojects {}

Of no use. Can be deleted.


*** contents of ./csl/jars/build.gradle

childrenDependOnMe()
dependsOnChildren()

Can be deleted.


subprojects {
  usePlugin('java')
sourceCompatibility = project(':').getProperty ("sourceCompatibility")

project(':'). sourceCompatibility

targetCompatibility = project(':').getProperty ("targetCompatibility")
  compile {
    options.deprecation =
project(':').getProperty("compile.options.deprecation")


project(':').compile.options.deprecation

    options.warnings    =
project(':').getProperty("compile.options.warnings")
  }
}

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

childrenDependOnMe()
dependsOnChildren()

Can be deleted.


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('**/*')
      }
    }
  }
}

This creates a task with a name that already exists. See above.


*** contents of ./csl/jars/myjarproject/build.gradle

type = 'jar'

Can be deleted


dependencies {
  compile "junit:junit:3.8.2"
}

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

type = 'war'

Can be deleted


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-tp18232294p18232294.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



--
Hans Dockter
Gradle Project lead
http://www.gradle.org





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

   http://xircles.codehaus.org/manage_email


Reply via email to