Using gradle 3.4 but fairly new to it.
If I run gradlew installDist the files in src/main/java get copied to the build folder all that works fine.
But I also have an extra folder in src/main/conf I would like to copy over to build/install/my-artifact/conf
I don't want to put it in src/main/resources because that will get included inside the jar. I would like to keep it external.
My gradle file doesn't have anything special except the dependencies.
So how would I go about copying the folders/files when installDist runs?
EDIT:
Has to work with shadow plugin as well.
To manage distribution contents, you will need to modify the main
distribution like the following :
apply plugin: 'distribution'
distributions {
main {
baseName = 'my-artifact'
contents {
from { 'src/main/java' }
from('src/main') {
include 'conf/**'
}
}
}
}
This will :
src/main/java
conf
and the files under itThe new structure would be like :
build/install/my-artifact/
│
├── com/
│ └── yourlib
│ └── ......
└── conf/
└── .....
You could also include the source directory at the same level :
build/install/my-artifact/
│
├── java/
│ └── com/
│ └── yourlib
│ └── ......
└── conf/
└── .....
with the following :
apply plugin: 'distribution'
distributions {
main {
baseName = 'my-artifact'
contents {
from('src/main') {
include 'java/**'
include 'conf/**'
}
}
}
}
Check CopySpec interface for more info