简体   繁体   中英

How can I add jar/war dependencies to ant fileset while using gradle?

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM