Commit cd26c900 authored by Christian Meyer's avatar Christian Meyer
Browse files

fixed launcher jar not included in simulation distributions

removed ZmtDistributionPlugin.groovy
    split into ZmtDeployPlugin, ZmtLaunchPlugin.groovy
    updated ZmtSimulationPlugin and test
added ZmtLaunchPlugin.groovy
    containing fixes for simulations to include launcher
added ZmtDeployPlugin.groovy
    containing deploy workings of deleted ZmtDistributionPlugin
parent c4c88bb4
package de.zmt.gradle;
import org.gradle.api.*
import org.gradle.api.file.DuplicatesStrategy
/*
* Distribution plugin for simulations based on zmt.core
* Deploy plugin for simulations based on zmt.core
* <p>
* With this plugin the simulation's jar file, source, dependencies
* and the runtime dependencies are added to the distribution's lib
* folder. A CHANGES file is also added containing git tags and
* their descriptions.
* Adds 'deployZip' task for uploading to dochost. A CHANGES file is also
* added containing git tags and their descriptions.
*/
public class ZmtDistributionPlugin implements Plugin<Project> {
public class ZmtDeployPlugin implements Plugin<Project> {
private static final def CONFIGURE = {
apply plugin: 'application'
apply plugin: "org.hidetake.ssh"
mainClassName = "de.zmt.Main"
remotes {
dochost {
host = determineCredentials.host
......@@ -26,28 +20,7 @@ public class ZmtDistributionPlugin implements Plugin<Project> {
password = credentials.dochostPw
}
}
startScripts {
applicationName = 'launcher'
}
distributions {
main {
contents {
into ('lib') {
// project's own library and dependencies
from (project.jar)
from (project.sourceJar)
from (project.configurations.runtime)
}
// prevent adding duplicates
// e.g. when several projects depend on the same library
// otherwise they are added several times to archives
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
}
}
}
task('deployZip') {
group = 'Upload'
description = 'Uploads zip distribution to dochost.'
......@@ -92,6 +65,3 @@ public class ZmtDistributionPlugin implements Plugin<Project> {
project.configure(project, CONFIGURE)
}
}
package de.zmt.gradle;
import org.gradle.api.*
import org.gradle.api.file.DuplicatesStrategy
/*
* Distribution plugin for simulations based on zmt.core
* <p>
* With this plugin the simulation's jar file, source, dependencies
* and the runtime dependencies are added to the distribution's lib
* folder.
*/
public class ZmtLaunchPlugin implements Plugin<Project> {
private static final def MAIN_CLASS_NAME = 'de.zmt.Main'
private static final def CONFIGURE = {
apply plugin: 'distribution'
def launcherProject = rootProject.ext.properties.get('launcherProject')
distributions {
main {
contents {
into ('lib') {
// project's own library and dependencies
from (project.jar)
from (project.sourceJar)
from (project.configurations.runtime)
}
// prevent adding duplicates
// e.g. when several projects depend on the same library
// otherwise they are added several times to archives
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
}
}
}
// if launcher is not available
if (launcherProject == null) {
// ... add dependency
project.dependencies {
runtime 'de.zmt:zmt-launcher:latest.release'
}
}
// if launcher project is available and it is not this project
if (launcherProject != null && launcherProject != project) {
// ... include its distribution
launcherProject.afterEvaluate {
project.distributions.main.contents {
// include launcher and dependencies without sources
with (copySpec {
with (launcherProject.distributions.main.contents)
exclude('*sources*.jar')
})
}
}
}
// ... otherwise generate start scripts pointing to launcher
else {
apply plugin: 'application'
mainClassName = MAIN_CLASS_NAME
jar {
manifest {
attributes 'Main-Class': mainClassName
}
}
startScripts {
/* Although launcher does not depend on other simulations, those
* are needed to be included in the class path to be launched. */
classpath += files('$APP_HOME/lib/*')
applicationName = 'launcher'
}
}
}
@Override
void apply(Project project) {
project.configure(project, CONFIGURE)
}
}
......@@ -11,7 +11,8 @@ public class ZmtSimulationPlugin implements Plugin<Project> {
apply(plugin: ZmtJavaPlugin)
apply(plugin: ZmtJavadocPlugin)
apply(plugin: ZmtDochostPlugin)
apply(plugin: ZmtDistributionPlugin)
apply(plugin: ZmtLaunchPlugin)
apply(plugin: ZmtDeployPlugin)
apply(plugin: ZmtEclipsePlugin)
}
......
......@@ -17,7 +17,8 @@ class ZmtSimulationPluginTest {
assertTrue(plugins.hasPlugin(ZmtJavaPlugin.class))
assertTrue(plugins.hasPlugin(ZmtJavadocPlugin.class))
assertTrue(plugins.hasPlugin(ZmtDochostPlugin.class))
assertTrue(plugins.hasPlugin(ZmtDistributionPlugin.class))
assertTrue(plugins.hasPlugin(ZmtLaunchPlugin.class))
assertTrue(plugins.hasPlugin(ZmtDeployPlugin.class))
assertTrue(plugins.hasPlugin(ZmtEclipsePlugin.class))
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment