we have a multi-project gradle setup with one Java jar for each subproject:
- root-project
|-sub-project-a
|-sub-project-b
|-sub-project-c
Now, because we are creating a Java webstart application, we need to sign all project jars as well as all third-party libraries (dependencies).
My approach was now to copy all built subproject jars and all third-party libraries into a seperate folder and execute a task for signing them. However I am not able to copy the jars.
This was my approach in the root build.gradle:
task copyFiles(type: Copy, dependsOn: subprojects.jar) {
from configurations.runtime
from("build/libs")
into("webstart/lib")
include('*.jar')
}
together with:
task signAll(dependsOn: [copyFiles]) << {
new File('webstart/signed').mkdirs()
def libFiles = files { file('webstart/lib').listFiles() }
...
}
Then I tried to execute gradle signAll. However, I can only find an empty jar with the name of the root project in the webstart/lib folder.
Maybe my approach is completely wrong. What do I have to do to copy all created & thrid-party jars into a single folder?
Keyboard Command: Control (Ctrl) + C The COPY command is used for just that - it copies the text or image you have selected and stores is on your virtual clipboard, until it is overwritten by the next "cut" or "copy" command.
Step 1: Click on the first file to be selected. Step 2: Hold down Ctrl and click on all the files that you want to select additionally. Step 2: Press the Shift key and click on the last file. Step 3: You have now selected all files at once and can copy and move them.
Copying Directories with cp Command To copy a directory, including all its files and subdirectories, use the -R or -r option. The command above creates the destination directory and recursively copy all files and subdirectories from the source to the destination directory.
Copy and paste filesRight-click and pick Copy, or press Ctrl + C . Navigate to another folder, where you want to put the copy of the file. Click the menu button and pick Paste to finish copying the file, or press Ctrl + V . There will now be a copy of the file in the original folder and the other folder.
Add this piece of code to root build.gradle and it should work fine:
allprojects {
apply plugin: 'java'
repositories {
mavenCentral()
}
}
task copyJars(type: Copy, dependsOn: subprojects.jar) {
from(subprojects.jar)
into project.file('dest')
}
task copyDeps(type: Copy) {
from(subprojects.configurations.runtime)
into project.file('dest/lib')
}
task copyFiles(dependsOn: [copyJars, copyDeps])
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With