[KARAF-2665] Fix issue with Karaf custom distributions
diff --git a/features/org.apache.karaf.eik.feature/feature.xml b/features/org.apache.karaf.eik.feature/feature.xml
index 11a46bd..bba28ec 100644
--- a/features/org.apache.karaf.eik.feature/feature.xml
+++ b/features/org.apache.karaf.eik.feature/feature.xml
@@ -99,4 +99,10 @@
install-size="0"
version="0.0.0"/>
+ <plugin
+ id="jdom"
+ download-size="0"
+ install-size="0"
+ version="0.0.0"/>
+
</feature>
diff --git a/features/org.apache.karaf.eik.repository/pom.xml b/features/org.apache.karaf.eik.repository/pom.xml
index 2df3db6..76eda02 100644
--- a/features/org.apache.karaf.eik.repository/pom.xml
+++ b/features/org.apache.karaf.eik.repository/pom.xml
@@ -91,6 +91,12 @@
<outputDirectory>plugins</outputDirectory>
</artifactItem>
<artifactItem>
+ <groupId>org.apache.karaf.eik.plugins</groupId>
+ <artifactId>jdom</artifactId>
+ <version>${jdom.version}</version>
+ <outputDirectory>plugins</outputDirectory>
+ </artifactItem>
+ <artifactItem>
<groupId>org.apache.karaf.eik.features</groupId>
<artifactId>org.apache.karaf.eik.feature</artifactId>
<version>${project.version}</version>
diff --git a/parent/pom.xml b/parent/pom.xml
index c2379c5..4769ca5 100644
--- a/parent/pom.xml
+++ b/parent/pom.xml
@@ -35,7 +35,7 @@
<name>Apache Karaf :: EIK :: Parent</name>
<properties>
- <platform-version-name>helios</platform-version-name>
+ <platform-version-name>juno</platform-version-name>
<eclipse-site>http://download.eclipse.org/releases/${platform-version-name}</eclipse-site>
<wikitext-site>http://download.eclipse.org/tools/mylyn/update/weekly</wikitext-site>
<swtbot-site>http://download.eclipse.org/technology/swtbot/${platform-version-name}/dev-build/update-site
@@ -46,6 +46,7 @@
<commons-collections.version>3.2.1</commons-collections.version>
<commons-lang.version>2.6</commons-lang.version>
<jansi.version>1.7</jansi.version>
+ <jdom.version>1.0</jdom.version>
<mina.version>2.0.1</mina.version>
<pax.url.version>1.2.8</pax.url.version>
<sshd.version>0.5.0</sshd.version>
diff --git a/plugins/jdom/.settings/org.eclipse.core.resources.prefs b/plugins/jdom/.settings/org.eclipse.core.resources.prefs
new file mode 100644
index 0000000..99f26c0
--- /dev/null
+++ b/plugins/jdom/.settings/org.eclipse.core.resources.prefs
@@ -0,0 +1,2 @@
+eclipse.preferences.version=1
+encoding/<project>=UTF-8
diff --git a/plugins/jdom/.settings/org.eclipse.jdt.core.prefs b/plugins/jdom/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 0000000..c537b63
--- /dev/null
+++ b/plugins/jdom/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,7 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.6
diff --git a/plugins/jdom/.settings/org.eclipse.m2e.core.prefs b/plugins/jdom/.settings/org.eclipse.m2e.core.prefs
new file mode 100644
index 0000000..f897a7f
--- /dev/null
+++ b/plugins/jdom/.settings/org.eclipse.m2e.core.prefs
@@ -0,0 +1,4 @@
+activeProfiles=
+eclipse.preferences.version=1
+resolveWorkspaceProjects=true
+version=1
diff --git a/plugins/jdom/META-INF/MANIFEST.MF b/plugins/jdom/META-INF/MANIFEST.MF
new file mode 100644
index 0000000..dcb94b7
--- /dev/null
+++ b/plugins/jdom/META-INF/MANIFEST.MF
@@ -0,0 +1,18 @@
+Manifest-Version: 1.0
+Bundle-Description: Types that extend and augment the Java Lang.
+Bundle-DocURL: http://www.apache.org/
+Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
+Bundle-ManifestVersion: 2
+Bundle-Name: Apache Karaf :: EIK :: Plugins :: JDOM
+Bundle-SymbolicName: jdom;singleton:=true
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 1.0
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
+Bundle-ClassPath: lib/jdom-1.0.jar
+Export-Package: org.jdom,
+ org.jdom.adapters,
+ org.jdom.filter,
+ org.jdom.input,
+ org.jdom.output,
+ org.jdom.transform,
+ org.jdom.xpath
diff --git a/plugins/jdom/NOTICE b/plugins/jdom/NOTICE
new file mode 100644
index 0000000..7040fed
--- /dev/null
+++ b/plugins/jdom/NOTICE
@@ -0,0 +1,31 @@
+Apache Karaf EIK
+Copyright 2010-2012 The Apache Software Foundation
+
+
+I. Used Software
+
+This product includes software developed at
+The Apache Software Foundation (http://www.apache.org/).
+Licensed under the Apache License 2.0.
+
+This product uses software developed at
+The OSGi Alliance (http://www.osgi.org/).
+Copyright (c) OSGi Alliance (2000, 2010).
+Licensed under the Apache License 2.0.
+
+This product uses software developed at
+OPS4J (http://www.ops4j.org/).
+Licensed under the Apache License 2.0.
+
+This product uses software developed at
+FUSE Source (http://www.fusesource.org/).
+Licensed under the Apache License 2.0.
+
+This product includes software developed at
+Eclipse Foundation (http://www.eclipse.org/).
+Licensed under the EPL.
+
+
+II. License Summary
+- Apache License 2.0
+- EPL License
diff --git a/plugins/jdom/build.properties b/plugins/jdom/build.properties
new file mode 100644
index 0000000..60913c6
--- /dev/null
+++ b/plugins/jdom/build.properties
@@ -0,0 +1,6 @@
+bin.includes = META-INF/,\
+ lib/,\
+ lib/jdom-2.0.2.jar,\
+ lib/jdom-1.0.jar
+bin.excludes = lib/jdom-2.0.2-javadoc.jar
+src.includes = lib/jdom-2.0.2-sources.jar
diff --git a/plugins/jdom/pom.xml b/plugins/jdom/pom.xml
new file mode 100644
index 0000000..a29aa66
--- /dev/null
+++ b/plugins/jdom/pom.xml
@@ -0,0 +1,128 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+ <!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ -->
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.karaf.eik</groupId>
+ <artifactId>parent</artifactId>
+ <version>0.10.0-SNAPSHOT</version>
+ <relativePath>../../parent/pom.xml</relativePath>
+ </parent>
+
+ <groupId>org.apache.karaf.eik.plugins</groupId>
+ <artifactId>jdom</artifactId>
+ <version>1.0</version>
+ <packaging>eclipse-plugin</packaging>
+ <name>Apache Karaf :: EIK :: Plugins :: JDOM</name>
+
+ <build>
+ <resources>
+ <resource>
+ <directory>lib</directory>
+ <includes>
+ <include>**/*.jar</include>
+ </includes>
+ </resource>
+ </resources>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>copy-dependencies</id>
+ <phase>generate-resources</phase>
+ <goals>
+ <goal>copy</goal>
+ </goals>
+ <configuration>
+ <artifactItems>
+ <artifactItem>
+ <groupId>jdom</groupId>
+ <artifactId>jdom</artifactId>
+ <version>${jdom.version}</version>
+ <outputDirectory>lib</outputDirectory>
+ </artifactItem>
+ <artifactItem>
+ <groupId>jdom</groupId>
+ <artifactId>jdom</artifactId>
+ <version>${jdom.version}</version>
+ <classifier>sources</classifier>
+ <outputDirectory>lib</outputDirectory>
+ </artifactItem>
+ </artifactItems>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jar-plugin</artifactId>
+ <configuration>
+ <archive>
+ <manifestFile>${project.basedir}/META-INF/MANIFEST.MF</manifestFile>
+ </archive>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-clean-plugin</artifactId>
+ <configuration>
+ <filesets>
+ <fileset>
+ <directory>lib</directory>
+ </fileset>
+ </filesets>
+ </configuration>
+ </plugin>
+ </plugins>
+ <pluginManagement>
+ <plugins>
+ <!-- this plugin configuration is used to store Eclipse m2e settings only. It doesn't affect the core Maven build -->
+ <plugin>
+ <groupId>org.eclipse.m2e</groupId>
+ <artifactId>lifecycle-mapping</artifactId>
+ <version>1.0.0</version>
+ <configuration>
+ <lifecycleMappingMetadata>
+ <pluginExecutions>
+ <pluginExecution>
+ <pluginExecutionFilter>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <versionRange>[2.1,)</versionRange>
+ <goals>
+ <goal>copy</goal>
+ </goals>
+ </pluginExecutionFilter>
+ <action>
+ <ignore />
+ </action>
+ </pluginExecution>
+ </pluginExecutions>
+ </lifecycleMappingMetadata>
+ </configuration>
+ </plugin>
+ </plugins>
+ </pluginManagement>
+ </build>
+</project>
diff --git a/plugins/org.apache.karaf.eik.core/META-INF/MANIFEST.MF b/plugins/org.apache.karaf.eik.core/META-INF/MANIFEST.MF
index ab7a0d3..1953eca 100644
--- a/plugins/org.apache.karaf.eik.core/META-INF/MANIFEST.MF
+++ b/plugins/org.apache.karaf.eik.core/META-INF/MANIFEST.MF
@@ -9,7 +9,7 @@
org.eclipse.osgi.services;bundle-version="3.2.0",
org.eclipse.core.variables;bundle-version="[3.1.0,4.0.0)",
org.eclipse.pde.ui;bundle-version="[3.2.0,4.0.0)",
- org.jdom;bundle-version="1.0.0",
+ jdom;bundle-version="1.0.0",
org.apache.mina.core;bundle-version="2.0.0",
org.fusesource.jansi;bundle-version="1.5.0",
sshd-core;bundle-version="0.5.0",
diff --git a/plugins/org.apache.karaf.eik.core/src/main/java/org/apache/karaf/eik/core/features/Bundle.java b/plugins/org.apache.karaf.eik.core/src/main/java/org/apache/karaf/eik/core/features/Bundle.java
index 2468663..8169a32 100644
--- a/plugins/org.apache.karaf.eik.core/src/main/java/org/apache/karaf/eik/core/features/Bundle.java
+++ b/plugins/org.apache.karaf.eik.core/src/main/java/org/apache/karaf/eik/core/features/Bundle.java
@@ -27,6 +27,8 @@
private final String bundleUrl;
+ private final String startLevel;
+
private final Element element;
public Bundle(final Element element) {
@@ -35,6 +37,8 @@
throw new IllegalArgumentException("bundle element is invalid: " + element.toString());
}
+ this.startLevel = element.getAttributeValue("start-level");
+
this.element = element;
}
@@ -42,6 +46,11 @@
return bundleUrl;
}
+
+ public String getStartLevel() {
+ return startLevel;
+ }
+
@Override
public Object getParent() {
final Transformer transformer = new ElementTransformer();
@@ -53,4 +62,4 @@
return bundleUrl;
}
-}
\ No newline at end of file
+}
diff --git a/plugins/org.apache.karaf.eik.core/src/main/java/org/apache/karaf/eik/core/features/Feature.java b/plugins/org.apache.karaf.eik.core/src/main/java/org/apache/karaf/eik/core/features/Feature.java
index 3cb4bb3..fd250f4 100644
--- a/plugins/org.apache.karaf.eik.core/src/main/java/org/apache/karaf/eik/core/features/Feature.java
+++ b/plugins/org.apache.karaf.eik.core/src/main/java/org/apache/karaf/eik/core/features/Feature.java
@@ -38,6 +38,8 @@
private final Element element;
+ private final String startLevel;
+
private static final class BundleOnlyPredicate implements Predicate {
@Override
public boolean evaluate(final Object element) {
@@ -53,6 +55,8 @@
}
version = element.getAttributeValue("version");
+
+ startLevel = element.getAttributeValue("start-level");
this.element = element;
}
@@ -134,4 +138,8 @@
return Collections.unmodifiableList(KarafCorePluginUtils.filterList(transformedList, new FeatureOnlyPredicate()));
}
-}
\ No newline at end of file
+ public String getStartLevel() {
+ return startLevel;
+ }
+
+}
diff --git a/plugins/org.apache.karaf.eik.ui/src/main/java/org/apache/karaf/eik/ui/KarafLaunchConfigurationInitializer.java b/plugins/org.apache.karaf.eik.ui/src/main/java/org/apache/karaf/eik/ui/KarafLaunchConfigurationInitializer.java
index 9da1d15..558954c 100644
--- a/plugins/org.apache.karaf.eik.ui/src/main/java/org/apache/karaf/eik/ui/KarafLaunchConfigurationInitializer.java
+++ b/plugins/org.apache.karaf.eik.ui/src/main/java/org/apache/karaf/eik/ui/KarafLaunchConfigurationInitializer.java
@@ -18,6 +18,10 @@
*/
package org.apache.karaf.eik.ui;
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+
import org.apache.karaf.eik.core.IKarafConstants;
import org.apache.karaf.eik.core.KarafCorePluginUtils;
import org.apache.karaf.eik.core.KarafPlatformModel;
@@ -27,27 +31,33 @@
import org.apache.karaf.eik.core.configuration.StartupSection;
import org.apache.karaf.eik.core.equinox.BundleEntry;
import org.apache.karaf.eik.core.model.WorkingKarafPlatformModel;
+import org.apache.karaf.eik.ui.features.FeaturesBundlesStartLevels;
import org.apache.karaf.eik.ui.internal.WorkbenchServiceExtensions;
+import org.apache.karaf.eik.ui.project.KarafProject;
import org.apache.karaf.eik.ui.workbench.KarafWorkbenchServiceFactory;
-import java.io.File;
-import java.util.ArrayList;
-import java.util.List;
-
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IWorkspaceRoot;
+import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Status;
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants;
import org.eclipse.pde.core.plugin.IPluginBase;
import org.eclipse.pde.core.plugin.IPluginModelBase;
import org.eclipse.pde.core.plugin.ModelEntry;
import org.eclipse.pde.core.plugin.PluginRegistry;
+import org.eclipse.pde.core.target.ITargetHandle;
+import org.eclipse.pde.core.target.ITargetPlatformService;
+import org.eclipse.pde.internal.core.PDECore;
import org.eclipse.pde.internal.launching.launcher.LaunchConfigurationHelper;
import org.eclipse.pde.internal.ui.IPDEUIConstants;
import org.eclipse.pde.launching.IPDELauncherConstants;
import org.eclipse.pde.launching.OSGiLaunchConfigurationInitializer;
-import org.osgi.framework.Version;
@SuppressWarnings("restriction")
public class KarafLaunchConfigurationInitializer extends OSGiLaunchConfigurationInitializer {
@@ -74,16 +84,16 @@
protected StartupSection startupSection;
+ private FeaturesBundlesStartLevels featuresBundlesStartLevels;
+
@Override
public void initialize(final ILaunchConfigurationWorkingCopy configuration) {
loadKarafPlatform(configuration);
- final File configDir =
- LaunchConfigurationHelper.getConfigurationArea(configuration);
+ final File configDir = LaunchConfigurationHelper.getConfigurationArea(configuration);
final IPath workingArea = new Path(configDir.getAbsolutePath());
- final WorkingKarafPlatformModel workingKarafPlatform =
- new WorkingKarafPlatformModel(workingArea, karafPlatform);
+ final WorkingKarafPlatformModel workingKarafPlatform = new WorkingKarafPlatformModel(workingArea, karafPlatform);
workingKarafPlatform.getConfigurationDirectory().toFile().mkdirs();
workingKarafPlatform.getUserDeployedDirectory().toFile().mkdirs();
@@ -122,6 +132,8 @@
protected String getAutoStart(final String bundleID) {
if (startupSection.containsPlugin(bundleID)) {
return "true"; //$NON-NLS-1$
+ } else if (featuresBundlesStartLevels.containsPlugin(bundleID)) {
+ return "true"; //$NON-NLS-1$
} else {
return super.getAutoStart(bundleID);
}
@@ -139,6 +151,8 @@
protected String getStartLevel(final String bundleID) {
if (startupSection.containsPlugin(bundleID)) {
return startupSection.getStartLevel(bundleID);
+ } else if (featuresBundlesStartLevels.containsPlugin(bundleID)) {
+ return featuresBundlesStartLevels.getStartLevel(bundleID);
} else {
return super.getStartLevel(bundleID);
}
@@ -160,18 +174,13 @@
continue;
}
- final BundleEntry entry = new BundleEntry.Builder(getBundleId(models[i])).autostart(getAutoStart(id)).startLevel(
- getStartLevel(id)).build();
+ final BundleEntry entry = new BundleEntry.Builder(getBundleId(models[i])).autostart(getAutoStart(id)).startLevel(getStartLevel(id)).build();
final boolean inWorkspace = models[i].getUnderlyingResource() != null;
if (inWorkspace) {
workspacePlugins.add(entry.toString());
} else {
- // By default, only add the plugin if it is in the Karaf model
- final Version v = Version.parseVersion(models[i].getPluginBase().getVersion());
- if (karafPlatform.getState().getBundle(id, v) != null && startupSection.containsPlugin(id)) {
- externalPlugins.add(entry.toString());
- }
+ externalPlugins.add(entry.toString());
}
}
@@ -196,13 +205,9 @@
final String bootClasspath = KarafCorePluginUtils.join(bootClasspathEntries, ",");
- configuration.setAttribute(
- KarafLaunchConfigurationConstants.KARAF_LAUNCH_REQUIRED_BOOT_CLASSPATH,
- bootClasspath);
+ configuration.setAttribute(KarafLaunchConfigurationConstants.KARAF_LAUNCH_REQUIRED_BOOT_CLASSPATH, bootClasspath);
- configuration.setAttribute(
- IPDELauncherConstants.DEFAULT_START_LEVEL,
- Integer.parseInt(IKarafConstants.KARAF_DEFAULT_BUNDLE_START_LEVEL));
+ configuration.setAttribute(IPDELauncherConstants.DEFAULT_START_LEVEL, Integer.parseInt(IKarafConstants.KARAF_DEFAULT_BUNDLE_START_LEVEL));
}
/**
@@ -214,17 +219,48 @@
protected void loadKarafPlatform(final ILaunchConfigurationWorkingCopy configuration) {
try {
this.karafPlatform = KarafPlatformModelRegistry.findActivePlatformModel();
+
+ if (karafPlatform == null) {
+ throw new CoreException(new Status(IStatus.ERROR, KarafUIPluginActivator.PLUGIN_ID, "Karaf target platform is not set !"));
+ }
+
this.karafPlatformFactory = KarafPlatformModelRegistry.findPlatformModelFactory(karafPlatform.getRootDirectory());
this.startupSection = (StartupSection) this.karafPlatform.getAdapter(StartupSection.class);
this.startupSection.load();
+
+ IProject project = findProjectForActiveTargetPlatform();
+ if (project != null) {
+ this.featuresBundlesStartLevels = new FeaturesBundlesStartLevels(new KarafProject(project));
+ this.featuresBundlesStartLevels.load();
+ } else {
+ throw new CoreException(new Status(IStatus.ERROR, KarafUIPluginActivator.PLUGIN_ID, "Target platform is not set from Karaf project !"));
+ }
} catch (final CoreException e) {
KarafUIPluginActivator.getLogger().error("Unable to locate the Karaf platform", e);
this.karafPlatform = null;
+ throw new IllegalStateException(e.getMessage(), e);
}
}
+ private IProject findProjectForActiveTargetPlatform() throws CoreException {
+ ITargetPlatformService service = (ITargetPlatformService) PDECore.getDefault().acquireService(ITargetPlatformService.class.getName());
+
+ ITargetHandle workspaceTargetHandle = service.getWorkspaceTargetHandle();
+ if (workspaceTargetHandle != null && workspaceTargetHandle.exists()) {
+ String memento = workspaceTargetHandle.getMemento();
+
+ IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
+ IResource targetDefinitionFile = root.findMember(memento);
+ if (targetDefinitionFile != null) {
+ return targetDefinitionFile.getProject();
+ }
+ }
+
+ return null;
+ }
+
/**
* Returns the a plugin id favoring the newest version in the target
* platform
@@ -264,7 +300,7 @@
// prevent terminal CTRL-characters in Eclipse console on Windows
final String localOperatingSystem = System.getProperty("os.name"); //$NON-NLS-1$
- if ( localOperatingSystem.toLowerCase().indexOf("windows") >= 0 //$NON-NLS-1$
+ if (localOperatingSystem.toLowerCase().indexOf("windows") >= 0 //$NON-NLS-1$
&& vmArgs.indexOf("-Djline.terminal") == -1) { //$NON-NLS-1$
vmArgs.append(" -Djline.terminal=jline.UnsupportedTerminal"); //$NON-NLS-1$
}
diff --git a/plugins/org.apache.karaf.eik.ui/src/main/java/org/apache/karaf/eik/ui/features/FeaturesBundlesStartLevels.java b/plugins/org.apache.karaf.eik.ui/src/main/java/org/apache/karaf/eik/ui/features/FeaturesBundlesStartLevels.java
new file mode 100644
index 0000000..0d5c395
--- /dev/null
+++ b/plugins/org.apache.karaf.eik.ui/src/main/java/org/apache/karaf/eik/ui/features/FeaturesBundlesStartLevels.java
@@ -0,0 +1,104 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.karaf.eik.ui.features;
+
+import java.io.File;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+
+import org.apache.karaf.eik.core.IKarafConstants;
+import org.apache.karaf.eik.core.KarafPlatformModel;
+import org.apache.karaf.eik.core.configuration.FeaturesSection;
+import org.apache.karaf.eik.core.features.Bundle;
+import org.apache.karaf.eik.core.features.Feature;
+import org.apache.karaf.eik.core.features.FeaturesRepository;
+import org.apache.karaf.eik.ui.IKarafProject;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.osgi.service.resolver.BundleDescription;
+
+public class FeaturesBundlesStartLevels {
+
+ private final IKarafProject karafProject;
+ private final Map<String, String> symbolicNameToStartLevel;
+ private final MvnUrlConverter converter;
+
+ private KarafPlatformModel karafPlatformModel;
+ private String baseBundlesDir;
+
+ public FeaturesBundlesStartLevels(IKarafProject karafProject) {
+ this.karafProject = karafProject;
+ this.symbolicNameToStartLevel = new HashMap<String, String>();
+ this.converter = new MvnUrlConverter();
+ }
+
+ public void load(){
+ karafPlatformModel = (KarafPlatformModel) karafProject.getAdapter(KarafPlatformModel.class);
+ baseBundlesDir = getBaseBundleDir();
+
+ final FeaturesSection featuresSection = (FeaturesSection) karafPlatformModel.getAdapter(FeaturesSection.class);
+ final FeaturesResolverJob job = new FeaturesResolverJob(karafProject.getName(), karafPlatformModel, featuresSection);
+ job.run(new NullProgressMonitor());
+ List<FeaturesRepository> featuresRepositories = job.getFeaturesRepositories();
+ for (FeaturesRepository featuresRepository : featuresRepositories) {
+ List<Feature> features = featuresRepository.getFeatures().getFeatures();
+ for (Feature feature : features) {
+ String featureStartLevel = feature.getStartLevel();
+ List<Bundle> bundles = feature.getBundles();
+ for (Bundle bundle : bundles) {
+ String bundleStartLevel = bundle.getStartLevel();
+
+ String startLevel = (bundleStartLevel != null) ? bundleStartLevel : featureStartLevel;
+ if(startLevel != null) {
+ String symbolicName = getSymbolicName(bundle.getBundleUrl());
+ if(symbolicName != null) {
+ symbolicNameToStartLevel.put(symbolicName, startLevel);
+ }
+ }
+ }
+ }
+ }
+ }
+
+ private String getBaseBundleDir() {
+ Properties runtimeProperties = karafProject.getRuntimeProperties();
+ String karafHome = (String) runtimeProperties.get(IKarafConstants.KARAF_HOME_PROP);
+ String defaultRepository = (String) runtimeProperties.get("karaf.default.repository");
+ return karafHome + "/" + defaultRepository;
+ }
+
+ public boolean containsPlugin(String bundleSymbolicName) {
+ return symbolicNameToStartLevel.containsKey(bundleSymbolicName);
+ }
+
+ public String getStartLevel(String bundleSymbolicName) {
+ return symbolicNameToStartLevel.get(bundleSymbolicName);
+ }
+
+ private String getSymbolicName(String bundleUrl){
+ File bundlePath = new File(baseBundlesDir, converter.getPath(bundleUrl));
+ BundleDescription bundleDescription = karafPlatformModel.getState().getBundleByLocation(bundlePath.getAbsolutePath());
+ if(bundleDescription != null) {
+ return bundleDescription.getSymbolicName();
+ } else {
+ return null;
+ }
+ }
+}
diff --git a/plugins/org.apache.karaf.eik.ui/src/main/java/org/apache/karaf/eik/ui/features/FeaturesResolverJob.java b/plugins/org.apache.karaf.eik.ui/src/main/java/org/apache/karaf/eik/ui/features/FeaturesResolverJob.java
index 44e055f..c89917d 100644
--- a/plugins/org.apache.karaf.eik.ui/src/main/java/org/apache/karaf/eik/ui/features/FeaturesResolverJob.java
+++ b/plugins/org.apache.karaf.eik.ui/src/main/java/org/apache/karaf/eik/ui/features/FeaturesResolverJob.java
@@ -119,7 +119,7 @@
final String repos = (String) mvnConfiguration.get("org.ops4j.pax.url.mvn.repositories");
final String combinedRepos = KarafCorePluginUtils.join(Arrays.asList(new String[] { defaultRepos, repos }), ",");
- mvnConfiguration.put("org.ops4j.pax.url.mvn.repositories", combinedRepos);
+ mvnConfiguration.put("org.ops4j.pax.url.mvn.repositories", removeInvalidSuffixes(combinedRepos));
// End: Refactor
final String repositoryName;
@@ -168,4 +168,26 @@
}
}
-}
\ No newline at end of file
+ private String removeInvalidSuffixes(String mergedRepositories) {
+ String[] repositories = mergedRepositories.split(",");
+
+ for (int i = 0; i < repositories.length; i++) {
+ String repository = repositories[0];
+ String[] segments = repository.split("@");
+ StringBuilder urlBuilder = new StringBuilder(segments[0]);
+ for (int j = 0; j < segments.length; ++j)
+ {
+ String segment = segments[j];
+ if (segment.trim().equalsIgnoreCase("snapshots") || segment.trim().equalsIgnoreCase("noreleases"))
+ {
+ urlBuilder.append("@");
+ urlBuilder.append(segment);
+ }
+ }
+ repositories[i] = urlBuilder.toString();
+ }
+
+ return KarafCorePluginUtils.join(Arrays.asList(repositories), ",");
+ }
+
+}
diff --git a/plugins/org.apache.karaf.eik.ui/src/main/java/org/apache/karaf/eik/ui/features/MvnUrlConverter.java b/plugins/org.apache.karaf.eik.ui/src/main/java/org/apache/karaf/eik/ui/features/MvnUrlConverter.java
new file mode 100644
index 0000000..b7563df
--- /dev/null
+++ b/plugins/org.apache.karaf.eik.ui/src/main/java/org/apache/karaf/eik/ui/features/MvnUrlConverter.java
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.karaf.eik.ui.features;
+
+public class MvnUrlConverter {
+
+ public String getPath(String mvnUrl) {
+ if(mvnUrl != null) {
+ if(mvnUrl.startsWith("mvn:")) {
+ mvnUrl = mvnUrl.substring(4);
+ }
+
+ String[] repositorySplit = mvnUrl.split("!");
+ String urlWithoutRepository = repositorySplit[repositorySplit.length - 1];
+
+ String[] segments = urlWithoutRepository.split("/");
+ if(segments.length == 3) {
+ String groupId = segments[0];
+ String artifactId = segments[1];
+ String version = segments[2];
+
+ return groupId.replace(".", "/") + "/" + artifactId + "/" + version + "/" + artifactId + "-" + version + ".jar";
+ }
+ }
+
+ return null;
+ }
+
+}
diff --git a/plugins/org.apache.karaf.eik.ui/src/main/java/org/apache/karaf/eik/ui/internal/KarafLaunchUtils.java b/plugins/org.apache.karaf.eik.ui/src/main/java/org/apache/karaf/eik/ui/internal/KarafLaunchUtils.java
index c104ea8..4ba774a 100644
--- a/plugins/org.apache.karaf.eik.ui/src/main/java/org/apache/karaf/eik/ui/internal/KarafLaunchUtils.java
+++ b/plugins/org.apache.karaf.eik.ui/src/main/java/org/apache/karaf/eik/ui/internal/KarafLaunchUtils.java
@@ -18,9 +18,6 @@
*/
package org.apache.karaf.eik.ui.internal;
-import org.apache.karaf.eik.core.KarafCorePluginUtils;
-import org.apache.karaf.eik.core.KarafPlatformModel;
-
import java.io.File;
import java.util.ArrayList;
import java.util.Collection;
@@ -28,18 +25,20 @@
import java.util.List;
import java.util.Set;
+import org.apache.karaf.eik.core.KarafCorePluginUtils;
+import org.apache.karaf.eik.core.KarafPlatformModel;
+import org.eclipse.pde.core.target.ITargetLocation;
import org.eclipse.pde.internal.core.target.DirectoryBundleContainer;
-import org.eclipse.pde.internal.core.target.provisional.IBundleContainer;
public final class KarafLaunchUtils {
private static final int MAX_DIRECTORY_RECURSE_DEPTH = 50;
@SuppressWarnings("restriction")
- public static List<IBundleContainer> getBundleContainers(final KarafPlatformModel karafPlatformModel) {
+ public static List<ITargetLocation> getBundleContainers(final KarafPlatformModel karafPlatformModel) {
final Collection<File> directories = KarafLaunchUtils.getJarDirectories(karafPlatformModel);
- final List<IBundleContainer> bundleContainers = new ArrayList<IBundleContainer>();
+ final List<ITargetLocation> bundleContainers = new ArrayList<ITargetLocation>();
for (final File dir : directories) {
bundleContainers.add(new DirectoryBundleContainer(dir.getAbsolutePath()));
}
diff --git a/plugins/org.apache.karaf.eik.ui/src/main/java/org/apache/karaf/eik/ui/project/KarafProject.java b/plugins/org.apache.karaf.eik.ui/src/main/java/org/apache/karaf/eik/ui/project/KarafProject.java
index e2bbde9..4eeeb94 100644
--- a/plugins/org.apache.karaf.eik.ui/src/main/java/org/apache/karaf/eik/ui/project/KarafProject.java
+++ b/plugins/org.apache.karaf.eik.ui/src/main/java/org/apache/karaf/eik/ui/project/KarafProject.java
@@ -18,14 +18,14 @@
*/
package org.apache.karaf.eik.ui.project;
+import java.util.Properties;
+
import org.apache.karaf.eik.core.KarafCorePluginUtils;
import org.apache.karaf.eik.core.KarafPlatformModel;
import org.apache.karaf.eik.core.KarafPlatformModelRegistry;
import org.apache.karaf.eik.ui.IKarafProject;
import org.apache.karaf.eik.ui.KarafUIPluginActivator;
-import java.util.Properties;
-
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IProject;
@@ -41,6 +41,8 @@
public static final IPath ROOT_PLATFORM_PATH = ROOT_PATH.append("platform");
+ public static final IPath ROOT_RUNTIME_PATH = ROOT_PATH.append("runtime");
+
/**
* Determines if the {@link IProject} is actually an {@link IKarafProject}
*
@@ -51,8 +53,7 @@
*/
public static boolean isKarafProject(final IProject project) {
try {
- final String karafProject = project.getPersistentProperty(
- new QualifiedName(KarafUIPluginActivator.PLUGIN_ID, "karafProject"));
+ final String karafProject = project.getPersistentProperty(new QualifiedName(KarafUIPluginActivator.PLUGIN_ID, "karafProject"));
return karafProject != null;
} catch (final CoreException e) {
@@ -127,7 +128,7 @@
public Properties getRuntimeProperties() {
try {
return KarafCorePluginUtils.loadProperties(
- project.getFolder("runtime").getRawLocation().toFile(),
+ project.getFolder(ROOT_RUNTIME_PATH).getRawLocation().toFile(),
"runtime.properties");
} catch (final CoreException e) {
return new Properties();
diff --git a/plugins/org.apache.karaf.eik.ui/src/main/java/org/apache/karaf/eik/ui/project/KarafProjectBuilder.java b/plugins/org.apache.karaf.eik.ui/src/main/java/org/apache/karaf/eik/ui/project/KarafProjectBuilder.java
index 330f586..c79ecf2 100644
--- a/plugins/org.apache.karaf.eik.ui/src/main/java/org/apache/karaf/eik/ui/project/KarafProjectBuilder.java
+++ b/plugins/org.apache.karaf.eik.ui/src/main/java/org/apache/karaf/eik/ui/project/KarafProjectBuilder.java
@@ -18,17 +18,6 @@
*/
package org.apache.karaf.eik.ui.project;
-import org.apache.karaf.eik.core.KarafCorePluginUtils;
-import org.apache.karaf.eik.core.KarafPlatformModel;
-import org.apache.karaf.eik.core.PropertyUtils;
-import org.apache.karaf.eik.core.configuration.FeaturesSection;
-import org.apache.karaf.eik.core.features.FeaturesRepository;
-import org.apache.karaf.eik.ui.IKarafProject;
-import org.apache.karaf.eik.ui.KarafUIPluginActivator;
-import org.apache.karaf.eik.ui.features.FeaturesResolverJob;
-import org.apache.karaf.eik.ui.internal.KarafLaunchUtils;
-import org.apache.karaf.eik.ui.internal.PopulateObrFileJob;
-
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
@@ -44,6 +33,17 @@
import java.util.jar.Manifest;
import java.util.zip.ZipEntry;
+import org.apache.karaf.eik.core.KarafCorePluginUtils;
+import org.apache.karaf.eik.core.KarafPlatformModel;
+import org.apache.karaf.eik.core.PropertyUtils;
+import org.apache.karaf.eik.core.configuration.FeaturesSection;
+import org.apache.karaf.eik.core.features.FeaturesRepository;
+import org.apache.karaf.eik.ui.IKarafProject;
+import org.apache.karaf.eik.ui.KarafUIPluginActivator;
+import org.apache.karaf.eik.ui.features.FeaturesResolverJob;
+import org.apache.karaf.eik.ui.internal.KarafLaunchUtils;
+import org.apache.karaf.eik.ui.internal.PopulateObrFileJob;
+
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IProject;
@@ -57,10 +57,10 @@
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Status;
-import org.eclipse.pde.internal.core.target.provisional.IBundleContainer;
-import org.eclipse.pde.internal.core.target.provisional.ITargetDefinition;
-import org.eclipse.pde.internal.core.target.provisional.ITargetHandle;
-import org.eclipse.pde.internal.core.target.provisional.ITargetPlatformService;
+import org.eclipse.pde.core.target.ITargetDefinition;
+import org.eclipse.pde.core.target.ITargetHandle;
+import org.eclipse.pde.core.target.ITargetLocation;
+import org.eclipse.pde.core.target.ITargetPlatformService;
public class KarafProjectBuilder extends IncrementalProjectBuilder {
@@ -327,7 +327,6 @@
return getKarafProject().getProjectHandle().getFile(targetFilename);
}
- @SuppressWarnings("restriction")
private void createTargetPlatform(final IProgressMonitor monitor) throws CoreException {
final ITargetPlatformService targetPlatformService = (ITargetPlatformService) KarafUIPluginActivator.getDefault().getService(ITargetPlatformService.class.getName());
@@ -338,8 +337,8 @@
target.setName(getKarafProject().getName());
- final List<IBundleContainer> bundleContainers = KarafLaunchUtils.getBundleContainers(getKarafPlatformModel());
- target.setBundleContainers(bundleContainers.toArray(new IBundleContainer[0]));
+ final List<ITargetLocation> bundleContainers = KarafLaunchUtils.getBundleContainers(getKarafPlatformModel());
+ target.setTargetLocations(bundleContainers.toArray(new ITargetLocation[0]));
targetPlatformService.saveTargetDefinition(target);
}
diff --git a/plugins/org.apache.karaf.eik.ui/src/main/java/org/apache/karaf/eik/ui/project/NewKarafProjectOperation.java b/plugins/org.apache.karaf.eik.ui/src/main/java/org/apache/karaf/eik/ui/project/NewKarafProjectOperation.java
index d47c9cd..9e80bb5 100644
--- a/plugins/org.apache.karaf.eik.ui/src/main/java/org/apache/karaf/eik/ui/project/NewKarafProjectOperation.java
+++ b/plugins/org.apache.karaf.eik.ui/src/main/java/org/apache/karaf/eik/ui/project/NewKarafProjectOperation.java
@@ -18,14 +18,14 @@
*/
package org.apache.karaf.eik.ui.project;
+import java.lang.reflect.InvocationTargetException;
+
import org.apache.karaf.eik.core.KarafPlatformModel;
import org.apache.karaf.eik.core.KarafWorkingPlatformModel;
import org.apache.karaf.eik.ui.IKarafProject;
import org.apache.karaf.eik.ui.KarafLaunchConfigurationInitializer;
import org.apache.karaf.eik.ui.KarafUIPluginActivator;
-import java.lang.reflect.InvocationTargetException;
-
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IProjectDescription;
import org.eclipse.core.runtime.CoreException;
@@ -36,9 +36,6 @@
import org.eclipse.core.runtime.QualifiedName;
import org.eclipse.core.variables.IDynamicVariable;
import org.eclipse.core.variables.VariablesPlugin;
-import org.eclipse.debug.core.DebugPlugin;
-import org.eclipse.debug.core.ILaunchConfigurationType;
-import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
import org.eclipse.ui.actions.WorkspaceModifyOperation;
public class NewKarafProjectOperation extends WorkspaceModifyOperation {
@@ -119,16 +116,6 @@
newKarafProject.getProjectHandle().setPersistentProperty(
new QualifiedName(KarafUIPluginActivator.PLUGIN_ID, "karafModel"),
karafPlatformModel.getRootDirectory().toString());
-
- final ILaunchConfigurationType launchType =
- DebugPlugin.getDefault().getLaunchManager().getLaunchConfigurationType("org.eclipse.pde.ui.EquinoxLauncher");
-
- final ILaunchConfigurationWorkingCopy launchConfiguration =
- launchType.newInstance(newKarafProject.getProjectHandle(), newKarafProject.getName());
-
- KarafLaunchConfigurationInitializer.initializeConfiguration(launchConfiguration);
-
- launchConfiguration.doSave();
}
private void createProject(final IProgressMonitor monitor) throws CoreException {
diff --git a/plugins/org.apache.karaf.eik.ui/src/main/java/org/apache/karaf/eik/ui/workbench/internal/GenericKarafWorkbenchService.java b/plugins/org.apache.karaf.eik.ui/src/main/java/org/apache/karaf/eik/ui/workbench/internal/GenericKarafWorkbenchService.java
index 0c87c2d..ec58ad9 100644
--- a/plugins/org.apache.karaf.eik.ui/src/main/java/org/apache/karaf/eik/ui/workbench/internal/GenericKarafWorkbenchService.java
+++ b/plugins/org.apache.karaf.eik.ui/src/main/java/org/apache/karaf/eik/ui/workbench/internal/GenericKarafWorkbenchService.java
@@ -231,10 +231,12 @@
final String bundleLocation =
KarafCorePluginUtils.getBundleLocation(b);
- final BundleEntry entry =
- new BundleEntry.Builder(bundleLocation).startLevel("1").autostart("start").build(); //$NON-NLS-1$ $NON-NLS-2$
-
- bundleEntries.add(entry);
+ if (bundleLocation != null) {
+ final BundleEntry entry =
+ new BundleEntry.Builder(bundleLocation).startLevel("1").autostart("start").build(); //$NON-NLS-1$ $NON-NLS-2$
+
+ bundleEntries.add(entry);
+ }
}
return bundleEntries;
diff --git a/pom.xml b/pom.xml
index b8d7164..0daa6ef 100644
--- a/pom.xml
+++ b/pom.xml
@@ -45,6 +45,7 @@
<module>plugins/org.apache.aries.jmx.core</module>
<module>plugins/org.apache.commons.collections</module>
<module>plugins/org.apache.commons.lang</module>
+ <module>plugins/jdom</module>
<module>plugins/org.apache.mina.core</module>
<module>plugins/org.apache.sshd.core</module>
<module>plugins/org.fusesource.jansi</module>