gradle-one-jar
gradle-one-jar copied to clipboard
Naming jar same as project name gives empty main.jar
If I use the following build, in a project that resides in /Users/gus/projects/solrsystem/SolrSystem/code/ingest, I get a onejar that has an empty main/main.jar.
apply plugin: 'java'
apply plugin: 'application'
apply plugin: 'gradle-one-jar'
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.github.rholder:gradle-one-jar:1.0.4'
}
}
repositories {
mavenCentral()
}
dependencies {
compile 'com.google.guava:guava:15.0'
compile 'com.google.code.findbugs:jsr305:2.0.2'
testCompile 'junit:junit:4.11'
}
task oneJar(type: OneJar) {
mainClass = 'org.solrsystem.ingest.Main'
archiveName = 'ingest.jar'
}
Yep, I'd consider that undesirable behavior. By default, a project's jar (as created from the built-in Jar Gradle task) is named according to the root project name. In this case, I believe it's replacing the existing project jar (of the same name) with the new OneJar jar that starts out as an empty file leaving it to then include the contents of the empty file.
I hit this same issue - it definitely annoying. Is there a way to get the jar file to be put in a different directory?
Just ran in to this issue as well.
So basically the archiveName to rename the final jar is not working, is it? any update on that ?
Try placing one-jar into separate directory, so that it will not conflict with a project's jar (as created from the built-in Jar Gradle task). This could be done via destinationDirectory property:
task oneJar(type: OneJar) {
mainClass = 'org.solrsystem.ingest.Main'
archiveName = 'ingest.jar'
destinationDirectory = file('${buildDir}/onejar')
}