私はGradle 1.3を使用しており、小さなプロジェクトで動作しています。.JAR ファイルは、希望どおりに作成されます。しかし、distZip を使用して ZIP ファイルを作成してもらうと、すべての JAR ファイルが含まれています。
私のbuild.gradleファイルの内容:
apply plugin: 'java'
apply plugin: 'maven'
apply plugin: 'application'
group = 'com.some.project'
version = '1.0.2.0'
description = 'Update Server'
mainClassName = 'com.some.project.updateserver.client.Client'
defaultTasks 'compileJava', 'jar'
[compileJava, compileTestJava]*.options*.encoding = 'UTF-8'
allprojects {
tasks.withType(Compile) {
options.debug = true
options.compilerArgs = ['-Xlint:all']
}
}
dependencies {
compile "$commonsCodecGroup:commons-codec:$commonsCodecVersion"
compile "$commonsConfigurationGroup:commons-configuration:$commonsConfigurationVersion"
compile "$commonsLangGroup:commons-lang:$commonsLangVersion"
compile "$commonsLoggingGroup:commons-logging:$commonsLoggingVersion"
compile "$cxfGroup:cxf-bundle-minimal:$cxfVersion"
compile "$cxfGroup:cxf-rt-databinding-jaxb:$cxfVersion"
compile "$cxfGroup:cxf-rt-frontend-jaxrs:$cxfVersion"
compile "$cxfGroup:cxf-rt-transports-common:$cxfVersion"
compile "$cxfGroup:cxf-rt-transports-http:$cxfVersion"
compile "$jacksonGroup:jackson-jaxrs:$jacksonVersion"
compile "$jmockitGroup:jmockit:$jmockitVersion"
compile "$logBackGroup:logback-classic:$logBackVersion"
compile "$logBackGroup:logback-core:$logBackVersion"
compile "$servletGroup:servlet-api:$servletVersion"
compile "$slf4jGroup:slf4j-api:$slf4jVersion"
compile "$springGroup:spring-aop:$springVersion"
compile "$springGroup:spring-asm:$springVersion"
compile "$springGroup:spring-beans:$springVersion"
compile "$springGroup:spring-context:$springVersion"
compile "$springGroup:spring-core:$springVersion"
compile "$springGroup:spring-expression:$springVersion"
compile "$springGroup:spring-tx:$springVersion"
compile "$springGroup:spring-web:$springVersion"
compile "$wsRestfulGroup:jsr311-api:$wsRestfulVersion"
testCompile "$junitGroup:junit:$junitVersion"
}
repositories {
mavenCentral()
}
task clientJar(type: Jar, description: 'Assembles a jar archive for running a simple client against the Update Server.') {
appendix = 'client'
from sourceSets.main.output
exclude('applicationContext.xml')
exclude('com/some/project/json')
exclude('com/some/project/updateserver/jaxrs')
exclude('com/some/project/updateserver/oauth')
exclude('com/some/project/updateserver/resource')
exclude('com/some/project/updateserver/util/ManifestHash*')
}
task modelJar(type: Jar, description: 'Assembles a jar archive for reference by other projects that need to access the API model of Update Server.') {
appendix = 'model'
from sourceSets.main.output.classesDir
exclude('applicationContext.xml')
exclude('update-server-client.properties')
exclude('com/some/project/json')
exclude('com/some/project/updateserver/client')
exclude('com/some/project/updateserver/jaxrs')
exclude('com/some/project/updateserver/oauth')
exclude('com/some/project/updateserver/resource')
}
jar {
description = 'Assembles the relevant archive files for Update Server'
dependsOn clientJar, modelJar
exclude('update-server-client.properties')
exclude('com/some/project/updateserver/client')
}
test {
testLogging.exceptionFormat 'full'
testLogging {
events 'passed'
minGranularity = 3
stackTraceFilters 'groovy', 'entry_point', 'truncate'
showStandardStreams = true
debug {
events 'started'
}
}
}
run {
description = 'Runs the Update Server Client application'
jvmArgs '-client'
// optional args can be specified
// args 'name1', 'value1'
}
distZip {
archiveName "$project.name-client.zip"
exclude('**/aopalliance-*.jar')
exclude('**/asm-3.3.jar')
exclude('**/bcprov-jdk*.jar')
exclude('**/commons-codec-*.jar')
exclude('**/commons-httpclient-*.jar')
exclude('**/cxf-api-*.jar')
exclude('**/cxf-common-utilities-*.jar')
exclude('**/cxf-rt-bindings-*.jar')
exclude('**/cxf-rt-core*.jar')
exclude('**/geronimo-*.jar')
exclude('**/isorelax-*.jar')
exclude('**/jaxb-*.jar')
exclude('**/jcip-annotations-*.jar')
exclude('**/jcl-over-slf4j-*.jar')
exclude('**/jettison-*.jar')
exclude('**/jetty-*.jar')
exclude('**/jmockit-*.jar')
exclude('**/joda-time-*.jar')
exclude('**/jul-to-slf4j-*.jar')
exclude('**/log4j-over-slf4j-*.jar')
exclude('**/logback-*.jar')
exclude('**/mimepull-*.jar')
exclude('**/msv-core-*.jar')
exclude('**/not-yet-commons-*.jar')
exclude('**/opensaml-*.jar')
exclude('**/openws-*.jar')
exclude('**/relaxngDatatype-*.jar')
exclude('**/saaj-*.jar')
exclude('**/serializer-*.jar')
exclude('**/servlet-api-*.jar')
exclude('**/slf4j-api*.jar')
exclude('**/spring-*.jar')
exclude('**/stax-*.jar')
exclude('**/woodstox-*.jar')
exclude('**/wssj4j-*.jar')
exclude('**/xalan-*.jar')
exclude('**/xmlbeans-*.jar')
exclude('**/xml-resolver-*.jar')
exclude('**/xmlschema-*.jar')
exclude('**/xmlsec-*.jar')
exclude('**/xmltooling-*.jar')
exclude('**/xsdlib-*.jar')
}
作成されるプライマリ JAR ファイル:
update-server-1.0.2.0.jar
-------------------------
applicationContext.xml
com/pearson/pss/json/JsonUtil.class
com/pearson/pss/updateserver/jaxrs/
com/pearson/pss/updateserver/jaxrs/JacksonObjectMapperFactory.class
com/pearson/pss/updateserver/model/PowerSchoolServerData$UPDATE_CATEGORY.class
com/pearson/pss/updateserver/model/PowerSchoolServerData.class
com/pearson/pss/updateserver/model/SimplePackageDescription.class
com/pearson/pss/updateserver/model/UpdateData.class
com/pearson/pss/updateserver/oauth/OAuthIdentity.class
com/pearson/pss/updateserver/oauth/OAuthTarget.class
com/pearson/pss/updateserver/oauth/OAuthTargetRegistry.class
com/pearson/pss/updateserver/oauth/OAuthTargetUpdateServerDownload.class
com/pearson/pss/updateserver/oauth/OAuthTicketData.class
com/pearson/pss/updateserver/oauth/PowerSourceDLOAuthBackChannel$PostValue.class
com/pearson/pss/updateserver/oauth/PowerSourceDLOAuthBackChannel.class
com/pearson/pss/updateserver/resource/Config$1.class
com/pearson/pss/updateserver/resource/Config.class
com/pearson/pss/updateserver/resource/CurrentDistrict$1.class
com/pearson/pss/updateserver/resource/CurrentDistrict.class
com/pearson/pss/updateserver/resource/DistrictDownloadRestriction.class
com/pearson/pss/updateserver/resource/OAuthDownloadFilter.class
com/pearson/pss/updateserver/resource/UpdateResource$1.class
com/pearson/pss/updateserver/resource/UpdateResource.class
com/pearson/pss/updateserver/util/ManifestHash.class
com/pearson/pss/updateserver/util/PackageUtil$1.class
com/pearson/pss/updateserver/util/PackageUtil$Architecture.class
com/pearson/pss/updateserver/util/PackageUtil$OS.class
com/pearson/pss/updateserver/util/PackageUtil.class
com/pearson/pss/updateserver/util/UpdateServerConstants.class
META-INF/cxf/org.apache.cxf.Logger
META-INF/MANIFEST.MF
単純なクライアントを実行するために作成される JAR ファイル:
update-server-client-1.0.2.0.jar
--------------------------------
com/pearson/pss/updateserver/client/Client.class
com/pearson/pss/updateserver/model/PowerSchoolServerData$UPDATE_CATEGORY.class
com/pearson/pss/updateserver/model/PowerSchoolServerData.class
com/pearson/pss/updateserver/model/SimplePackageDescription.class
com/pearson/pss/updateserver/model/UpdateData.class
com/pearson/pss/updateserver/util/PackageUtil$1.class
com/pearson/pss/updateserver/util/PackageUtil$Architecture.class
com/pearson/pss/updateserver/util/PackageUtil$OS.class
com/pearson/pss/updateserver/util/PackageUtil.class
com/pearson/pss/updateserver/util/UpdateServerConstants.class
META-INF/cxf/org.apache.cxf.Logger
META-INF/MANIFEST.MF
update-server-client.properties
API を公開するために作成される JAR ファイル:
update-server-model-1.0.2.0.jar
--------------------------------
com/pearson/pss/updateserver/model/PowerSchoolServerData$UPDATE_CATEGORY.class
com/pearson/pss/updateserver/model/PowerSchoolServerData.class
com/pearson/pss/updateserver/model/SimplePackageDescription.class
com/pearson/pss/updateserver/model/UpdateData.class
com/pearson/pss/updateserver/util/ManifestHash.class
com/pearson/pss/updateserver/util/PackageUtil$1.class
com/pearson/pss/updateserver/util/PackageUtil$Architecture.class
com/pearson/pss/updateserver/util/PackageUtil$OS.class
com/pearson/pss/updateserver/util/PackageUtil.class
com/pearson/pss/updateserver/util/UpdateServerConstants.class
META-INF/MANIFEST.MF
「distZip」の実行時に作成される実際の ZIP ファイル:
update-server-1.0.2.0.zip (actual contents)
-------------------------------------------
update-server-1.0.2.0/bin/update-server
update-server-1.0.2.0/bin/update-server.bat
update-server-1.0.2.0/lib/aopalliance-1.0.jar
update-server-1.0.2.0/lib/asm-3.3.jar
update-server-1.0.2.0/lib/bcprov-jdk15-1.45.jar
update-server-1.0.2.0/lib/commons-codec-1.4.jar
update-server-1.0.2.0/lib/commons-configuration-1.8.jar
update-server-1.0.2.0/lib/commons-httpclient-3.1.jar
update-server-1.0.2.0/lib/commons-lang-2.6.jar
update-server-1.0.2.0/lib/commons-logging-1.1.1.jar
update-server-1.0.2.0/lib/cxf-api-2.5.2.jar
update-server-1.0.2.0/lib/cxf-bundle-minimal-2.5.2.jar
update-server-1.0.2.0/lib/cxf-common-utilities-2.5.2.jar
update-server-1.0.2.0/lib/cxf-rt-bindings-xml-2.5.2.jar
update-server-1.0.2.0/lib/cxf-rt-core-2.5.2.jar
update-server-1.0.2.0/lib/cxf-rt-databinding-jaxb-2.5.2.jar
update-server-1.0.2.0/lib/cxf-rt-frontend-jaxrs-2.5.2.jar
update-server-1.0.2.0/lib/cxf-rt-transports-common-2.5.2.jar
update-server-1.0.2.0/lib/cxf-rt-transports-http-2.5.2.jar
update-server-1.0.2.0/lib/geronimo-activation_1.1_spec-1.1.jar
update-server-1.0.2.0/lib/geronimo-annotation_1.0_spec-1.1.1.jar
update-server-1.0.2.0/lib/geronimo-javamail_1.4_spec-1.7.1.jar
update-server-1.0.2.0/lib/geronimo-jaxws_2.2_spec-1.1.jar
update-server-1.0.2.0/lib/geronimo-jms_1.1_spec-1.1.1.jar
update-server-1.0.2.0/lib/geronimo-servlet_2.5_spec-1.1.2.jar
update-server-1.0.2.0/lib/geronimo-stax-api_1.0_spec-1.0.1.jar
update-server-1.0.2.0/lib/geronimo-ws-metadata_2.0_spec-1.1.3.jar
update-server-1.0.2.0/lib/isorelax-20030108.jar
update-server-1.0.2.0/lib/jackson-core-asl-1.9.4.jar
update-server-1.0.2.0/lib/jackson-jaxrs-1.9.4.jar
update-server-1.0.2.0/lib/jackson-mapper-asl-1.9.4.jar
update-server-1.0.2.0/lib/jaxb-api-2.2.3.jar
update-server-1.0.2.0/lib/jaxb-impl-2.2.4-1.jar
update-server-1.0.2.0/lib/jaxb-xjc-2.2.4-1.jar
update-server-1.0.2.0/lib/jcip-annotations-1.0.jar
update-server-1.0.2.0/lib/jcl-over-slf4j-1.6.1.jar
update-server-1.0.2.0/lib/jettison-1.3.1.jar
update-server-1.0.2.0/lib/jetty-continuation-7.5.4.v20111024.jar
update-server-1.0.2.0/lib/jetty-http-7.5.4.v20111024.jar
update-server-1.0.2.0/lib/jetty-io-7.5.4.v20111024.jar
update-server-1.0.2.0/lib/jetty-security-7.5.4.v20111024.jar
update-server-1.0.2.0/lib/jetty-server-7.5.4.v20111024.jar
update-server-1.0.2.0/lib/jetty-util-7.5.4.v20111024.jar
update-server-1.0.2.0/lib/jmockit-0.999.19.jar
update-server-1.0.2.0/lib/joda-time-1.6.2.jar
update-server-1.0.2.0/lib/jsr311-api-1.1.1.jar
update-server-1.0.2.0/lib/jul-to-slf4j-1.6.1.jar
update-server-1.0.2.0/lib/log4j-over-slf4j-1.6.1.jar
update-server-1.0.2.0/lib/logback-classic-1.0.0.jar
update-server-1.0.2.0/lib/logback-core-1.0.0.jar
update-server-1.0.2.0/lib/mimepull-1.4.jar
update-server-1.0.2.0/lib/msv-core-2011.1.jar
update-server-1.0.2.0/lib/neethi-3.0.1.jar
update-server-1.0.2.0/lib/not-yet-commons-ssl-0.3.9.jar
update-server-1.0.2.0/lib/opensaml-2.5.1-1.jar
update-server-1.0.2.0/lib/openws-1.4.2-1.jar
update-server-1.0.2.0/lib/relaxngDatatype-20020414.jar
update-server-1.0.2.0/lib/saaj-api-1.3.4.jar
update-server-1.0.2.0/lib/saaj-impl-1.3.12.jar
update-server-1.0.2.0/lib/serializer-2.7.1.jar
update-server-1.0.2.0/lib/servlet-api-2.5.jar
update-server-1.0.2.0/lib/slf4j-api-1.6.4.jar
update-server-1.0.2.0/lib/spring-aop-3.1.1.RELEASE.jar
update-server-1.0.2.0/lib/spring-asm-3.1.1.RELEASE.jar
update-server-1.0.2.0/lib/spring-beans-3.1.1.RELEASE.jar
update-server-1.0.2.0/lib/spring-context-3.1.1.RELEASE.jar
update-server-1.0.2.0/lib/spring-core-3.1.1.RELEASE.jar
update-server-1.0.2.0/lib/spring-expression-3.1.1.RELEASE.jar
update-server-1.0.2.0/lib/spring-jms-3.0.6.RELEASE.jar
update-server-1.0.2.0/lib/spring-tx-3.1.1.RELEASE.jar
update-server-1.0.2.0/lib/spring-web-3.1.1.RELEASE.jar
update-server-1.0.2.0/lib/stax2-api-3.1.1.jar
update-server-1.0.2.0/lib/update-server-1.0.2.0.jar
update-server-1.0.2.0/lib/woodstox-core-asl-4.1.1.jar
update-server-1.0.2.0/lib/wsdl4j-1.6.2.jar
update-server-1.0.2.0/lib/wss4j-1.6.4.jar
update-server-1.0.2.0/lib/xalan-2.7.1.jar
update-server-1.0.2.0/lib/xmlbeans-2.5.0.jar
update-server-1.0.2.0/lib/xml-resolver-1.2.jar
update-server-1.0.2.0/lib/xmlschema-core-2.0.1.jar
update-server-1.0.2.0/lib/xmlsec-1.4.6.jar
update-server-1.0.2.0/lib/xmltooling-1.3.2-1.jar
update-server-1.0.2.0/lib/xsdlib-2010.1.jar
クライアントは、プロジェクト全体で必要なすべての JAR ファイルを必要とするわけではなく、ごく一部のファイルのみを必要とします。これは、ZIPファイルを次のようにしたいものです。
update-server-1.0.2.0.zip (wanted contents)
-------------------------------------------
update-server-1.0.2.0/bin/update-server
update-server-1.0.2.0/bin/update-server.bat
update-server-1.0.2.0/lib/commons-configuration-1.8.jar
update-server-1.0.2.0/lib/commons-lang-2.6.jar
update-server-1.0.2.0/lib/commons-logging-1.1.1.jar
update-server-1.0.2.0/lib/cxf-bundle-minimal-2.5.2.jar
update-server-1.0.2.0/lib/cxf-rt-databinding-jaxb-2.5.2.jar
update-server-1.0.2.0/lib/cxf-rt-frontend-jaxrs-2.5.2.jar
update-server-1.0.2.0/lib/cxf-rt-transports-common-2.5.2.jar
update-server-1.0.2.0/lib/cxf-rt-transports-http-2.5.2.jar
update-server-1.0.2.0/lib/jackson-core-asl-1.9.4.jar
update-server-1.0.2.0/lib/jackson-jaxrs-1.9.4.jar
update-server-1.0.2.0/lib/jackson-mapper-asl-1.9.4.jar
update-server-1.0.2.0/lib/jsr311-api-1.1.1.jar
update-server-1.0.2.0/lib/neethi-3.0.1.jar
update-server-1.0.2.0/lib/wsdl4j-1.6.2.jar
build.gradle ファイルを変更してクライアントの不要な JAR ファイルを除外する方法を教えてください。