changed bundles activation order
This commit is contained in:
@@ -1,13 +1,14 @@
|
||||
package net.woggioni.gradle.osgi.app;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.net.URI;
|
||||
import java.net.URL;
|
||||
import javax.annotation.Nonnull;
|
||||
import lombok.SneakyThrows;
|
||||
import org.gradle.api.resources.ReadableResource;
|
||||
import org.gradle.api.resources.ResourceException;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.io.InputStream;
|
||||
import java.net.URI;
|
||||
import java.net.URL;
|
||||
|
||||
abstract class EmbeddedResource implements ReadableResource {
|
||||
private final URL url;
|
||||
|
||||
|
@@ -1,12 +1,10 @@
|
||||
package net.woggioni.gradle.osgi.app;
|
||||
|
||||
import aQute.bnd.osgi.Constants;
|
||||
import groovy.lang.Tuple2;
|
||||
import lombok.SneakyThrows;
|
||||
import org.gradle.api.DefaultTask;
|
||||
import org.gradle.api.tasks.OutputFile;
|
||||
import org.gradle.api.tasks.TaskAction;
|
||||
import org.osgi.framework.Version;
|
||||
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.File;
|
||||
@@ -14,8 +12,6 @@ import java.io.FileOutputStream;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
import java.util.jar.Attributes;
|
||||
import java.util.jar.JarFile;
|
||||
|
||||
@@ -41,25 +37,20 @@ public class BundleFileTask extends DefaultTask {
|
||||
@TaskAction
|
||||
@SneakyThrows
|
||||
public void run() {
|
||||
Map<Tuple2<String, Version>, String> map = new TreeMap<>();
|
||||
for(File bundleFile : bundles) {
|
||||
try(JarFile jarFile = new JarFile(bundleFile)) {
|
||||
Attributes mainAttributes = jarFile.getManifest().getMainAttributes();
|
||||
String bundleSymbolicName = mainAttributes.getValue(Constants.BUNDLE_SYMBOLICNAME);
|
||||
String bundleVersion = mainAttributes.getValue(Constants.BUNDLE_VERSION);
|
||||
if(bundleSymbolicName != null && bundleVersion != null) {
|
||||
Tuple2<String, Version> key = new Tuple2<>(
|
||||
bundleSymbolicName,
|
||||
Version.parseVersion(bundleVersion));
|
||||
map.put(key, bundleFile.getName());
|
||||
try (BufferedWriter writer =
|
||||
new BufferedWriter(
|
||||
new OutputStreamWriter(new FileOutputStream(systemBundleFile)))) {
|
||||
for (File bundleFile : bundles) {
|
||||
try (JarFile jarFile = new JarFile(bundleFile)) {
|
||||
Attributes mainAttributes = jarFile.getManifest().getMainAttributes();
|
||||
String bundleSymbolicName = mainAttributes.getValue(Constants.BUNDLE_SYMBOLICNAME);
|
||||
String bundleVersion = mainAttributes.getValue(Constants.BUNDLE_VERSION);
|
||||
if (bundleSymbolicName != null && bundleVersion != null) {
|
||||
writer.write("bundles/" + bundleFile.getName());
|
||||
writer.newLine();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
try(BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(systemBundleFile)))) {
|
||||
for(Map.Entry<Tuple2<String, Version>, String> entry : map.entrySet()) {
|
||||
writer.write("bundles/" + entry.getValue());
|
||||
writer.newLine();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,7 +1,6 @@
|
||||
package net.woggioni.gradle.osgi.app;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.SneakyThrows;
|
||||
import org.gradle.api.DefaultTask;
|
||||
import org.gradle.api.model.ObjectFactory;
|
||||
|
@@ -35,9 +35,9 @@ public class JavaAgentFileTask extends DefaultTask {
|
||||
@TaskAction
|
||||
@SneakyThrows
|
||||
public void run() {
|
||||
try(Writer writer = Files.newBufferedWriter(getOutputFile().toPath())) {
|
||||
try (Writer writer = Files.newBufferedWriter(getOutputFile().toPath())) {
|
||||
Properties props = new Properties();
|
||||
for(JavaAgent javaAgent : javaAgents.get()) {
|
||||
for (JavaAgent javaAgent : javaAgents.get()) {
|
||||
props.setProperty(javaAgent.getClassName(), javaAgent.getArgs());
|
||||
}
|
||||
props.store(writer, null);
|
||||
|
Reference in New Issue
Block a user