Question

I have a gradle configuration which performs my compile and packaging of the war.

I have an ant script that I want to invoke after the war enunciate.codehaus.org. The ant script needs access to the jars that were bundled into the war.

Gradle configuration:

apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'war'

repositories {
    mavenCentral()
}

dependencies {
    compile "javax.ws.rs:jsr311-api:1.1.1"

    compile 'com.sun.jersey:jersey-server:1.16'
    compile 'com.sun.jersey:jersey-core:1.16'
    compile 'com.sun.jersey:jersey-client:1.16'
    compile 'com.sun.jersey:jersey-servlet:1.16'
    compile 'com.sun.jersey:jersey-json:1.16'

    testCompile "junit:junit-dep:4.10"
}

ant.importBuild 'ant-builds/enunciate/targets.xml'

part of the enunciate ant file:

<path id="enunciate.classpath">
    <!--this pulls in enunciate library files to be used to generate documentation -->
    <fileset dir="${enunciate.home}/lib">
        <include name="*.jar"/>
    </fileset>

    <!-- this pulls in some java framework libraries used to generate documentation -->
    <fileset dir="${java.home}">
        <include name="lib/tools.jar"/>
    </fileset>
</path>

How can I add the dependencies of the war to this file set? When gradle compile the war, do the jars (that are dependencies and then packaged into the war) get put somewhere that I could reference?

I assume that it has to do with using the dependencies or configuration class, but cannot seem to pull this together.

Was it helpful?

Solution

From gradle build, you can set the ant properties, for example. the ant classpath in the following target can be set in gralde build.

<enunciate basedir="${enunciate.baseSourceDirectory}" configFile="enunciate.xml">
<include name="**/*.java"/>
<classpath refid="enunciate.classpath"/>
<classpath>
    <pathelement path="${enunciate.dependencies}"/>
</classpath>
<export artifactId="docs" destination="${enunciate.destinationDirectory}/some-icd.tar"/>

In build.gradle, "enunciate.dependencies" can be set as ant.properties['enunciate.dependencies']=configurations.runtime.asPath

I hope this helps.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top