Skip to content
Snippets Groups Projects
Commit aaa4e6cb authored by birkhoff's avatar birkhoff
Browse files

flushDependencies, and deleteFromClassPath tasks added, but still needs to be tested properly

parent 0624da31
No related branches found
No related tags found
No related merge requests found
...@@ -128,8 +128,9 @@ def groupId(){ ...@@ -128,8 +128,9 @@ def groupId(){
* This Group ID will be used in every sub project * This Group ID will be used in every sub project
*/ */
def addLibToCP(def project, File filePar, def libPar){ def addLibToCP(def project, def libPar){
def filePar = new File(workspacePath+project+"/.classpath")
boolean notYetAdded = true boolean notYetAdded = true
filePar.eachLine{ line -> filePar.eachLine{ line ->
def pattern = ".*${dependencyFolder}${libPar}.*" def pattern = ".*${dependencyFolder}${libPar}.*"
...@@ -139,26 +140,61 @@ def addLibToCP(def project, File filePar, def libPar){ ...@@ -139,26 +140,61 @@ def addLibToCP(def project, File filePar, def libPar){
} }
if(notYetAdded){ if(notYetAdded){
File newCP = new File(project+'/.cp') File newCP = new File(workspacePath+project+'/.cp')
filePar.eachLine{ line -> filePar.eachLine{ line ->
if(line ==~ /.*<\/classpath>.*/){ if(line ==~ /.*<\/classpath>.*/){
String entry = '<classpathentry exported="true" kind="lib" path="lib/dependencies/'+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 line println project + " : "+ libPar +" added to classpath"
newCP << line+"\n" newCP << line
}else{ }else{
newCP << line+"\n" newCP << line+"\n"
} }
} }
filePar.delete() filePar.delete()
newCP.renameTo(project+'/.classpath') newCP.renameTo(workspacePath+project+'/.classpath')
}else{ }else{
println project + " : "+ libPar +" classpath entry already present" println project + " : "+ libPar +" classpath entry already present"
} }
} }
def deleteLibFromCP(def project){
def filePar = new File(workspacePath+project+"/.classpath")
boolean deleteCP = false
def newCP = new File(workspacePath+project+'/cp')
def pattern = ".*${dependencyFolder}[^<].*/>"
filePar.eachLine{ line ->
if(line ==~ /\n(\ |\t)*/) line = line.replaceAll(/\n(\ |\t)*/, '') // delete empty lines
if(line ==~ /${pattern}/){
deleteCP = true
def pattern2 = '(\\ |\\t)*<classpathentry exported="true" kind="lib" path="'+dependencyFolder+"[^<].*"+'"/>(\\ |\\t)*'
line = line.replaceAll(/${pattern2}/, '')
newCP << line
}else{
newCP << line+"\n"
}
}
if(!deleteCP){
println project + " : no dependencies from "+ dependencyFolder+" found in classpath file! "
newCP.delete()
}else{
filePar.delete()
newCP.renameTo(workspacePath+project+'/.classpath')
println workspacePath+project+'/.classpath' +"!"
}
}
///////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////
// -- !!! DEFINING SUB PROJECTS !!! -- // // -- !!! DEFINING SUB PROJECTS !!! -- //
///////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////
...@@ -167,7 +203,7 @@ subprojects { ...@@ -167,7 +203,7 @@ subprojects {
apply plugin: 'base' apply plugin: 'base'
apply plugin: 'java' apply plugin: 'java'
apply plugin: 'eclipse' // apply plugin: 'eclipse'
task deleteArtifacts(type: Delete) { task deleteArtifacts(type: Delete) {
delete 'target','pom.xml' delete 'target','pom.xml'
...@@ -183,22 +219,22 @@ subprojects { ...@@ -183,22 +219,22 @@ subprojects {
} }
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"
def dependencyList = [] def dependencyList = []
try{ try{
def dir = new File(project.name+"/"+dependencyFolder).eachFile() { file-> def dir = new File(workspacePath+project.name+"/"+dependencyFolder).eachFile() { file->
dependencyList << file.getName() dependencyList << file.getName()
} }
if(features.every{ it != project.name }){ if(features.every{ it != project.name }){
def cpFile = new File(project.name+"/.classpath")
for(int icp = 0; icp < dependencyList.size; icp++){ for(int icp = 0; icp < dependencyList.size; icp++){
addLibToCP(project.name, cpFile, dependencyList[icp]) addLibToCP(project.name, dependencyList[icp])
} }
/*dependencyList.each{ dep-> /*dependencyList.each{ dep->
println project.name+": "+ dep println project.name+": "+ dep // could still be usefull for debugging, that's why it's not deleted
}*/ }*/
} }
...@@ -208,12 +244,33 @@ subprojects { ...@@ -208,12 +244,33 @@ subprojects {
}// setClassPath }// setClassPath
eclipse.classpath.file {
whenMerged { classpath -> task deleteFromClassPath()<<{ //AKTUELLE BAUSTELLE !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!! !! !! !! !!!!!!!!!!!!!!!!!!######!!!!#!!!
classpath.entries.findAll { entry -> entry.kind == 'lib' }*.exported = true
description = "\tDeletes all your Dependencies located in your local lib folder from each project's classpath"
try{
boolean depsDelete = false
def depsFolder = new File(workspacePath+project.name+'/'+dependencyFolder)
if(depsFolder.exists()) depsDelete = true
depsFolder.deleteDir()
if(features.every{ it != project.name } && depsDelete){
deleteLibFromCP(project.name)
} }
}catch(Exception e){
println project.name+" has no dependencies in '${dependencyFolder}' defined: Classpath will not be changed"
} }
}
task flushDependencies( dependsOn: ['deleteFromClassPath'])<<{
tasks.setClassPath.execute()
}
//////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////
task deploy() <<{ task deploy() <<{
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment