| import org.apache.tools.ant.filters.ReplaceTokens |
| |
| apply plugin: 'distribution' |
| |
| distributions { |
| main { |
| baseName = 'virgo-nano' |
| contents { |
| from { "${buildDir}/common_resources/" } |
| from ( 'src/main/dist' ) { |
| include ( '**/*.properties' ) |
| include ( '**/.version' ) |
| filter(ReplaceTokens, tokens: tokenMap) // tokens are used in e.g. oev.kernel.userregion.properties |
| } |
| from ( 'src/main/dist' ) { |
| include ( 'bin/*.sh' ) |
| fileMode 0755 |
| } |
| from ( 'src/main/dist' ) { |
| exclude ( '**/*.properties' ) |
| exclude ( '**/.version' ) |
| exclude ( 'bin/*.sh' ) |
| } |
| from ( "${buildDir}/VN/nano/" ) { exclude ( 'Eclipse.app' ) } |
| } |
| } |
| full { |
| baseName = 'virgo-nano-full' |
| contents { |
| from { 'src/main/dist' } |
| from { "${buildDir}/common_resources/" } |
| from ( 'src/main/dist' ) { |
| include ( '**/*.properties' ) |
| include ( '**/.version' ) |
| filter(ReplaceTokens, tokens: tokenMap) // tokens are used in e.g. oev.kernel.userregion.properties |
| } |
| from ( 'src/main/dist' ) { |
| include ( 'bin/*.sh' ) |
| fileMode 0755 |
| } |
| from ( 'src/main/dist' ) { |
| exclude ( '**/*.properties' ) |
| exclude ( '**/.version' ) |
| exclude ( 'bin/*.sh' ) |
| } |
| from ( "${buildDir}/VF/nano-full/" ) { exclude ( 'Eclipse.app' ) } |
| } |
| } |
| rap { |
| baseName = 'virgo-nano-rap' |
| contents { |
| from { "${buildDir}/common_resources/" } |
| from ( 'src/main/dist' ) { |
| include ( '**/*.properties' ) |
| include ( '**/.version' ) |
| filter(ReplaceTokens, tokens: tokenMap) // tokens are used in e.g. oev.kernel.userregion.properties |
| } |
| from ( 'src/main/dist' ) { |
| include ( 'bin/*.sh' ) |
| fileMode 0755 |
| } |
| from ( 'src/main/dist' ) { |
| exclude ( '**/*.properties' ) |
| exclude ( '**/.version' ) |
| exclude ( 'bin/*.sh' ) |
| } |
| from ( "${buildDir}/VR/nano-rap/" ) { exclude ( 'Eclipse.app' ) } |
| } |
| } |
| } |
| |
| task ('assembleNano', dependsOn: ['groupInstall',]) { |
| distZip.dependsOn('groupInstall') |
| fullDistZip.dependsOn('groupInstall') |
| rapDistZip.dependsOn('groupInstall') |
| } |
| |
| task ('prepareBundlesAndFeatures') { |
| def assemblyPluginsDir = file("${buildDir}/assembly/plugins/") |
| def srcFeatureDir = file("${projectDir}/publish_resources/features/") |
| def rapBundlesDir = file("${projectDir}/rapbundles/") |
| def assemblyFeatureDir = file("${buildDir}/assembly/features/") |
| doLast { |
| println "Copy the Virgo core runtime artifacts to '${assemblyPluginsDir}' - a p2 repo will be built around them." |
| copy { from configurations.virgoCoreRuntime into assemblyPluginsDir } |
| println "Copy the Virgo Nano runtime artifacts to '${assemblyPluginsDir}' - a p2 repo will be built around them." |
| copy { from configurations.nanoRuntime into assemblyPluginsDir } |
| println "Copy the Virgo enterprise runtime artifacts to '${assemblyPluginsDir}' - a p2 repo will be built around them." |
| copy { from configurations.enterpriseRuntime into assemblyPluginsDir } |
| println "Copy the RAP bundles from '${rapBundlesDir}' into '${assemblyPluginsDir}'." |
| copy { from rapBundlesDir into assemblyPluginsDir } |
| |
| println "Copy features from '${srcFeatureDir}' into '${assemblyFeatureDir}'." |
| copy { |
| from srcFeatureDir |
| into assemblyFeatureDir |
| include "**/*" |
| filter(ReplaceTokens, tokens: tokenMap) |
| } |
| } |
| } |
| |
| // start in debug mode with gradle generateP2Inf --debug-jvm |
| task ('generateP2Inf', type:JavaExec, dependsOn: ':packaging:fetchUnzippedVirgoBuildTools') { |
| description = "Generates p2.inf-s for all feature directories inside a wrapping 'features' directory." |
| def assemblyFeatureDir = file("${buildDir}/assembly/features/") |
| |
| main = 'org.eclipse.equinox.launcher.Main' |
| classpath = files("${virgoBuildToolsDir}/plugins/org.eclipse.equinox.launcher_${equinoxLauncherVersion}.jar") |
| args = [ |
| '-application', |
| 'org.eclipse.virgo.build.p2tools.instructions.P2InstructionGeneratorApplication', |
| '-source', |
| assemblyFeatureDir |
| ] |
| } |
| |
| // start in debug mode with gradle publishBundlesAndFeatures --debug-jvm |
| task ('publishBundlesAndFeatures', type:JavaExec) { |
| description = "Publishes Virgo Server bundles and features to '${buildDir}/repository'." |
| def sourceDir = file("${buildDir}/assembly/") |
| def repositoryDir = file("${buildDir}/repository/") |
| |
| main = 'org.eclipse.equinox.launcher.Main' |
| classpath = files("${virgoBuildToolsDir}/plugins/org.eclipse.equinox.launcher_${equinoxLauncherVersion}.jar") |
| args = [ |
| '-application', |
| 'org.eclipse.equinox.p2.publisher.FeaturesAndBundlesPublisher', |
| '-metadataRepository', |
| "file:${repositoryDir}", |
| '-artifactRepository', |
| "file:${repositoryDir}", |
| '-source', |
| "${sourceDir}", |
| '-append', |
| '-compress', |
| '-publishArtifacts', |
| ] |
| doLast() { println "Published Virgo Server bundles and features to '${buildDir}/repository'." } |
| } |
| |
| // TODO gradle-build remove duplicate method |
| def packageConfiguration(configurationName, configuration, target) { |
| println "Copy the ${configurationName} artifacts to '${target}'." |
| configuration.dependencies.each { dep -> |
| if(dep.hasProperty("dependencyProject")) { |
| println "Adding Virgo module dependency: ${dep}" |
| } else { |
| println "Adding other dependency: ${dep}" |
| } |
| } |
| copy { from configuration into target } |
| } |
| |
| task ('packageResourcesAndProducts') { |
| doLast { |
| packageConfiguration('lib', configurations.nanoLib, file("${buildDir}/common_resources/lib/")) |
| packageConfiguration('libPersistence', configurations.nanoLibPersistence, file("${buildDir}/common_resources/lib/persistence/")) |
| packageConfiguration('libEndorsed', configurations.nanoLibEndorsed, file("${buildDir}/common_resources/lib/endorsed/")) |
| packageConfiguration('pickup', configurations.nanoPickup, file("${buildDir}/common_resources/pickup/")) |
| } |
| } |
| |
| // start in debug mode with gradle publish<ID> |
| tasks.addRule("Pattern: publish<ID>") { String taskName -> |
| if (taskName.startsWith("publish")) { |
| task (taskName, type:JavaExec, dependsOn: [ |
| 'prepareBundlesAndFeatures', |
| 'generateP2Inf', |
| 'publishBundlesAndFeatures', |
| 'packageResourcesAndProducts', |
| ]) { |
| def product = 'undefined' |
| switch (taskName.toString() - 'publish') { |
| case 'Base': product = 'base'; break |
| case 'NanoBase': product = 'nano-base'; break |
| case 'Nano': product = 'nano'; break |
| case 'NanoFull': product = 'nano-full'; break |
| case 'NanoRap': product = 'nano-rap'; break |
| } |
| println "Publishing: " + product |
| |
| description = "Publishes a product to a p2 repository. The publishing uses ANY environment configurations." |
| def repositoryDir = file("${buildDir}/repository/") |
| def productFileLocation = file("${projectDir}/publish_resources/products/${product}/${product}.product") |
| def javaprofileLocation = file("${projectDir}/src/main/dist/configuration/java6-server.profile") |
| |
| main = 'org.eclipse.equinox.launcher.Main' |
| classpath = files("${virgoBuildToolsDir}/plugins/org.eclipse.equinox.launcher_${equinoxLauncherVersion}.jar") |
| args = [ |
| '-application', |
| 'org.eclipse.equinox.p2.publisher.ProductPublisher', |
| '-metadataRepository', |
| "file:${repositoryDir}", |
| '-artifactRepository', |
| "file:${repositoryDir}", |
| '-append', |
| '-compress', |
| '-publishArtifacts', |
| '-productFile', |
| "${productFileLocation}", |
| '-jreLocation', |
| "${javaprofileLocation}", |
| '-configs', |
| 'ANY.ANY.ANY', |
| '-flavor', |
| 'tooling' |
| ] |
| doLast() { println "Published Virgo ${productFileLocation} to '${buildDir}/repository'." } |
| } |
| } |
| } |
| |
| task ('groupPublish', dependsOn: [ |
| 'publishBase', |
| 'publishNanoBase', |
| 'publishNano', |
| 'publishNanoFull', |
| 'publishNanoRap', |
| ]){ } |
| |
| // start in debug mode with gradle publish<ID> |
| tasks.addRule("Pattern: installProduct<ID>") { String taskName -> |
| if (taskName.startsWith("installProduct")) { |
| // start in debug mode with gradle publishNanoBase --debug-jvm |
| task (taskName, type:JavaExec, dependsOn: ['groupPublish',]) { |
| description = "Installs a Virgo product to a desired destination. Default profile(roaming) is VIRGOProfile, the environment cofigurations are ANY." |
| def product = 'undefined' |
| def shortProduct = 'undefined' |
| switch (taskName.toString() - 'installProduct') { |
| case 'Nano': product = 'nano'; shortProduct = "VN"; break; |
| case 'NanoFull': product = 'nano-full'; shortProduct = "VF"; break; |
| case 'NanoRap': product = 'nano-rap'; shortProduct = "VR"; break; |
| } |
| println "Installing: " + product |
| |
| def repositoryDir = file("${buildDir}/repository/") |
| def destinationDir = file("${buildDir}/${shortProduct}/${product}") |
| def productIu = "${product}.product" |
| |
| main = 'org.eclipse.equinox.launcher.Main' |
| classpath = files("${virgoBuildToolsDir}/plugins/org.eclipse.equinox.launcher_${equinoxLauncherVersion}.jar") |
| args = [ |
| '-application', |
| 'org.eclipse.equinox.p2.director', |
| '-repository', |
| "file:${repositoryDir}", |
| '-installIU', |
| "${productIu}", |
| '-tag', |
| 'InitialState', |
| '-destination', |
| "${destinationDir}", |
| '-profile', |
| 'VIRGOProfile', |
| '-roaming' |
| ] |
| doLast() { println "Installed Virgo '${productIu}' to '${destinationDir}'." } |
| } |
| } |
| } |
| |
| task ('groupInstall', dependsOn: [ |
| 'installProductNano', |
| 'installProductNanoFull', |
| 'installProductNanoRap', |
| ]){ } |