mirror of
https://github.com/ethauvin/kobalt.git
synced 2025-04-26 00:17:11 -07:00
OSGi improvements.
This commit is contained in:
parent
4385a81308
commit
bc4bee8461
1 changed files with 27 additions and 23 deletions
|
@ -12,12 +12,15 @@ import com.beust.kobalt.plugin.packaging.PackagingPlugin
|
||||||
import com.google.common.reflect.ClassPath
|
import com.google.common.reflect.ClassPath
|
||||||
import com.google.inject.Inject
|
import com.google.inject.Inject
|
||||||
import com.google.inject.Singleton
|
import com.google.inject.Singleton
|
||||||
|
import java.io.ByteArrayOutputStream
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.net.URI
|
import java.net.URI
|
||||||
import java.net.URLClassLoader
|
import java.net.URLClassLoader
|
||||||
import java.nio.file.FileSystems
|
import java.nio.file.FileSystems
|
||||||
import java.nio.file.Files
|
import java.nio.file.Files
|
||||||
import java.nio.file.StandardOpenOption
|
import java.nio.file.StandardOpenOption
|
||||||
|
import java.time.LocalDate
|
||||||
|
import java.time.format.DateTimeFormatter
|
||||||
import java.util.jar.JarFile
|
import java.util.jar.JarFile
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -60,6 +63,7 @@ class OsgiPlugin @Inject constructor(val configActor: ConfigActor<OsgiConfig>, v
|
||||||
dependencyManager.calculateDependencies(project, context, passedDependencies = dependencies).forEach {
|
dependencyManager.calculateDependencies(project, context, passedDependencies = dependencies).forEach {
|
||||||
addClasspath(it.jarFile.get())
|
addClasspath(it.jarFile.get())
|
||||||
}
|
}
|
||||||
|
setProperty("Build-Date", LocalDate.now().format(DateTimeFormatter.ofPattern("y-MM-dd")))
|
||||||
setProperty(Analyzer.BUNDLE_VERSION, project.version)
|
setProperty(Analyzer.BUNDLE_VERSION, project.version)
|
||||||
setProperty(Analyzer.BUNDLE_NAME, project.group + "." + project.artifactId)
|
setProperty(Analyzer.BUNDLE_NAME, project.group + "." + project.artifactId)
|
||||||
setProperty(Analyzer.BUNDLE_DESCRIPTION, project.description)
|
setProperty(Analyzer.BUNDLE_DESCRIPTION, project.description)
|
||||||
|
@ -72,15 +76,13 @@ class OsgiPlugin @Inject constructor(val configActor: ConfigActor<OsgiConfig>, v
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val manifest = analyzer.calcManifest()
|
analyzer.calcManifest().let { manifest ->
|
||||||
val lines = manifest.mainAttributes.map {
|
val lines2 = ByteArrayOutputStream().use { baos ->
|
||||||
it.key.toString() + ": " + it.value.toString()
|
manifest.write(baos)
|
||||||
|
String(baos.toByteArray())
|
||||||
}
|
}
|
||||||
|
|
||||||
context.logger.log(project.name, 2, " Generated manifest:")
|
context.logger.log(project.name, 2, " Generated manifest:\n$lines2")
|
||||||
lines.forEach {
|
|
||||||
context.logger.log(project.name, 2, " $it")
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Update or create META-INF/MANIFEST.MF
|
// Update or create META-INF/MANIFEST.MF
|
||||||
|
@ -94,10 +96,12 @@ class OsgiPlugin @Inject constructor(val configActor: ConfigActor<OsgiConfig>, v
|
||||||
Files.createDirectories(fs.getPath("META-INF/"))
|
Files.createDirectories(fs.getPath("META-INF/"))
|
||||||
}
|
}
|
||||||
val jarManifest = fs.getPath(MetaArchive.MANIFEST_MF)
|
val jarManifest = fs.getPath(MetaArchive.MANIFEST_MF)
|
||||||
Files.write(jarManifest, lines, if (mf != null) StandardOpenOption.APPEND else StandardOpenOption.CREATE)
|
Files.write(jarManifest, listOf(lines2),
|
||||||
|
if (mf != null) StandardOpenOption.APPEND else StandardOpenOption.CREATE)
|
||||||
}
|
}
|
||||||
return TaskResult()
|
return TaskResult()
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class OsgiConfig
|
class OsgiConfig
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue