Skip to content
Snippets Groups Projects
Commit 77e913c1 authored by dgelessus's avatar dgelessus
Browse files

Fix dubious indents and formatting in Gradle scripts

parent 012a9ec3
Branches
Tags
No related merge requests found
Pipeline #66413 passed
...@@ -2,10 +2,11 @@ ...@@ -2,10 +2,11 @@
import org.apache.tools.ant.taskdefs.condition.Os import org.apache.tools.ant.taskdefs.condition.Os
project.ext { project.ext {
targetRepositories = [
targetRepositories = ["http://download.eclipse.org/releases/luna/", "http://download.eclipse.org/releases/luna/",
"http://rodin-b-sharp.sourceforge.net/updates", "http://rodin-b-sharp.sourceforge.net/updates",
"https://www3.hhu.de/stups/buildlibs/org.rodinp.dev/"] "https://www3.hhu.de/stups/buildlibs/org.rodinp.dev/",
]
groupID = "de.prob" groupID = "de.prob"
} }
...@@ -16,7 +17,6 @@ apply from: 'tycho_build.gradle' ...@@ -16,7 +17,6 @@ apply from: 'tycho_build.gradle'
/*task bMotionStudioHelpCustumBuild(type: Exec){ /*task bMotionStudioHelpCustumBuild(type: Exec){
commandLine 'ant', '-f','de.bmotionstudio.help/customBuild.xml' commandLine 'ant', '-f','de.bmotionstudio.help/customBuild.xml'
} }
...@@ -25,12 +25,10 @@ install.dependsOn bMotionStudioHelpCustumBuild ...@@ -25,12 +25,10 @@ install.dependsOn bMotionStudioHelpCustumBuild
completeInstall.dependsOn bMotionStudioHelpCustumBuild*/ completeInstall.dependsOn bMotionStudioHelpCustumBuild*/
project(':de.prob.core') { project(':de.prob.core') {
repositories { repositories {
mavenCentral() mavenCentral()
} }
def parser_version = '2.5.1' def parser_version = '2.5.1'
dependencies { dependencies {
...@@ -44,7 +42,6 @@ project(':de.prob.core') { ...@@ -44,7 +42,6 @@ project(':de.prob.core') {
compile group: "de.hhu.stups", name: "theorymapping", version: parser_version, changing: true compile group: "de.hhu.stups", name: "theorymapping", version: parser_version, changing: true
compile 'commons-lang:commons-lang:2.6' compile 'commons-lang:commons-lang:2.6'
} }
} }
project(':de.prob.ui') { project(':de.prob.ui') {
...@@ -98,9 +95,7 @@ task downloadCli { ...@@ -98,9 +95,7 @@ task downloadCli {
} }
task downloadCli2 (type: Exec) { task downloadCli2 (type: Exec) {
def dir = workspacePath + 'de.prob.core/prob/' def dir = workspacePath + 'de.prob.core/prob/'
delete file(dir) delete file(dir)
new File(dir).mkdirs() new File(dir).mkdirs()
...@@ -132,7 +127,6 @@ task downloadCli2 ( type: Exec ) { ...@@ -132,7 +127,6 @@ task downloadCli2 ( type: Exec ) {
} }
completeInstall.dependsOn downloadCli completeInstall.dependsOn downloadCli
completeInstall.dependsOn subprojects.setClassPath completeInstall.dependsOn subprojects.setClassPath
......
...@@ -7,7 +7,6 @@ import org.apache.tools.ant.taskdefs.condition.Os ...@@ -7,7 +7,6 @@ import org.apache.tools.ant.taskdefs.condition.Os
Pom Generation can be executed via gradle deploy Pom Generation can be executed via gradle deploy
If you have a product definition please add a buildProduct = true to your main build.gradle script If you have a product definition please add a buildProduct = true to your main build.gradle script
*/ */
...@@ -28,14 +27,12 @@ try{ ...@@ -28,14 +27,12 @@ try{
project.ext.excludeFromClassPath = [] project.ext.excludeFromClassPath = []
} }
try { try {
workspacePath = workspacePath workspacePath = workspacePath
} catch (MissingPropertyException e) { } catch (MissingPropertyException e) {
project.ext.workspacePath = "" project.ext.workspacePath = ""
} }
try { try {
dependencyFolder = dependencyFolder dependencyFolder = dependencyFolder
} catch (MissingPropertyException e) { } catch (MissingPropertyException e) {
...@@ -45,48 +42,45 @@ try{ ...@@ -45,48 +42,45 @@ try{
try { try {
groupID = groupID groupID = groupID
} catch (MissingPropertyException e) { } catch (MissingPropertyException e) {
// workspace nach releng durchsuchen // workspace nach releng durchsuchen
def folderNames = [] def folderNames = []
def folders = [] def folders = []
println "folders:" println "folders:"
new File(workspacePath+".").listFiles().each{dir -> new File(workspacePath+".").listFiles().each{dir ->
if( dir.isDirectory() ) folders << dir.getName() if (dir.isDirectory()) {
folders << dir.getName()
}
} }
folders.each(){ it -> folders.each { it ->
it = (String)it.replaceFirst(/\.\//, "") it = (String)it.replaceFirst(/\.\//, "")
if( !( ( it ==~ /\..+/ ) || (it ==~ /.*.repository/) || (it ==~ /.*.parent/) ) ) folderNames << it // subProjects eventuell unnötig settings.gradle datei stattdessen benutzen // subProjects eventuell unnötig settings.gradle datei stattdessen benutzen
if (!(it ==~ /\..+/ || it ==~ /.*.repository/ || it ==~ /.*.parent/)) {
folderNames << it
}
} }
project.ext.groupID = "group" project.ext.groupID = "group"
for (int i = 0; i < folderNames.size(); i++) { for (int i = 0; i < folderNames.size(); i++) {
if (folderNames[i] ==~ /.*\.[rR]eleng/) { if (folderNames[i] ==~ /.*\.[rR]eleng/) {
groupID = folderNames[i] groupID = folderNames[i]
groupID = groupID.replace(".releng", "") groupID = groupID.replace(".releng", "")
groupID = groupID.replace(".Releng", "") groupID = groupID.replace(".Releng", "")
} }
} }
} }
try { try {
features = features features = features
} catch (MissingPropertyException e) { } catch (MissingPropertyException e) {
project.ext.features = [] project.ext.features = []
for (int i = 0; i < subprojects.name.size(); i++){ for (int i = 0; i < subprojects.name.size(); i++){
if (subprojects.name[i] ==~ /.*\.[fF]eature/) { if (subprojects.name[i] ==~ /.*\.[fF]eature/) {
features.add(subprojects.name[i]) features.add(subprojects.name[i])
} }
} }
} }
try { try {
repositoryName = repositoryName repositoryName = repositoryName
} catch (MissingPropertyException e) { } catch (MissingPropertyException e) {
...@@ -106,7 +100,8 @@ try{ ...@@ -106,7 +100,8 @@ try{
} catch (MissingPropertyException e) { } catch (MissingPropertyException e) {
project.ext.categoryDescriptions = [[:], [:]] // label and descriptions of the features project.ext.categoryDescriptions = [[:], [:]] // label and descriptions of the features
noDescriptions = true noDescriptions = true
} // categoryDescriptions = [["feature": "labelName","feature2": "label"],["feature": "featureDescription","feature2": "feature2Description"]] // label and descriptions of the features // categoryDescriptions = [["feature": "labelName", "feature2": "label"], ["feature": "featureDescription", "feature2": "feature2Description"]] // label and descriptions of the features
}
try { try {
targetRepositories = targetRepositories targetRepositories = targetRepositories
...@@ -116,52 +111,36 @@ try{ ...@@ -116,52 +111,36 @@ try{
try { try {
buildProduct = buildProduct buildProduct = buildProduct
} catch (MissingPropertyException e) { } catch (MissingPropertyException e) {
project.ext.buildProduct = false project.ext.buildProduct = false
} }
// returns the name of a subproject listed in the settings.gradle file
def projects(int i) { def projects(int i) {
return subprojects.name[i] return subprojects.name[i]
} }
// returns the name of a subproject listed in the settings.gradle file
// returns the number of projects listed in the settings.gradle file
def numberOfProjects() { def numberOfProjects() {
return subprojects.name.size() return subprojects.name.size()
} }
// returns the number of projects listed in the settings.gradle file
//
/* -- Return ParentId -- */ // This is the project of the parent Pom
// The Tycho Maven Build is triggered from this project's pom
def parentId() { def parentId() {
return parentID return parentID
} }
/*
* This is the project of the parent Pom
* The Tycho Maven Build is triggered from
* this project's pom
*/
/* -- Return Group Id -- */ // This Group ID will be used in every sub project
def groupId() { def groupId() {
return groupID return groupID
} }
/* // Add certain Jar to Library
* This Group ID will be used in every sub project
*/
def addLibToCP(def project, def libPar) { def addLibToCP(def project, def libPar) {
def filePar = new File(workspacePath + project + "/.classpath") def filePar = new File(workspacePath + project + "/.classpath")
boolean notYetAdded = true boolean notYetAdded = true
filePar.eachLine {line -> filePar.eachLine {line ->
...@@ -169,14 +148,11 @@ def addLibToCP(def project, def libPar){ ...@@ -169,14 +148,11 @@ def addLibToCP(def project, def libPar){
if (line ==~ /${pattern}/) { if (line ==~ /${pattern}/) {
notYetAdded = false notYetAdded = false
} }
} }
if (notYetAdded) { if (notYetAdded) {
File newCP = new File(workspacePath + project + '/.cp') File newCP = new File(workspacePath + project + '/.cp')
filePar.eachLine {line -> filePar.eachLine {line ->
if (line ==~ /.*<\/classpath>.*/) { if (line ==~ /.*<\/classpath>.*/) {
String entry = '\t<classpathentry exported="true" kind="lib" path="' + dependencyFolder + libPar + '"/>' + '\n</classpath>\n' String entry = '\t<classpathentry exported="true" kind="lib" path="' + dependencyFolder + libPar + '"/>' + '\n</classpath>\n'
line = line.replaceAll(/<\/classpath>/, entry) line = line.replaceAll(/<\/classpath>/, entry)
println project + " : " + libPar + " added to classpath" println project + " : " + libPar + " added to classpath"
...@@ -190,21 +166,20 @@ def addLibToCP(def project, def libPar){ ...@@ -190,21 +166,20 @@ def addLibToCP(def project, def libPar){
} else { } else {
println project + " : " + libPar + " classpath entry already present" println project + " : " + libPar + " classpath entry already present"
} }
} }
// Add certain Jar to Library
// deletes whole DependenciesLibrary Folder
def deleteLibFromCP(def project) { def deleteLibFromCP(def project) {
def filePar = new File(workspacePath + project + "/.classpath") def filePar = new File(workspacePath + project + "/.classpath")
boolean deleteCP = false boolean deleteCP = false
def newCP = new File(workspacePath + project + '/cp') def newCP = new File(workspacePath + project + '/cp')
def pattern = ".*${dependencyFolder}[^<].*/>" def pattern = ".*${dependencyFolder}[^<].*/>"
filePar.eachLine {line -> filePar.eachLine {line ->
if (line ==~ /\n(\ |\t)*/) {
if(line ==~ /\n(\ |\t)*/) line = line.replaceAll(/\n(\ |\t)*/, '') // delete empty lines // delete empty lines
line = line.replaceAll(/\n(\ |\t)*/, '')
}
if (line ==~ /${pattern}/) { if (line ==~ /${pattern}/) {
deleteCP = true deleteCP = true
def pattern2 = '(\\ |\\t)*<classpathentry exported="true" kind="lib" path="' + dependencyFolder + "[^<].*"+'"/>(\\ |\\t)*' def pattern2 = '(\\ |\\t)*<classpathentry exported="true" kind="lib" path="' + dependencyFolder + "[^<].*"+'"/>(\\ |\\t)*'
...@@ -223,43 +198,37 @@ def deleteLibFromCP(def project){ ...@@ -223,43 +198,37 @@ def deleteLibFromCP(def project){
println workspacePath + project + '/.classpath' + "!" println workspacePath + project + '/.classpath' + "!"
} }
} }
// deletes whole DependenciesLibrary Folder
// Adds a Library to the current Bundle-ClassPath of the Manifest file
def addRunTimeLib(String libPar, String projectPar) { def addRunTimeLib(String libPar, String projectPar) {
def mf = new File(projectPar + "/META-INF/MANIFEST.MF") def mf = new File(projectPar + "/META-INF/MANIFEST.MF")
def newMf = new File(projectPar + "/MF") def newMf = new File(projectPar + "/MF")
newMf.delete() newMf.delete()
mf.eachLine {line -> mf.eachLine {line ->
if (line ==~ /.*Bundle-ClassPath:.*\.jar.*/) { if (line ==~ /.*Bundle-ClassPath:.*\.jar.*/) {
libsInLine = line.replaceAll(/[\ \t]*Bundle-ClassPath:[\ \t]*/, '') libsInLine = line.replaceAll(/[\ \t]*Bundle-ClassPath:[\ \t]*/, '')
line = line.replaceFirst(/[^\ \t]*\.jar[\ \,]*/, dependencyFolder + libPar + ",\n " + libsInLine) // /[^\ \t]*.\.jar[\ \,]*/ line = line.replaceFirst(/[^\ \t]*\.jar[\ \,]*/, dependencyFolder + libPar + ",\n " + libsInLine) // /[^\ \t]*.\.jar[\ \,]*/
} else { } else {
if (line ==~ /.*Bundle-ClassPath: \.[\ \t]*/) { if (line ==~ /.*Bundle-ClassPath: \.[\ \t]*/) {
line = line + ",\n " + dependencyFolder + libPar line = line + ",\n " + dependencyFolder + libPar
}else{ } else if (line ==~ /.*Bundle-ClassPath: \.\,[\ \t]*/) {
if( line ==~ /.*Bundle-ClassPath: \.\,[\ \t]*/ ){
line = line + "\n " + dependencyFolder + libPar + "," line = line + "\n " + dependencyFolder + libPar + ","
} }
} }
}
newMf << line + "\n" newMf << line + "\n"
} }
mf.delete() mf.delete()
newMf.renameTo(projectPar + "/META-INF/MANIFEST.MF") newMf.renameTo(projectPar + "/META-INF/MANIFEST.MF")
}
// Creates a Bundle-ClassPath Section in the Manifest file
} // Adds a Library to the current Bundle-ClassPath of the Manifest file
def createRunTimeLib(String libPar, String projectPar) { def createRunTimeLib(String libPar, String projectPar) {
def mf = new File(projectPar + "/META-INF/MANIFEST.MF") def mf = new File(projectPar + "/META-INF/MANIFEST.MF")
mf << "Bundle-ClassPath: lib/dependencies/" + libPar mf << "Bundle-ClassPath: lib/dependencies/" + libPar
} // Creates a Bundle-ClassPath Section in the Manifest file }
// checks for a Bundle-ClassPath section in the Manifest file
def boolean checkForRunTimeLibs(String projectPar) { def boolean checkForRunTimeLibs(String projectPar) {
boolean returnBool = false boolean returnBool = false
def mf = new File(projectPar + "/META-INF/MANIFEST.MF") def mf = new File(projectPar + "/META-INF/MANIFEST.MF")
...@@ -269,19 +238,23 @@ def boolean checkForRunTimeLibs(String projectPar){ ...@@ -269,19 +238,23 @@ def boolean checkForRunTimeLibs(String projectPar){
} }
} }
return returnBool return returnBool
} // checks for a Bundle-ClassPath section in the Manifest file }
def boolean checkRunTimeLib(String libPar, String projectPar){ // checks if lib is in RunTimeLibrary present and // checks if lib is already present in Manifest file
def mf = new File(projectPar+"/META-INF/MANIFEST.MF") // changes reference if necessary // if lib is present but is referenced from another folder than dependencyFolder the library from dependencyFolder will be referenced
def boolean checkRunTimeLib(String libPar, String projectPar){
// checks if lib is in RunTimeLibrary present and changes reference if necessary
def mf = new File(projectPar + "/META-INF/MANIFEST.MF")
def newMf = new File(projectPar + "/MF") def newMf = new File(projectPar + "/MF")
newMf.delete() newMf.delete()
boolean returnBool = false boolean returnBool = false
boolean changed = false boolean changed = false
mf.eachLine {line -> mf.eachLine {line ->
if (line ==~ /.*${libPar}.*/) { if (line ==~ /.*${libPar}.*/) {
if( !( line ==~ /.*(\ |\t)*${dependencyFolder}${libPar}(\ |\t)*.*/ ) ){ //if lib is already referenced if (!(line ==~ /.*(\ |\t)*${dependencyFolder}${libPar}(\ |\t)*.*/)){
line = line.replaceFirst( /[^\ \t]*${libPar}/, dependencyFolder+libPar ) // reference lib from dependencyFolder // if lib is already referenced
// reference lib from dependencyFolder
line = line.replaceFirst( /[^\ \t]*${libPar}/, dependencyFolder+libPar )
changed = true changed = true
println line println line
println "yolo ${libPar}\n" println "yolo ${libPar}\n"
...@@ -298,16 +271,13 @@ def boolean checkRunTimeLib(String libPar, String projectPar){ // checks ...@@ -298,16 +271,13 @@ def boolean checkRunTimeLib(String libPar, String projectPar){ // checks
newMf.delete() newMf.delete()
} }
return returnBool return returnBool
}
}// checks if lib is already present in Manifest file ///////////////////////////////////
// if lib is present but is referenced from another folder than dependencyFolder the library from dependencyFolder will be referenced // !!! DEFINING SUB PROJECTS !!! //
///////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////
// -- !!! DEFINING SUB PROJECTS !!! -- //
/////////////////////////////////////////////////////////////////////////////////////////
subprojects { subprojects {
apply plugin: 'base' apply plugin: 'base'
apply plugin: 'java' apply plugin: 'java'
// apply plugin: 'eclipse' // apply plugin: 'eclipse'
...@@ -316,22 +286,18 @@ subprojects { ...@@ -316,22 +286,18 @@ subprojects {
delete 'target','pom.xml' delete 'target','pom.xml'
} }
///// Copy Dependencies into subprojects DependencyFolder ///// // Copy Dependencies into subprojects DependencyFolder
task collectDependencies(type: Copy) { task collectDependencies(type: Copy) {
from configurations.compile from configurations.compile
from configurations.runtime from configurations.runtime
into "${dependencyFolder}" into "${dependencyFolder}"
} }
task setClassPath(dependsOn: 'collectDependencies') { task setClassPath(dependsOn: 'collectDependencies') {
description = "\tAdds all your Dependencies from your local lib folder in each project to it's classpath" description = "\tAdds all your Dependencies from your local lib folder in each project to it's classpath"
doLast { doLast {
if (excludeFromClassPath.every {it != project.name}) { if (excludeFromClassPath.every {it != project.name}) {
def dependencyList = [] def dependencyList = []
try { try {
...@@ -344,19 +310,21 @@ subprojects { ...@@ -344,19 +310,21 @@ subprojects {
if (features.every {it != project.name}) { if (features.every {it != project.name}) {
boolean BundleClassPathPresent = checkForRunTimeLibs(project.name) boolean BundleClassPathPresent = checkForRunTimeLibs(project.name)
for (int icp = 0; icp < dependencyList.size; icp++) { for (int icp = 0; icp < dependencyList.size; icp++) {
addLibToCP(project.name, dependencyList[icp]) //Adds Lib to .classPath file // Adds Lib to .classPath file
addLibToCP(project.name, dependencyList[icp])
if(!BundleClassPathPresent){ // Adds Lib to Manifest File if (!BundleClassPathPresent) {
// Adds Lib to Manifest File
createRunTimeLib(dependencyList[icp], project.name) createRunTimeLib(dependencyList[icp], project.name)
BundleClassPathPresent = true BundleClassPathPresent = true
}else{ } else if (!checkRunTimeLib(dependencyList[icp], project.name)) {
if(!checkRunTimeLib(dependencyList[icp], project.name)){ // if library not present add it to RunTimeLibrary // if library not present add it to RunTimeLibrary
addRunTimeLib(dependencyList[icp], project.name) addRunTimeLib(dependencyList[icp], project.name)
} }
} }
} // could still be usefull for debugging, that's why it's not deleted
/*dependencyList.each {dep -> /*dependencyList.each {dep ->
println project.name+": "+ dep // could still be usefull for debugging, that's why it's not deleted println project.name + ": " + dep
}*/ }*/
} }
def warningReadMe = new File(workspacePath + project.name + "/" + dependencyFolder + "_README.txt") def warningReadMe = new File(workspacePath + project.name + "/" + dependencyFolder + "_README.txt")
...@@ -364,84 +332,75 @@ subprojects { ...@@ -364,84 +332,75 @@ subprojects {
warningReadMe << "Do Not Remove any Jars/Libraries in this Folder!\nThis folder contains all of your dependencies defined in your gradle script.\n" warningReadMe << "Do Not Remove any Jars/Libraries in this Folder!\nThis folder contains all of your dependencies defined in your gradle script.\n"
warningReadMe << "Removing or renaming any of these files will result in an Error in your .classpath file\n" warningReadMe << "Removing or renaming any of these files will result in an Error in your .classpath file\n"
warningReadMe << "If any error concerning missing dependencies should occur please run 'gradle deleteFromClassPath setClassPath' in your workspace folder from your shell." warningReadMe << "If any error concerning missing dependencies should occur please run 'gradle deleteFromClassPath setClassPath' in your workspace folder from your shell."
} catch (Exception e) { } catch (Exception e) {
println project.name + " has no dependencies in '${dependencyFolder}' defined: Classpath will not be changed" println project.name + " has no dependencies in '${dependencyFolder}' defined: Classpath will not be changed"
} }
}// if exclude projectAbfrage }
}
} /// doLast }
} // setClassPath
task deleteFromClassPath(){ task deleteFromClassPath(){
description = "\tDeletes all your Dependencies located in your local lib folder from each project's classpath" description = "\tDeletes all your Dependencies located in your local lib folder from each project's classpath"
doLast { doLast {
try { try {
boolean depsDelete = false boolean depsDelete = false
def depsFolder = new File(workspacePath + project.name + '/' + dependencyFolder) def depsFolder = new File(workspacePath + project.name + '/' + dependencyFolder)
if(depsFolder.exists()) depsDelete = true if (depsFolder.exists()) {
depsDelete = true
}
depsFolder.deleteDir() depsFolder.deleteDir()
if (features.every {it != project.name} && depsDelete) { if (features.every {it != project.name} && depsDelete) {
deleteLibFromCP(project.name) deleteLibFromCP(project.name)
} }
} catch (Exception e) { } catch (Exception e) {
println project.name+" has no dependencies in '${dependencyFolder}' defined: Classpath will not be changed" println project.name+" has no dependencies in '${dependencyFolder}' defined: Classpath will not be changed"
} }
} }
} }
/////---- For a complete classPath Refresh please execute 'gradle deleteFromClassPath setClassPath' ----/////// // For a complete classPath Refresh please execute 'gradle deleteFromClassPath setClassPath'
//////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////
task deploy() { task deploy() {
description = "\tGenerating the Tycho Poms. Please remember to add a '.qualifier' to the version numbers!" description = "\tGenerating the Tycho Poms. Please remember to add a '.qualifier' to the version numbers!"
doLast { doLast {
String versionNumber = 'Version Number Error:\tcheck Manifest for Bundle-Version Number and make sure to add a ".qualifier" to the version numbers!\n' String versionNumber = 'Version Number Error:\tcheck Manifest for Bundle-Version Number and make sure to add a ".qualifier" to the version numbers!\n'
String artifactId = 'Could not find Bundle-SymbolicName in Manifest.file' String artifactId = 'Could not find Bundle-SymbolicName in Manifest.file'
// -- In case of changed Manifest File in Eclipse:
// Version Numbers of the projects are collected via
// regular expressions in the Manifest.MF File.
// versionnumber of the projects are equal to their
// Bundle-Version Number
/* -- In case of changed Manifest File in Eclipse: // Generating Poms for sub projects except features
* if (features.every {it != project.name}) {
* Version Numbers of the projects are collected via
* regular expressions in the Manifest.MF File.
* versionnumber of the projects are equal to their
* Bundle-Version Number
*/
if(features.every{ it != project.name }){ // Generating Poms for sub projects except features
def content = new File(workspacePath + "${project.name}/META-INF/MANIFEST.MF").getText("UTF-8") def content = new File(workspacePath + "${project.name}/META-INF/MANIFEST.MF").getText("UTF-8")
def printFileLine = { def printFileLine = {
if (it ==~ /Bundle-Version.+qualifier/) { if (it ==~ /Bundle-Version.+qualifier/) {
versionNumber = it.substring(16) // possibile error: cuts off first 16 chars versionNumber = it.substring(16) // possibile error: cuts off first 16 chars
/* Version Number is taken from Bundle-Version in Manifest.MF // Version Number is taken from Bundle-Version in Manifest.MF
* If there is no Bundle-Version or the versionnumber needs to // If there is no Bundle-Version or the versionnumber needs to
* be taken from a different key word, please change the // be taken from a different key word, please change the
* regular expression and the substring above // regular expression and the substring above
*/
versionNumber = versionNumber.replace(".qualifier", "-SNAPSHOT") versionNumber = versionNumber.replace(".qualifier", "-SNAPSHOT")
} }
// Artifact ID is taken from Bundle-SymbolicName minus the 16 chars ';singleton:=true'
if (it ==~ /Bundle-SymbolicName:.+/) { if (it ==~ /Bundle-SymbolicName:.+/) {
artifactId = it artifactId = it
artifactId = artifactId.replace("Bundle-SymbolicName:", ''); artifactId = artifactId.replace("Bundle-SymbolicName:", '')
artifactId = artifactId.replace(";", '') artifactId = artifactId.replace(";", '')
artifactId = artifactId.replace(" ", '') artifactId = artifactId.replace(" ", '')
artifactId = artifactId.replace("singleton:=true", '') artifactId = artifactId.replace("singleton:=true", '')
} }
/* Artifact ID is taken from Bundle-SymbolicName minus the
* 16 chars ';singleton:=true'
*/
} }
content.eachLine(printFileLine) content.eachLine(printFileLine)
...@@ -452,25 +411,16 @@ doLast { ...@@ -452,25 +411,16 @@ doLast {
def f = new File(workspacePath + artifactId + '/pom.xml') def f = new File(workspacePath + artifactId + '/pom.xml')
f.delete() f.delete()
// ---- Test Cases ------ //
if (project.name ==~ /.*\.[tT]ests*/) { if (project.name ==~ /.*\.[tT]ests*/) {
// Test Cases
f << start() + elder() + testArtifact(artifactId, versionNumber) + end() f << start() + elder() + testArtifact(artifactId, versionNumber) + end()
} else { } else {
// Normal Plugin
// ---- Normal Plugin ----- //
f << start() + elder() + artifact(artifactId, versionNumber) + end() f << start() + elder() + artifact(artifactId, versionNumber) + end()
/* // old pom.xml files are deleted and replaced by new auto generated Tycho pom.xml files
* old pom.xml files are deleted and replaced by new auto generated Tycho pom.xml files
*/
} }
}else{ // end of { if subprojects aren't a feature } Block } else if (features.any {it == project.name}) {
// Features
// -- Features -- //
if(features.any{ it == project.name } ){
def parsedXml = new XmlParser().parse(workspacePath + "${project.name}/feature.xml") def parsedXml = new XmlParser().parse(workspacePath + "${project.name}/feature.xml")
artifactId = parsedXml.attribute("id") artifactId = parsedXml.attribute("id")
...@@ -485,18 +435,16 @@ doLast { ...@@ -485,18 +435,16 @@ doLast {
f << feature(artifactId, versionNumber) f << feature(artifactId, versionNumber)
} }
} }
} //doLast }
}//deploy }
}// defining subprojects
clean { clean {
dependsOn += subprojects.deleteArtifacts dependsOn += subprojects.deleteArtifacts
} }
// define Parent
task createParent() { task createParent() {
// --------- define Parent --------- //
doLast { doLast {
new File(workspacePath + "${parentID}").mkdir() new File(workspacePath + "${parentID}").mkdir()
String versionNumber = '1.0.0.qualifier' String versionNumber = '1.0.0.qualifier'
...@@ -511,22 +459,18 @@ doLast{ ...@@ -511,22 +459,18 @@ doLast{
f << endRepos() f << endRepos()
f << moduleStart() f << moduleStart()
for (int i = 0; i < numberOfProjects(); i++) { for (int i = 0; i < numberOfProjects(); i++) {
if (excludeFromTychoBuild.every {it != projects(i)}) { if (excludeFromTychoBuild.every {it != projects(i)}) {
f << module(projects(i)) f << module(projects(i))
} }
} }
f << module(repositoryName) f << module(repositoryName)
f << endParent() f << endParent()
} }
} }
// define Repository
task createRepository() { task createRepository() {
doLast{ doLast{
// ------------ define Repository --------- //
new File(workspacePath + "${repositoryName}").mkdir() new File(workspacePath + "${repositoryName}").mkdir()
String versionNumber = '1.0.0.qualifier' String versionNumber = '1.0.0.qualifier'
...@@ -537,7 +481,6 @@ doLast{ ...@@ -537,7 +481,6 @@ doLast{
f.delete() f.delete()
f << categoryHead() f << categoryHead()
for (int i = 0; i < features.size(); i++) { for (int i = 0; i < features.size(); i++) {
def parsedXml = new XmlParser().parse("${workspacePath}${features[i]}/feature.xml") def parsedXml = new XmlParser().parse("${workspacePath}${features[i]}/feature.xml")
featureVersionNumber = parsedXml.attribute("version") featureVersionNumber = parsedXml.attribute("version")
...@@ -548,24 +491,23 @@ doLast{ ...@@ -548,24 +491,23 @@ doLast{
categoryDescriptions[1].put(features[i], parsedXml.description.text()) categoryDescriptions[1].put(features[i], parsedXml.description.text())
} }
f << categoryFeatures(featureArtifactId.replace(workspacePath, ''), featureVersionNumber) f << categoryFeatures(featureArtifactId.replace(workspacePath, ''), featureVersionNumber)
}// for }
for (int i = 0; i < features.size(); i++) { for (int i = 0; i < features.size(); i++) {
if (noDescriptions) { if (noDescriptions) {
f << categoryDescription(features[i], categoryDescriptions[0][features[i]] ,categoryDescriptions[1][features[i]] )
// featureName, label, description // featureName, label, description
f << categoryDescription(features[i], categoryDescriptions[0][features[i]],categoryDescriptions[1][features[i]])
} else { } else {
f << categoryDescription(features[i], categoryDescriptions[features[i]][0],categoryDescriptions[features[i]][1]) f << categoryDescription(features[i], categoryDescriptions[features[i]][0],categoryDescriptions[features[i]][1])
} }
}//for }
f << categoryEnd() f << categoryEnd()
def pom = new File(workspacePath + artifactId + '/pom.xml') def pom = new File(workspacePath + artifactId + '/pom.xml')
pom.delete() pom.delete()
pom << reposi() pom << reposi()
}// end of repository definition }
} }
task createPoms(dependsOn: [createParent, createRepository, subprojects.deploy]) task createPoms(dependsOn: [createParent, createRepository, subprojects.deploy])
...@@ -577,7 +519,6 @@ task install(dependsOn: [createPoms] , type:Exec) { ...@@ -577,7 +519,6 @@ task install(dependsOn: [createPoms] , type:Exec) {
} }
task completeInstall(dependsOn: [subprojects.collectDependencies, createPoms], type:Exec){ task completeInstall(dependsOn: [subprojects.collectDependencies, createPoms], type:Exec){
description = "\tCopies dependencies into dependencyFolder of each subproject and executes a 'mvn install' of the parent pom.xml and auto-generates Tycho Poms" description = "\tCopies dependencies into dependencyFolder of each subproject and executes a 'mvn install' of the parent pom.xml and auto-generates Tycho Poms"
commandLine 'mvn', 'install', '-f', workspacePath + parentID + '/pom.xml' commandLine 'mvn', 'install', '-f', workspacePath + parentID + '/pom.xml'
} }
...@@ -640,7 +581,8 @@ task tycho(dependsOn: [createPoms] , type:Exec) { ...@@ -640,7 +581,8 @@ task tycho(dependsOn: [createPoms] , type:Exec) {
} }
def start() { """<?xml version="1.0" encoding="UTF-8"?> def start() {"""\
<?xml version="1.0" encoding="UTF-8"?>
<project <project
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
...@@ -663,10 +605,8 @@ task tycho(dependsOn: [createPoms] , type:Exec) { ...@@ -663,10 +605,8 @@ task tycho(dependsOn: [createPoms] , type:Exec) {
// -- defining Parent Pom -- // // -- defining Parent Pom -- //
def parentPom(artifactId) {"""\
<?xml version="1.0" encoding="UTF-8"?>
def parentPom(artifactId) { """<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
...@@ -689,26 +629,18 @@ def parentPom(artifactId) { """<?xml version="1.0" encoding="UTF-8"?> ...@@ -689,26 +629,18 @@ def parentPom(artifactId) { """<?xml version="1.0" encoding="UTF-8"?>
</pluginRepositories> </pluginRepositories>
<repositories> <repositories>
<!-- configure p2 repository to resolve against --> <!-- configure p2 repository to resolve against -->
"""} """}
def repos(String targetRepo, int i) {""" def repos(String targetRepo, int i) {"""
<repository> <repository>
<id>targetRepository${i}</id> <id>targetRepository${i}</id>
<layout>p2</layout> <layout>p2</layout>
<url>${targetRepo}</url> <url>${targetRepo}</url>
</repository> </repository>
"""} """}
def endRepos() {""" def endRepos() {"""
</repositories> </repositories>
<build> <build>
<plugins> <plugins>
<plugin> <plugin>
...@@ -729,12 +661,11 @@ def moduleStart(){""" ...@@ -729,12 +661,11 @@ def moduleStart(){"""
// for (int i = 0; i < numberOfProjects(); i++) // for (int i = 0; i < numberOfProjects(); i++)
def module(String project){""" <module>../${project}</module> def module(String project) {"""\
<module>../${project}</module>
"""} """}
def endParent() {"""\
def endParent() {"""
</modules> </modules>
</project> </project>
"""} """}
...@@ -742,7 +673,7 @@ def endParent() {""" ...@@ -742,7 +673,7 @@ def endParent() {"""
// end of defining parent pom.xml // end of defining parent pom.xml
// repository Pom // repository Pom
def reposi() { """ def reposi() {"""\
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project <project
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
...@@ -754,7 +685,6 @@ def reposi() { """ ...@@ -754,7 +685,6 @@ def reposi() { """
<relativePath>../${parentID}/pom.xml</relativePath> <relativePath>../${parentID}/pom.xml</relativePath>
</parent> </parent>
<groupId>${groupID}</groupId> <groupId>${groupID}</groupId>
<artifactId>${repositoryName}</artifactId> <artifactId>${repositoryName}</artifactId>
<version>1.0.0.qualifier</version> <version>1.0.0.qualifier</version>
...@@ -765,7 +695,6 @@ def reposi() { """ ...@@ -765,7 +695,6 @@ def reposi() { """
"""} """}
def String reposiBuildStep(){ def String reposiBuildStep(){
if (buildProduct != false) { if (buildProduct != false) {
return """ return """
<build> <build>
...@@ -790,7 +719,6 @@ def String reposiBuildStep(){ ...@@ -790,7 +719,6 @@ def String reposiBuildStep(){
<goal>archive-products</goal> <goal>archive-products</goal>
</goals> </goals>
</execution> </execution>
</executions> </executions>
</plugin> </plugin>
</plugins> </plugins>
...@@ -803,9 +731,9 @@ def String reposiBuildStep(){ ...@@ -803,9 +731,9 @@ def String reposiBuildStep(){
// creates a category in // creates a category in
def categoryHead() { """<?xml version="1.0" encoding="UTF-8"?> def categoryHead() {"""\
<?xml version="1.0" encoding="UTF-8"?>
<site> <site>
"""} """}
def categoryFeatures(artifactId, versionNumber) {""" def categoryFeatures(artifactId, versionNumber) {"""
...@@ -828,7 +756,7 @@ def categoryEnd(){""" ...@@ -828,7 +756,7 @@ def categoryEnd(){"""
// end of category definition // end of category definition
// feature pom // feature pom
def feature(artifactId, versionNumber) { """ def feature(artifactId, versionNumber) {"""\
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project <project
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
...@@ -850,14 +778,12 @@ def feature(artifactId, versionNumber) { """ ...@@ -850,14 +778,12 @@ def feature(artifactId, versionNumber) { """
// -------- In case you want to generate the product definition ------ // // -------- In case you want to generate the product definition ------ //
/* /*
def productXML(){ def productXML(){
""" """\
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<?pde version="3.5"?> <?pde version="3.5"?>
<product name="${groupID}.product" uid="${groupID}" id="${groupID}.product" application="${product}" version="1.0.0.qualifier" useFeatures="true" includeLaunchers="true"> <product name="${groupID}.product" uid="${groupID}" id="${groupID}.product" application="${product}" version="1.0.0.qualifier" useFeatures="true" includeLaunchers="true">
<configIni use="default"> <configIni use="default">
</configIni> </configIni>
...@@ -868,7 +794,6 @@ def productXML(){ ...@@ -868,7 +794,6 @@ def productXML(){
</launcherArgs> </launcherArgs>
<plugins> <plugins>
</plugins> </plugins>
<features> <features>
""" + listProductFeature() + """ """ + listProductFeature() + """
...@@ -879,19 +804,15 @@ def productXML(){ ...@@ -879,19 +804,15 @@ def productXML(){
<plugin id="org.eclipse.equinox.common" autoStart="true" startLevel="2" /> <plugin id="org.eclipse.equinox.common" autoStart="true" startLevel="2" />
<plugin id="org.eclipse.osgi" autoStart="true" startLevel="-1" /> <plugin id="org.eclipse.osgi" autoStart="true" startLevel="-1" />
</configurations> </configurations>
</product> </product>
""" """
/* /*
""" """\
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<?pde version="3.5"?> <?pde version="3.5"?>
<product name="de.prob.product" uid="de.prob" id="de.prob.standalone.product" application="de.prob.standalone.application" version="1.0.0.qualifier" useFeatures="true" includeLaunchers="true"> <product name="de.prob.product" uid="de.prob" id="de.prob.standalone.product" application="de.prob.standalone.application" version="1.0.0.qualifier" useFeatures="true" includeLaunchers="true">
<configIni use="default"> <configIni use="default">
</configIni> </configIni>
...@@ -901,18 +822,11 @@ def productXML(){ ...@@ -901,18 +822,11 @@ def productXML(){
<plugins> <plugins>
</plugins> </plugins>
</product> </product>
"""*/ """*/
/* /*
<feature id="birkhoff.feature" version="1.0.0.qualifier"/> <feature id="birkhoff.feature" version="1.0.0.qualifier"/>
*/ */
/* /*
} }
...@@ -920,12 +834,9 @@ def productXML(){ ...@@ -920,12 +834,9 @@ def productXML(){
def String listProductFeatures(){ def String listProductFeatures(){
String returnString = "" String returnString = ""
for (int i = 0; i < features.size(); i++) { for (int i = 0; i < features.size(); i++) {
returnString += '\n\t\t<feature id="${features[i]}" version="1.0.0.qualifier"/>' returnString += '\n\t\t<feature id="${features[i]}" version="1.0.0.qualifier"/>'
} }
return returnString return returnString
} }
*/ */
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment