-
Notifications
You must be signed in to change notification settings - Fork 129
Provided Plugins
For the scenarios where packages have to be built for both CentOS and Ubuntu, it's likely they'll have the same paths to copy from and into. To help share settings between the output formats, or even to share between multiple tasks of the same type, this plugin exposes an extension that which will propagate to the tasks. Any settings set on the extension, will serve as defaults, while values on the task will take precedence. Any copy specs, e.g. from(), will apply to all tasks irrelevant of what the task specifies.
apply plugin: 'nebula.ospackage-base'
ospackage {
release '3'
os = LINUX // only applied to RPM
prefix '/opt/local' // also only applied to RPM
into '/opt/app1'
from ('dist') {
user 'builds'
exclude '**/*.rb'
}
}
task app1Rpm(type: Rpm) {
packageName = 'foo'
arch = I386
}
task app1Deb(type: Deb) {
}
Built on top of the os-package-base plugin, the os-package plugin automatically creates two tasks, buildRpm and buildDeb. This is useful when the project defaults are good and any configuration can be put into the ospackage extension. It leverages the fact that most project have no need to customize on a per-package-type basis and want a package for each platform supported.
apply plugin: 'nebula.ospackage'
ospackage {
release '3'
os = LINUX // only applied to RPM
into '/opt/app1'
from ('dist') {
user 'builds'
exclude '**/*.rb'
}
}
// buildRpm and buildDeb are implicitly created, but can still be configured if needed
buildRpm {
arch = I386
}
Builds the proper scripts for running a daemon (with daemontools) on CentOS and Ubuntu.
To include, add the following to your build.gradle
buildscript {
repositories { jcenter() }
dependencies {
classpath 'com.netflix.nebula:nebula-ospackage-plugin:3.+'
}
}
apply plugin: 'nebula.ospackage-daemon'
An extension is provided to configure possible daemons.
The simplest usage is a single daemon:
daemon {
daemonName = "foobar" // default = packageName
command = "sleep infinity" // required
}
Technically only the command field is needed, and the daemon's name will default to the package being built. This is the complete list of fields available:
- daemonName:String - Name used to start and stop the dameon
- command:String - Command to ensure is running
- user:String - User to run as, defaults to "root"
- logCommand:String - Log command to run, defaults to "multilog t ./main"
- runLevels:List - Run levels for daemon, rpm defaults to [3,4,5], deb defaults to [2,3,4,5]
- autoStart:Boolean - Should auto start, defaults to true
- startSequence:Integer - Boot ordering, default is 85
- stopSequence:Integer - Shutdown ordering, default is 15
Multiple daemons can be defined using the daemons extension, e.g.
daemons {
daemon {
// daemonName default = packageName
command = 'exit 0'
}
daemon {
daemonName = "foobar"
command = "sleep infinity" // required
}
daemon {
daemonName = "fooqux"
command = "sleep infinity"
user = "nobody"
logCommand = "cronolog /logs/foobar/foobar.log"
runLevels = [3,4]
autoStart = false
startSequence = 99
stopSequence = 1
}
}
A task used for templating will be created for each combination of System Packaging task and daemon. For example, if there's a daemon called Foobar, a Rpm task, and a Deb task, there would also be a buildDebFoobarDaemon task and a buildRpmFoobarDaemon task.
This plugin provide the following templates:
Version 5.1.0
introduces a configuration value to set the path to look for these templates. This way you can override them if necessary.
daemonsTemplates.folder = '/com/netflix/gradle/plugins/daemon/custom'
daemon {
daemonName = "foobar" // default = packageName
command = "sleep infinity" // required
}
With this change, ospackage will look for templates in /com/netflix/gradle/plugins/daemon/custom
wither in your classpath or local filesystem.
Takes the output of the Application plugin and packages it into a system package like a RPM or DEB. It uses the os-package plugin to accomplish this.
To include, add the following to your build.gradle
buildscript {
repositories { jcenter() }
dependencies {
classpath 'com.netflix.nebula:nebula-ospackage-plugin:3.+'
}
}
apply plugin: 'nebula.ospackage-application'
There is a single property available on a ospackage-application extension which controls the prefix.
ospackage_application {
prefix = '/usr/local'
}
Otherwise the prefix defaults to /opt, the actual installation will be to into /opt/$applicationName, where applicationName comes from the Application plugin. As usual to the Application plugin, the user has to provide a mainClassName.
Once configured with a system packaging task, the project will produce a DEB or RPM with the context of the application:
gradlew buildDeb
Combine the above two plugins to create a self-running daemon out of a Application plugin project.
Since this plugin is making the daemon for you, it could be difficult to access the standard daemon configuration. To alleviate this, there's a extension provided for configuring the application daemon, called applicationdaemon:
applicationdaemon {
user = "nobody"
}
Once configured, the project will produce a DEB and a RPM with the context of the application and the relevant daemon scripts:
gradlew buildDeb buildRpm