我的目录和文件名为src / main / java / HelloWorld / HelloWorld.java。我的build.gradle有:
sourceSets {
main {
java {
srcDir 'src'
}
}
}
task worldJar(type: Jar) {
baseName = "WorldJar"
from(sourceSets.main.output) {
include "HelloWorld/**"
}
}
但是,生成的jar中没有HelloWorld.class。知道我做错了吗?
答案 0 :(得分:0)
您必须创建单独的包并执行此操作:
sourceSets {
main {
java {
srcDir 'src'
}
}
}
task worldJar(type: Jar) {
baseName = "WorldJar"
println sourceSets.main.output
from(sourceSets.main.output) {
include "HelloWorld/**"
}
}
task spencerJar(type: Jar) {
baseName = "SpencerJar"
from(sourceSets.main.output) {
include "HelloSpencer/**"
}
}