I'm trying to generate a jar
from a folder in which I manually compiled my classes.
Here is the task I put in place
task toJar (type: Jar) {
from file('/path/to/classes/dir')
destinationDir file('/path/to/jars/dir')
with jar
}
But what that task doesn't generate anything. I've seen may examples with configurations.compile.collect
but in my case the directory is compiled by an external tool.
How gradle
can generate a jar
from externally compiled classes ?
Your task should work fine, but you don't really need the with jar
.
Below is a working example, assuming that the directory with externally compiled classes is $rootDir/externalClasses
:
task toJar(type: Jar) {
from file("$rootDir/externalClasses")
destinationDir project.buildDir
// print each included file for debug purpose
eachFile { print "included file: $it" }
}
Output :
> Task :toJar
included file: file 'C:\tmp\gradle-projects\TestGradle\externalClasses\org\mycompany\gradle\MaiApp.class'
BUILD SUCCESSFUL in 0s
1 actionable task: 1 executed
The result Jar file is then properly created in $buildDir/
Can you try to remove the "with jar" line, and add the eachFile
debug closure in your code? what is the output?
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.