Index: features/org.apache.karaf.eik.feature/feature.xml =================================================================== --- features/org.apache.karaf.eik.feature/feature.xml (revision 1541491) +++ features/org.apache.karaf.eik.feature/feature.xml (working copy) @@ -99,4 +99,10 @@ install-size="0" version="0.0.0"/> + + Index: features/org.apache.karaf.eik.repository/pom.xml =================================================================== --- features/org.apache.karaf.eik.repository/pom.xml (revision 1541491) +++ features/org.apache.karaf.eik.repository/pom.xml (working copy) @@ -91,6 +91,12 @@ plugins + org.apache.karaf.eik.plugins + jdom + ${jdom.version} + plugins + + org.apache.karaf.eik.features org.apache.karaf.eik.feature ${project.version} Index: plugins/jdom/.settings/org.eclipse.core.resources.prefs =================================================================== --- plugins/jdom/.settings/org.eclipse.core.resources.prefs (revision 0) +++ plugins/jdom/.settings/org.eclipse.core.resources.prefs (revision 0) @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +encoding/=UTF-8 Index: plugins/jdom/.settings/org.eclipse.jdt.core.prefs =================================================================== --- plugins/jdom/.settings/org.eclipse.jdt.core.prefs (revision 0) +++ plugins/jdom/.settings/org.eclipse.jdt.core.prefs (revision 0) @@ -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 Index: plugins/jdom/.settings/org.eclipse.m2e.core.prefs =================================================================== --- plugins/jdom/.settings/org.eclipse.m2e.core.prefs (revision 0) +++ plugins/jdom/.settings/org.eclipse.m2e.core.prefs (revision 0) @@ -0,0 +1,4 @@ +activeProfiles= +eclipse.preferences.version=1 +resolveWorkspaceProjects=true +version=1 Index: plugins/jdom/NOTICE =================================================================== --- plugins/jdom/NOTICE (revision 0) +++ plugins/jdom/NOTICE (revision 0) @@ -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 Index: plugins/jdom/build.properties =================================================================== --- plugins/jdom/build.properties (revision 0) +++ plugins/jdom/build.properties (revision 0) @@ -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 Index: plugins/jdom/META-INF/MANIFEST.MF =================================================================== --- plugins/jdom/META-INF/MANIFEST.MF (revision 0) +++ plugins/jdom/META-INF/MANIFEST.MF (revision 0) @@ -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 Index: plugins/jdom/pom.xml =================================================================== --- plugins/jdom/pom.xml (revision 0) +++ plugins/jdom/pom.xml (revision 0) @@ -0,0 +1,166 @@ + + + + + + 4.0.0 + + + org.apache.karaf.eik + parent + 0.10.0-SNAPSHOT + ../../parent/pom.xml + + + org.apache.karaf.eik.plugins + jdom + 1.0 + eclipse-plugin + Apache Karaf :: EIK :: Plugins :: JDOM + + + + + lib + + **/*.jar + + + + + + org.apache.maven.plugins + maven-dependency-plugin + + + copy-dependencies + generate-resources + + copy + + + + + jdom + jdom + ${jdom.version} + lib + + + jdom + jdom + ${jdom.version} + sources + lib + + + + + + + + org.apache.maven.plugins + maven-jar-plugin + + + ${project.basedir}/META-INF/MANIFEST.MF + + + + + org.apache.maven.plugins + maven-clean-plugin + + + + lib + + + + + + + + + + org.eclipse.m2e + lifecycle-mapping + 1.0.0 + + + + + + org.apache.maven.plugins + maven-dependency-plugin + [2.1,) + + copy + + + + + + + + + + + + + + Index: plugins/jdom/.classpath =================================================================== --- plugins/jdom/.classpath (revision 0) +++ plugins/jdom/.classpath (revision 0) @@ -0,0 +1,7 @@ + + + + + + + Index: plugins/jdom/.project =================================================================== --- plugins/jdom/.project (revision 0) +++ plugins/jdom/.project (revision 0) @@ -0,0 +1,29 @@ + + + jdom + The Apache Software Foundation provides support for the Apache community of open-source software projects. + The Apache projects are characterized by a collaborative, consensus based development process, an open and + pragmatic software license, and a desire to create high quality software that leads the way in its field. + We consider ourselves not simply a group of projects sharing a server, but rather a community of developers + and users. NO_M2ECLIPSE_SUPPORT: Project files created with the maven-eclipse-plugin are not supported in M2Eclipse. + + + + org.eclipse.jdt.core.javabuilder + + + org.eclipse.pde.ManifestBuilder + + + org.eclipse.pde.SchemaBuilder + + + org.eclipse.m2e.core.maven2Builder + + + + org.eclipse.m2e.core.maven2Nature + org.eclipse.pde.PluginNature + org.eclipse.jdt.core.javanature + + \ No newline at end of file Index: plugins/org.apache.karaf.eik.core/META-INF/MANIFEST.MF =================================================================== --- plugins/org.apache.karaf.eik.core/META-INF/MANIFEST.MF (revision 1541491) +++ plugins/org.apache.karaf.eik.core/META-INF/MANIFEST.MF (working copy) @@ -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", Index: plugins/org.apache.karaf.eik.core/src/main/java/org/apache/karaf/eik/core/features/Feature.java =================================================================== --- plugins/org.apache.karaf.eik.core/src/main/java/org/apache/karaf/eik/core/features/Feature.java (revision 1541491) +++ plugins/org.apache.karaf.eik.core/src/main/java/org/apache/karaf/eik/core/features/Feature.java (working copy) @@ -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) { @@ -54,6 +56,8 @@ version = element.getAttributeValue("version"); + startLevel = element.getAttributeValue("start-level"); + this.element = element; } @@ -134,4 +138,7 @@ return Collections.unmodifiableList(KarafCorePluginUtils.filterList(transformedList, new FeatureOnlyPredicate())); } + public String getStartLevel() { + return startLevel; + } } \ No newline at end of file Index: plugins/org.apache.karaf.eik.core/src/main/java/org/apache/karaf/eik/core/features/Bundle.java =================================================================== --- plugins/org.apache.karaf.eik.core/src/main/java/org/apache/karaf/eik/core/features/Bundle.java (revision 1541491) +++ plugins/org.apache.karaf.eik.core/src/main/java/org/apache/karaf/eik/core/features/Bundle.java (working copy) @@ -26,7 +26,7 @@ public final class Bundle implements ParentAwareObject { private final String bundleUrl; - + private final String startLevel; private final Element element; public Bundle(final Element element) { @@ -35,6 +35,8 @@ throw new IllegalArgumentException("bundle element is invalid: " + element.toString()); } + this.startLevel = element.getAttributeValue("start-level"); + this.element = element; } @@ -42,6 +44,10 @@ return bundleUrl; } + public String getStartLevel() { + return startLevel; + } + @Override public Object getParent() { final Transformer transformer = new ElementTransformer(); Index: plugins/org.apache.karaf.eik.ui/src/main/java/org/apache/karaf/eik/ui/KarafLaunchConfigurationInitializer.java =================================================================== --- plugins/org.apache.karaf.eik.ui/src/main/java/org/apache/karaf/eik/ui/KarafLaunchConfigurationInitializer.java (revision 1541491) +++ plugins/org.apache.karaf.eik.ui/src/main/java/org/apache/karaf/eik/ui/KarafLaunchConfigurationInitializer.java (working copy) @@ -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,32 @@ 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 { @@ -56,7 +65,7 @@ /** * Convenience method for initializing a Karaf launch configuration - * + * * @param configuration * the working copy of the launch configuration */ @@ -74,16 +83,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(); @@ -114,7 +123,7 @@ /** * Initializes the auto start property to true for the bundles found in the * Karaf platform and defers the the parent for all other bundles. - * + * * @see org.eclipse.pde.ui.launcher.OSGiLaunchConfigurationInitializer#getAutoStart * (java.lang.String) */ @@ -122,6 +131,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); } @@ -131,7 +142,7 @@ * Initializes the bundles associated with the Karaf platform with the * correct default start levels and falls back to the default start level * provided by the parent. - * + * * @see org.eclipse.pde.ui.launcher.OSGiLaunchConfigurationInitializer#getStartLevel * (java.lang.String) */ @@ -139,6 +150,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 +173,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()); } } @@ -185,7 +193,7 @@ * Initializes a series of default configuration items for the framework * launcher. This includes registering the default boot classpath entries * and setting the Karaf platform default OSGi bundle start level. - * + * * @param configuration * the launch configuration * @see org.eclipse.pde.ui.launcher.OSGiLaunchConfigurationInitializer#initializeFrameworkDefaults(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy) @@ -196,39 +204,67 @@ 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)); } /** * Loads a Karaf platform definition based on the context of the launch * configuration. - * + * * @param configuration */ 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 - * + * * @param model * the {@link IPluginModelBase} * @return the string plugin identifier with an optional version set at the @@ -251,7 +287,7 @@ /** * Adds default VM arguments to this launch configuration - * + * * @param configuration * the working copy of the launch configuration */ @@ -264,8 +300,8 @@ // 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$ - && vmArgs.indexOf("-Djline.terminal") == -1) { //$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$ } Index: plugins/org.apache.karaf.eik.ui/src/main/java/org/apache/karaf/eik/ui/project/KarafProject.java =================================================================== --- plugins/org.apache.karaf.eik.ui/src/main/java/org/apache/karaf/eik/ui/project/KarafProject.java (revision 1541491) +++ plugins/org.apache.karaf.eik.ui/src/main/java/org/apache/karaf/eik/ui/project/KarafProject.java (working copy) @@ -18,14 +18,13 @@ */ 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; @@ -40,7 +39,8 @@ private static final IPath ROOT_PATH = new Path(".bin"); 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} * @@ -127,7 +127,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(); Index: plugins/org.apache.karaf.eik.ui/src/main/java/org/apache/karaf/eik/ui/project/KarafProjectBuilder.java =================================================================== --- plugins/org.apache.karaf.eik.ui/src/main/java/org/apache/karaf/eik/ui/project/KarafProjectBuilder.java (revision 1541491) +++ plugins/org.apache.karaf.eik.ui/src/main/java/org/apache/karaf/eik/ui/project/KarafProjectBuilder.java (working copy) @@ -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,16 @@ 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 +56,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 +326,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 +336,8 @@ target.setName(getKarafProject().getName()); - final List bundleContainers = KarafLaunchUtils.getBundleContainers(getKarafPlatformModel()); - target.setBundleContainers(bundleContainers.toArray(new IBundleContainer[0])); + final List bundleContainers = KarafLaunchUtils.getBundleContainers(getKarafPlatformModel()); + target.setTargetLocations(bundleContainers.toArray(new ITargetLocation[0])); targetPlatformService.saveTargetDefinition(target); } Index: plugins/org.apache.karaf.eik.ui/src/main/java/org/apache/karaf/eik/ui/project/NewKarafProjectOperation.java =================================================================== --- plugins/org.apache.karaf.eik.ui/src/main/java/org/apache/karaf/eik/ui/project/NewKarafProjectOperation.java (revision 1541491) +++ plugins/org.apache.karaf.eik.ui/src/main/java/org/apache/karaf/eik/ui/project/NewKarafProjectOperation.java (working copy) @@ -18,14 +18,12 @@ */ 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 +34,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 { @@ -74,9 +69,9 @@ monitor.worked(1); createKarafPlatformResources(monitor); - + monitor.worked(1); - + newKarafProject.getProjectHandle().refreshLocal(2, monitor); monitor.done(); @@ -119,16 +114,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 { Index: plugins/org.apache.karaf.eik.ui/src/main/java/org/apache/karaf/eik/ui/workbench/internal/GenericKarafWorkbenchService.java =================================================================== --- plugins/org.apache.karaf.eik.ui/src/main/java/org/apache/karaf/eik/ui/workbench/internal/GenericKarafWorkbenchService.java (revision 1541491) +++ plugins/org.apache.karaf.eik.ui/src/main/java/org/apache/karaf/eik/ui/workbench/internal/GenericKarafWorkbenchService.java (working copy) @@ -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; Index: plugins/org.apache.karaf.eik.ui/src/main/java/org/apache/karaf/eik/ui/internal/KarafLaunchUtils.java =================================================================== --- plugins/org.apache.karaf.eik.ui/src/main/java/org/apache/karaf/eik/ui/internal/KarafLaunchUtils.java (revision 1541491) +++ plugins/org.apache.karaf.eik.ui/src/main/java/org/apache/karaf/eik/ui/internal/KarafLaunchUtils.java (working copy) @@ -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 getBundleContainers(final KarafPlatformModel karafPlatformModel) { + public static List getBundleContainers(final KarafPlatformModel karafPlatformModel) { final Collection directories = KarafLaunchUtils.getJarDirectories(karafPlatformModel); - final List bundleContainers = new ArrayList(); + final List bundleContainers = new ArrayList(); for (final File dir : directories) { bundleContainers.add(new DirectoryBundleContainer(dir.getAbsolutePath())); } Index: plugins/org.apache.karaf.eik.ui/src/main/java/org/apache/karaf/eik/ui/features/MvnUrlConverter.java =================================================================== --- plugins/org.apache.karaf.eik.ui/src/main/java/org/apache/karaf/eik/ui/features/MvnUrlConverter.java (revision 0) +++ plugins/org.apache.karaf.eik.ui/src/main/java/org/apache/karaf/eik/ui/features/MvnUrlConverter.java (revision 0) @@ -0,0 +1,27 @@ +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; + } + +} Index: plugins/org.apache.karaf.eik.ui/src/main/java/org/apache/karaf/eik/ui/features/FeaturesResolverJob.java =================================================================== --- plugins/org.apache.karaf.eik.ui/src/main/java/org/apache/karaf/eik/ui/features/FeaturesResolverJob.java (revision 1541491) +++ plugins/org.apache.karaf.eik.ui/src/main/java/org/apache/karaf/eik/ui/features/FeaturesResolverJob.java (working copy) @@ -119,9 +119,10 @@ 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; final InputStream stream; if (repository.startsWith(FeaturesLabelProvider.MVN_URL_PREFIX)) { @@ -168,4 +169,26 @@ } } + 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), ","); + } + } \ No newline at end of file Index: plugins/org.apache.karaf.eik.ui/src/main/java/org/apache/karaf/eik/ui/features/FeaturesBundlesStartLevels.java =================================================================== --- plugins/org.apache.karaf.eik.ui/src/main/java/org/apache/karaf/eik/ui/features/FeaturesBundlesStartLevels.java (revision 0) +++ plugins/org.apache.karaf.eik.ui/src/main/java/org/apache/karaf/eik/ui/features/FeaturesBundlesStartLevels.java (revision 0) @@ -0,0 +1,86 @@ +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 symbolicNameToStartLevel; + private final MvnUrlConverter converter; + + private KarafPlatformModel karafPlatformModel; + private String baseBundlesDir; + + public FeaturesBundlesStartLevels(IKarafProject karafProject) { + this.karafProject = karafProject; + this.symbolicNameToStartLevel = new HashMap(); + 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 featuresRepositories = job.getFeaturesRepositories(); + for (FeaturesRepository featuresRepository : featuresRepositories) { + List features = featuresRepository.getFeatures().getFeatures(); + for (Feature feature : features) { + String featureStartLevel = feature.getStartLevel(); + List 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; + } + } +} Index: parent/pom.xml =================================================================== --- parent/pom.xml (revision 1541491) +++ parent/pom.xml (working copy) @@ -35,7 +35,7 @@ Apache Karaf :: EIK :: Parent - helios + juno http://download.eclipse.org/releases/${platform-version-name} http://download.eclipse.org/tools/mylyn/update/weekly http://download.eclipse.org/technology/swtbot/${platform-version-name}/dev-build/update-site @@ -45,6 +45,7 @@ 1.0.0 3.2.1 2.6 + 1.0 1.7 2.0.1 1.2.8 Index: pom.xml =================================================================== --- pom.xml (revision 1541491) +++ pom.xml (working copy) @@ -45,6 +45,7 @@ plugins/org.apache.aries.jmx.core plugins/org.apache.commons.collections plugins/org.apache.commons.lang + plugins/jdom plugins/org.apache.mina.core plugins/org.apache.sshd.core plugins/org.fusesource.jansi