Skip to content

Commit

Permalink
#58: added bom task
Browse files Browse the repository at this point in the history
  • Loading branch information
ypujante committed May 27, 2013
1 parent 7e81933 commit d4eef3b
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 3 deletions.
2 changes: 1 addition & 1 deletion console/org.linkedin.glu.console-webapp/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ console.commandsService.commandExecutionIOStorage.filesystem.rootDir="${buildDir
def warFile = new File("${buildDir}/distributions/${project.name}-${project.version}.war")

task war(dependsOn: lib) << {
ant.exec(dir: '.', executable: grailsExe) {
ant.exec(dir: '.', executable: grailsExe, failonerror: true) {
arg(line: "-Dgrails.project.war.file=${warFile} -Dbuild.version=${project.version} war")
}
}
Expand Down
50 changes: 48 additions & 2 deletions packaging/org.linkedin.glu.packaging-all/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import java.text.SimpleDateFormat

/*
* Copyright (c) 2010-2010 LinkedIn, Inc
* Portions Copyright (c) 2011-2013 Yan Pujante
Expand Down Expand Up @@ -75,3 +73,51 @@ project.'package-assemble'.doFirst {
ant.untar(src: zkp, dest: basePackage, compression: 'gzip')
}
}

task bom << {
File basePackage = project.convention.plugins.cmdline.assemblePackageFile
File lib = new File(basePackage, "lib")
delete lib
lib.mkdirs()

def allJars = fileTree(dir: basePackage)

allJars.include "**/*.jar"

def jarFiles = [:]
def bomFiles = [:]

allJars.each { File jar ->

File bomFile = new File(jar.parentFile, "bom.txt")
def bomFileContent = bomFiles[bomFile]
if(!bomFileContent)
{
bomFileContent = [__base__: bomFile.parentFile.toPath().relativize(lib.toPath())]
bomFiles[bomFile] = bomFileContent

}

def sha1 = org.gradle.util.hash.HashUtil.sha1(jar).asHexString()

def previousSha1 = jarFiles[jar.name]
if(!previousSha1)
{
copy {
from jar
into lib
}
jarFiles[jar.name] = sha1
}
else
if(sha1 != previousSha1)
throw new Exception("mismatch sha1 [${sha1} != ${previousSha1}] for ${jar}")

bomFileContent[jar.name] = sha1
}

bomFiles.each { File bomFile, def bomFileContent ->
bomFile.text = bomFileContent.collect { k, v -> "${k}=${v}"}.join("\n")
logger.info "created bom file ${bomFile}"
}
}

0 comments on commit d4eef3b

Please sign in to comment.