2
这是我的build.gradle的样子。我想能够从同一个项目中创建多个jar,但是每个jar都可以创建不同的主类? 最后的linkToBin函数将是最后一个被执行的函数,它应该通过做configurations.testRuntime.allArtifacts.files.forEach
来收集所有的瓶子。无论如何,最大的问题是我怎样才能从同一个源创建多个罐子,但是每个罐子都有不同的主类?任何帮助将是伟大的如何从同一来源创建多个罐子,但是每个罐子的主要类别不同?
apply plugin: 'idea'
apply plugin: 'java'
apply plugin: 'maven'
group 'com.hello'
version '1.0'
sourceCompatibility = 1.8
repositories {
mavenCentral()
flatDir {
dirs '/usr/local/hello/lib'
}
}
dependencies {
compile 'commons-cli:commons-cli:1.3.1'
compile 'org.slf4j:slf4j-log4j12:1.7.12'
testCompile group: 'junit', name: 'junit', version: '4.11'
compile "com.sparkjava:spark-core:2.5"
compile group: 'com.google.code.gson', name: 'gson', version: '2.6.2'
compile group: 'org.xerial', name: 'sqlite-jdbc', version: '3.8.11.2'
compile project(':anchor_service_api_thrift')
}
jar {
from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } }
from sourceSets.test.output
manifest {
attributes 'Main-Class': 'com.hello.echoserver.AnchorEchoServer'
}
exclude 'META-INF/.RSA', 'META-INF/.SF','META-INF/*.DSA'
}
task (anchorHttpServerJar, dependsOn: 'classes', type: Jar) {
from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } }
from sourceSets.test.output
archivesBaseName = 'anchor_echo_http_server'
version = '1.0-SNAPSHOT'
manifest {
attributes ('Main-Class': 'com.hello.httpserver.AnchorHttpServer')
}
exclude 'META-INF/.RSA', 'META-INF/.SF','META-INF/*.DSA'
}
artifacts {
archives anchorHttpServerJar
}
build.dependsOn(linkToBin)
在我来说,我想在同一个项目中的权利产生两个罐子不同的主类。那会是什么? – user1870400
您可以运行'gradle build'两次,同时提供主类名作为参数。 – yonisha