mirror of
https://github.com/ethauvin/kobalt.git
synced 2025-04-26 16:28:12 -07:00
Clarify and document.
This commit is contained in:
parent
66b39aa213
commit
c2c4d8e254
1 changed files with 32 additions and 25 deletions
|
@ -62,21 +62,28 @@ class PackagingPlugin @Inject constructor(val dependencyManager : DependencyMana
|
||||||
runTask = { taskInstall(project) })
|
runTask = { taskInstall(project) })
|
||||||
}
|
}
|
||||||
|
|
||||||
val zipToFiles = hashMapOf<String, List<IncludedFile>>()
|
|
||||||
|
|
||||||
override fun assemble(project: Project, context: KobaltContext) : IncrementalTaskInfo {
|
override fun assemble(project: Project, context: KobaltContext) : IncrementalTaskInfo {
|
||||||
val allConfigs = packages.filter { it.project.name == project.name }
|
val allConfigs = packages.filter { it.project.name == project.name }
|
||||||
|
val zipToFiles = hashMapOf<String, List<IncludedFile>>()
|
||||||
|
|
||||||
val benchmark = benchmarkMillis {
|
val benchmark = benchmarkMillis {
|
||||||
if (true) {
|
if (true) {
|
||||||
|
//
|
||||||
|
// This loop prepares the data so we can calculate input and output checksums for the
|
||||||
|
// assemble task:
|
||||||
|
// - Input: Calculate the list of all the included files for every archive (jar/war/zip) and
|
||||||
|
// store them in the `zipToFiles` map.
|
||||||
|
// - Output: Calculate all the output archive files into `allFiles`
|
||||||
|
//
|
||||||
|
// `zipToFiles` is used again so we can pass that list of included files to the actual execution
|
||||||
|
// of the task, so we don't have to look for them a second time
|
||||||
|
//
|
||||||
val allIncludedFiles = arrayListOf<IncludedFile>()
|
val allIncludedFiles = arrayListOf<IncludedFile>()
|
||||||
val outputArchives = arrayListOf<File>()
|
val outputArchives = arrayListOf<File>()
|
||||||
allConfigs.forEach { packageConfig ->
|
allConfigs.forEach { packageConfig ->
|
||||||
listOf(packageConfig.jars, packageConfig.wars, packageConfig.zips).forEach { archives ->
|
listOf(packageConfig.jars, packageConfig.wars, packageConfig.zips).forEach { archives ->
|
||||||
archives.forEach {
|
archives.forEach {
|
||||||
val files = jarGenerator.findIncludedFiles(packageConfig.project, context, it)
|
val files = jarGenerator.findIncludedFiles(packageConfig.project, context, it)
|
||||||
val suffixIndex = it.name.lastIndexOf(".")
|
|
||||||
val suffix = it.name.substring(suffixIndex)
|
|
||||||
val outputFile = jarGenerator.fullArchiveName(project, context, it.name)
|
val outputFile = jarGenerator.fullArchiveName(project, context, it.name)
|
||||||
outputArchives.add(outputFile)
|
outputArchives.add(outputFile)
|
||||||
allIncludedFiles.addAll(files)
|
allIncludedFiles.addAll(files)
|
||||||
|
@ -84,7 +91,7 @@ class PackagingPlugin @Inject constructor(val dependencyManager : DependencyMana
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
val allFiles = allIncludedFiles.fold(arrayListOf<File>()) { files, includedFile: IncludedFile ->
|
val inputFiles = allIncludedFiles.fold(arrayListOf<File>()) { files, includedFile: IncludedFile ->
|
||||||
val foundFiles = includedFile.allFromFiles(project.directory)
|
val foundFiles = includedFile.allFromFiles(project.directory)
|
||||||
val absFiles = foundFiles.map {
|
val absFiles = foundFiles.map {
|
||||||
File(KFiles.joinDir(project.directory, includedFile.from, it.path))
|
File(KFiles.joinDir(project.directory, includedFile.from, it.path))
|
||||||
|
@ -93,7 +100,7 @@ class PackagingPlugin @Inject constructor(val dependencyManager : DependencyMana
|
||||||
files
|
files
|
||||||
}
|
}
|
||||||
|
|
||||||
val inMd5 = Md5.toMd5Directories(allFiles)
|
val inMd5 = Md5.toMd5Directories(inputFiles)
|
||||||
val outMd5 = Md5.toMd5Directories(outputArchives)
|
val outMd5 = Md5.toMd5Directories(outputArchives)
|
||||||
Pair(inMd5, outMd5)
|
Pair(inMd5, outMd5)
|
||||||
} else {
|
} else {
|
||||||
|
@ -150,7 +157,7 @@ class PackagingPlugin @Inject constructor(val dependencyManager : DependencyMana
|
||||||
context.pluginInfo.incrementalAssemblyContributors.forEach {
|
context.pluginInfo.incrementalAssemblyContributors.forEach {
|
||||||
val taskInfo = it.assemble(project, context)
|
val taskInfo = it.assemble(project, context)
|
||||||
val closure = incrementalManagerFactory.create().toIncrementalTaskClosure(TASK_ASSEMBLE, {
|
val closure = incrementalManagerFactory.create().toIncrementalTaskClosure(TASK_ASSEMBLE, {
|
||||||
p: Project -> taskInfo }, context.variant)
|
_: Project -> taskInfo }, context.variant)
|
||||||
val thisResult = closure.invoke(project)
|
val thisResult = closure.invoke(project)
|
||||||
if (! thisResult.success) {
|
if (! thisResult.success) {
|
||||||
// Abort at the first failure
|
// Abort at the first failure
|
||||||
|
@ -174,24 +181,24 @@ class PackagingPlugin @Inject constructor(val dependencyManager : DependencyMana
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Task(name = "generateOsgiManifest", alwaysRunAfter = arrayOf(TASK_ASSEMBLE))
|
// @Task(name = "generateOsgiManifest", alwaysRunAfter = arrayOf(TASK_ASSEMBLE))
|
||||||
fun generateManifest(project: Project): TaskResult {
|
// fun generateManifest(project: Project): TaskResult {
|
||||||
val analyzer = Analyzer().apply {
|
// val analyzer = Analyzer().apply {
|
||||||
jar = aQute.bnd.osgi.Jar(project.projectProperties.get(Archives.JAR_NAME) as String)
|
// jar = aQute.bnd.osgi.Jar(project.projectProperties.get(Archives.JAR_NAME) as String)
|
||||||
val dependencies = project.compileDependencies + project.compileRuntimeDependencies
|
// val dependencies = project.compileDependencies + project.compileRuntimeDependencies
|
||||||
dependencyManager.calculateDependencies(project, context, passedDependencies = dependencies).forEach {
|
// dependencyManager.calculateDependencies(project, context, passedDependencies = dependencies).forEach {
|
||||||
addClasspath(it.jarFile.get())
|
// addClasspath(it.jarFile.get())
|
||||||
}
|
// }
|
||||||
setProperty(Analyzer.BUNDLE_VERSION, project.version)
|
// setProperty(Analyzer.BUNDLE_VERSION, project.version)
|
||||||
setProperty(Analyzer.BUNDLE_NAME, project.group)
|
// setProperty(Analyzer.BUNDLE_NAME, project.group)
|
||||||
setProperty(Analyzer.BUNDLE_DESCRIPTION, project.description)
|
// setProperty(Analyzer.BUNDLE_DESCRIPTION, project.description)
|
||||||
setProperty(Analyzer.IMPORT_PACKAGE, "*")
|
// setProperty(Analyzer.IMPORT_PACKAGE, "*")
|
||||||
setProperty(Analyzer.EXPORT_PACKAGE, "*;-noimport:=false;version=" + project.version)
|
// setProperty(Analyzer.EXPORT_PACKAGE, "*;-noimport:=false;version=" + project.version)
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
val manifest = analyzer.calcManifest()
|
// val manifest = analyzer.calcManifest()
|
||||||
manifest.write(System.out)
|
// manifest.write(System.out)
|
||||||
return TaskResult()
|
// return TaskResult()
|
||||||
}
|
// }
|
||||||
|
|
||||||
|
|
||||||
@Task(name = PackagingPlugin.TASK_INSTALL, description = "Install the artifacts",
|
@Task(name = PackagingPlugin.TASK_INSTALL, description = "Install the artifacts",
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue