How to get a deb package from a Java Gradle project which after installation of the deb file automatically generates /etc/systemd/system/project.service, and adds binary files in /var/project/bin/, and config files in /etc/project/.
Something like https://github.com/nebula-plugins/gradle-ospackage-plugin but with systemd support.
Sorry for bad English!
I found out that I can use the nebula-plugin that mention in question.
I just need to add this lines to build.gradle file:
buildDeb {
link('/etc/systemd/system/project.service', '/opt/project/bin/project.service')
}
And also create a project.service file like below and make the plugin moves the service file to install directory of deb package:
[Unit]
Description=<description>
[Service]
User=<user>
Group=<group>
EnvironmentFile=-/etc/default/project
ExecStart=/opt/project/bin/project > /var/log/project/project.log
Restart=no
[Install]
WantedBy=multi-user.target
The code below will copy service file (if you put it in the bin directory of the project root) and all other necessary files to install directory of deb file:
ospackage {
packageName = 'project'
configurationFile "/opt/project/bin/project.service"
into '/opt/project'
from(jar.outputs.files) {
into 'lib'
}
from(configurations.runtime) {
into 'lib'
}
from('build/libs') {
into 'lib'
}
from('conf'){
into 'conf'
}
from('bin') { //project.service is in bin directory
fileType = CONFIG | NOREPLACE //wont replace any configurationFile in this directory
into 'bin'
}
from('build/scripts') {
into 'bin'
exclude 'database'
fileMode = 0550
}
}