Skip to content

Commit 4a1e657

Browse files
committed
Slightly improved version.
1 parent 5bd76ff commit 4a1e657

1 file changed

Lines changed: 13 additions & 10 deletions

File tree

de.tototec.osgi.setupbuilder/src/main/scala/de/tototec/osgi/setupbuilder/EquinoxSetupBuilder.scala

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -39,17 +39,20 @@ class EquinoxSetupBuilder(
3939
setup.bundles.map { file =>
4040
// the Bundle
4141
val bundle = new Bundle(file)
42+
val isFrameworkBundle = setup.frameworkBundle == bundle.symbolicName
43+
val bundleString = if (isFrameworkBundle) "framework bundle" else "bundle"
44+
val copyBundle = !setup.doNotCopyBundles
4245

4346
// the target location of the bundle
44-
val bundleFile = if (setup.doNotCopyBundles) {
45-
log.debug(s"Using bundle ${bundle.symbolicName} from source location.")
47+
val bundleFile = if (!copyBundle) {
48+
log.debug(s"Using ${bundleString} ${bundle.symbolicName} from source location.")
4649
file
4750

4851
} else {
4952
val bundleFile = new File(pluginDir, s"${bundle.symbolicName}_${bundle.version}.jar")
5053

5154
// copy bundle to target location
52-
log.debug(s"Copying bundle ${bundle.symbolicName} to plugins directory.")
55+
log.debug(s"Copying ${bundleString} ${bundle.symbolicName} to plugins directory.")
5356
val out = new FileOutputStream(bundleFile)
5457
val in = new FileInputStream(file)
5558
try {
@@ -63,12 +66,12 @@ class EquinoxSetupBuilder(
6366
}
6467

6568
// Add the bundle to config, either as framework bundle or as plugin with optional start level and start configuration
66-
if (setup.frameworkBundle == bundle.symbolicName) {
69+
if (isFrameworkBundle) {
6770
equinoxConfig += ("osgi.framework" -> {
68-
if (setup.doNotCopyBundles) s"file:${bundleFile.getAbsolutePath}"
69-
else s"file:plugins/${bundleFile.getName}"
70-
71-
})
71+
if (copyBundle) s"file:plugins/${bundleFile.getName}"
72+
else s"file:${bundleFile.getAbsolutePath}"
73+
}
74+
)
7275
} else {
7376
// the suffix indicates the start level and the start state
7477
// <URL | simple bundle location>[@ [<start-level>] [":start"]]
@@ -83,8 +86,8 @@ class EquinoxSetupBuilder(
8386

8487
var bundles = equinoxConfig.get("osgi.bundles").toSeq
8588
bundles ++= Seq(
86-
if (setup.doNotCopyBundles) s"reference:file:${bundleFile.getAbsolutePath}${suffix}"
87-
else s"reference:file:${bundleFile.getName}${suffix}"
89+
if (copyBundle) s"reference:file:${bundleFile.getName}${suffix}"
90+
else s"reference:file:${bundleFile.getAbsolutePath}${suffix}"
8891
)
8992

9093
equinoxConfig += ("osgi.bundles" -> bundles.mkString(","))

0 commit comments

Comments
 (0)