Building class-path in war MANIFEST


(fozzykh) #1

I would like to take the gradle classpath (e.g. compile) and use it to create classpath in manifest file. How it can be archived?

apply plugin: 'war'
  dependencies {
 compile 'org.codehaus.groovy:groovy-all:1.6.0'
       }
  war{
 manifest {
         attributes 'Class-Path': compile
     }
 }

Thanks in advance


(René Groeschke) #2

instead of writing ‘compile’ you nee to write ‘configurations.compile.asPath’. one downside atm is that this will trigger the resolve of the compile configuration at configuration time. as a workaround you can move the manifest configuration into a doFirst block

cheers, rene


(fozzykh) #3

Thank you for your fast reply. I have another question :

I used the asPath and it worked, but I got the absolute jar paths from repository.

Is there a way to customize this ? for example a way to append the jars name to a path prefix which I determine lets say to append the jar names to 'myDir/jars/*.jar ?

Regards, Foz


(benilda39) #4

hi … plz help me to get out from this problem … i want to create a WAR file … mine is creating … but war file contain only manifest file … other files are not there … i want to include all the jar files and want to create the exact war file for that …here is my code… plz help… i dont know gradle well… simply from net i have taken code and developed this

apply plugin: ‘java’ apply plugin: ‘eclipse’ apply plugin: ‘war’ apply plugin: ‘jetty’ File jarFile

repositories {

mavenCentral()

flatDir { dirs “lib” } }

dependencies {

compile files(’${project.projectDir}/gradle/wrapper/gradle-wrapper.jar’)

}

sourceCompatibility = 1.5 version = ‘1.0’ jar {

manifest {

attributes ‘Implementation-Title’: ‘Gradle Quickstart’, ‘Implementation-Version’: version

} }

test {

systemProperties ‘property’: ‘value’ }

uploadArchives {

repositories {

flatDir {

dirs ‘libs’

}

} } war {

destinationDir = new File(‘test’) }


(benilda39) #5

hi all … please help me to create a war file for a eclipse project …


(René Groeschke) #6

Sorry, I don’t understand your question. Are you saying that the war file created by the war task does not contain the (jar) files you’re expecting? Apart from declaring a compile dependency on the gradle wrapper file (Usually you don’t need that / can you explain why you have a dependency on the gradle wrapper?) you havn’t declared any dependencies. That’s why no jars end up in your war archive.

Please consult the war plugin chapter (http://www.gradle.org/docs/current/userguide/userguide_single.html#war_plugin) for details about how the war plugin works.

cheers, René