From 2bf012c73133a9455649d87dd982be654adb7d5b Mon Sep 17 00:00:00 2001
From: birkhoff <mike.birkhoff@gmx.de>
Date: Mon, 2 Apr 2012 17:15:32 +0200
Subject: [PATCH] enhanced Build Script

---
 build.gradle                    | 41 +++++++++++++++++++++++++++++----
 de.prob.parent/build.gradle     |  6 ++---
 de.prob.repository/build.gradle | 14 +++++------
 de.prob2.feature/build.gradle   |  8 +++----
 4 files changed, 50 insertions(+), 19 deletions(-)

diff --git a/build.gradle b/build.gradle
index 8618cc88..43dbf8eb 100644
--- a/build.gradle
+++ b/build.gradle
@@ -1,10 +1,17 @@
 apply plugin: 'base'
 
+/*	--!		 Please Define the Parent ID and and the Group Id! 		--!	*/
+
+groupID		=	"de.prob"
+parentID	= 	"de.prob.parent"
+
+
+
 //---     Defining Tycho POM parts			--//
 
 
     def artifact(artifactId,versionNumber) { """
-		<groupId>de.prob</groupId>
+		<groupId>${groupId()}</groupId>
 		<artifactId>${artifactId}</artifactId>
 		<version>${versionNumber}</version>
 		<packaging>eclipse-plugin</packaging>
@@ -21,10 +28,10 @@ apply plugin: 'base'
 	
 	def elder() {"""
 		<parent>
-			<groupId>de.prob</groupId>
-			<artifactId>de.prob.parent</artifactId>
+			<groupId>${groupId()}</groupId>
+			<artifactId>${parentId()}</artifactId>
 			<version>1.0.0.qualifier</version>
-			<relativePath>../de.prob.parent/pom.xml</relativePath>
+			<relativePath>../${parentId()}/pom.xml</relativePath>
 		</parent>
 	"""}
 
@@ -63,10 +70,14 @@ def download(address,target) {
 def projects(int i){
 	return  subprojects.name[i]
 }
+//	returns the name of a subproject listed in the settings.gradle file
+
 
 def numberOfProjects(){
 	return subprojects.name.size()
 }
+//	returns the number of projects listed in the settings.gradle file
+
 
 task downloadCli << {
 		dir = 'de.prob.core/prob/'
@@ -90,9 +101,29 @@ task downloadCli << {
 	
 }
 
+
+/* 		--		Define ParentId			--		*/
+
 def parentId(){
-	return "de.prob.parent"
+	return parentID
 }
+/*
+*	This is the project of the parent Pom
+*	The Tycho Maven Build is triggered from
+*	this project's pom
+*/
+
+
+
+/*	--			Define Group Id			--		*/
+def groupId(){
+	return groupID
+}
+
+/*
+*	This Group ID will be used in every sub project
+*/
+
 subprojects {
 	
 	apply plugin: 'base'
diff --git a/de.prob.parent/build.gradle b/de.prob.parent/build.gradle
index 20ea0686..6b332ad7 100644
--- a/de.prob.parent/build.gradle
+++ b/de.prob.parent/build.gradle
@@ -3,7 +3,7 @@
 <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>
 	
-	<groupId>de.prob</groupId>
+	<groupId>${groupId()}</groupId>
   	<artifactId>${artifactId}</artifactId>
   	<version>1.0.0.qualifier</version>
   
@@ -65,7 +65,7 @@ def endParent() {"""
 deploy <<{
 
 	versionNumber = '1.0.0.qualifier'
-	artifactId = 'de.prob.parent'
+	artifactId = parentId()
 	
 		println projects(2) + numberOfProjects() + projects(1)
 
@@ -85,7 +85,7 @@ deploy <<{
 
 /*
 
-!!!!!	In case of problems the old parernt Pom Defenintion:				!!!!
+!!!!!	In case of problems: This is the old parernt Pom Defenintion:				!!!!
 	
 	def parentPom() { """
 <?xml version="1.0" encoding="UTF-8"?>
diff --git a/de.prob.repository/build.gradle b/de.prob.repository/build.gradle
index 7ae8245e..ab746c32 100644
--- a/de.prob.repository/build.gradle
+++ b/de.prob.repository/build.gradle
@@ -1,18 +1,18 @@
-def reposi() { """
+def reposi(artifact) { """
 <?xml version="1.0" encoding="UTF-8"?>
   <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">
     <modelVersion>4.0.0</modelVersion>
     <parent>
-      <groupId>de.prob</groupId>
-      <artifactId>de.prob.parent</artifactId>
+      <groupId>${groupId()}</groupId>
+      <artifactId>${parentId()}</artifactId>
       <version>1.0.0.qualifier</version>
-      <relativePath>../de.prob.parent/pom.xml</relativePath>
+      <relativePath>../${parentId()}/pom.xml</relativePath>
     </parent>
 
     
-    <groupId>de.prob</groupId>
-    <artifactId>de.prob.repository</artifactId>
+    <groupId>${groupId()}</groupId>
+    <artifactId>${artifact}</artifactId>
     <version>1.0.0.qualifier</version>
     <packaging>eclipse-repository</packaging>
   </project>
@@ -27,6 +27,6 @@ deploy <<{
 
 	def f = new File(artifactId+'/pom.xml') 
 	f.delete()
-	f << reposi()
+	f << reposi(artifactId)
 	
 }
\ No newline at end of file
diff --git a/de.prob2.feature/build.gradle b/de.prob2.feature/build.gradle
index 327bb749..695a03f7 100644
--- a/de.prob2.feature/build.gradle
+++ b/de.prob2.feature/build.gradle
@@ -4,12 +4,12 @@ def feature(artifactId, versionNumber) { """
 		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>
 		<parent>
-			<groupId>de.prob</groupId>
-			<artifactId>de.prob.parent</artifactId>
+			<groupId>${groupId()}</groupId>
+			<artifactId>${parentId()}</artifactId>
 			<version>1.0.0.qualifier</version>
-			<relativePath>../de.prob.parent/pom.xml</relativePath>
+			<relativePath>../${parentId()}/pom.xml</relativePath>
 		</parent>
-		<groupId>de.prob</groupId>
+		<groupId>${groupId()}</groupId>
 		<artifactId>${artifactId}</artifactId>
 		<version>${versionNumber}</version>
 		<packaging>eclipse-feature</packaging>
-- 
GitLab