Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for karaf 4.0.x #4

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@ target
.idea
*.i??
.classpath
.project
.project
.settings
*.jar
5 changes: 0 additions & 5 deletions plugins/org.apache.karaf.eik.core/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,6 @@
point="org.apache.karaf.eik.core.platformModel">
<model
class="org.apache.karaf.eik.core.internal.GenericKarafPlatformModelFactory">
<triggerBundle
symbolicName="org.apache.karaf.main"></triggerBundle>
<triggerBundle
symbolicName="org.apache.felix.karaf.jaas.boot">
</triggerBundle>
<triggerBundle
symbolicName="org.apache.karaf.main">
</triggerBundle>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@
*/
package org.apache.karaf.eik.core.internal;

import java.io.File;
import java.io.FilenameFilter;
import java.nio.file.Paths;

import org.apache.karaf.eik.core.KarafPlatformValidator;

import org.eclipse.core.runtime.IPath;
Expand All @@ -26,21 +30,31 @@ public class GenericKarafPlatformValidator implements KarafPlatformValidator {

public boolean isValid(IPath rootPath) {
final IPath karafJar = rootPath.append("/lib/karaf.jar");
final IPath bootDir = rootPath.append("/lib/boot");

final IPath systemDir = rootPath.append("/system");
final IPath confDir = rootPath.append("/etc");

// First level is the Karaf JARs in the lib directory
if (karafJar.toFile().exists()) {
return true;
if (karafJar.toFile().exists()) { // karaf 3.X
return true;
}
if (bootDir.toFile().isDirectory()) { // karaf 4.X
String[] karafLibs = bootDir.toFile().list(new FilenameFilter() {
@Override
public boolean accept(File dir, String name) {
return name.startsWith("org.apache.karaf.main");
}
});
return karafLibs.length > 0;
}

/*
* Second level is the directory structure with the features system
* configuration files.
*/
if(systemDir.toFile().isDirectory() && confDir.toFile().isDirectory()) {
final IPath karafFeatures = confDir.append("/org.apache.felix.karaf.features.cfg");
final IPath karafFeatures = confDir.append("/org.apache.karaf.features.cfg");

if(karafFeatures.toFile().exists()) {
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ public Object getAdapter(@SuppressWarnings("rawtypes") final Class adapterType)
public List<String> getBootClasspath() {
final List<File> jarFiles = new ArrayList<File>();
KarafCorePluginUtils.getJarFileList(rootPlatformPath.append("lib").toFile(), jarFiles, 0);
KarafCorePluginUtils.getJarFileList(rootPlatformPath.append("lib").append("boot").toFile(), jarFiles, 0);

final List<String> bootClasspath = new ArrayList<String>();
for(final File f : jarFiles) {
Expand Down
1 change: 1 addition & 0 deletions plugins/org.apache.karaf.eik.ui/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Require-Bundle: org.eclipse.ant.core;bundle-version="3.2.201",
org.apache.karaf.eik.core;bundle-version="[3.0.0,4.0.0)"
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Export-Package: org.apache.karaf.eik.ui,
org.apache.karaf.eik.ui.project,
org.apache.karaf.eik.ui.wizards,
org.apache.karaf.eik.ui.workbench
Bundle-ActivationPolicy: lazy
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,12 @@ private IStatus resolveFeatures(final IProgressMonitor monitor) {
final Properties runtimeProperties = karafProject.getRuntimeProperties();

PropertyUtils.interpolateVariables(mvnConfiguration, runtimeProperties);

final String defaultRepos = (String) mvnConfiguration.get("org.ops4j.pax.url.mvn.defaultRepositories");
final String repos = (String) mvnConfiguration.get("org.ops4j.pax.url.mvn.repositories");

// Remove whitespaces in lists as these lead to errors in OPS4j
final String defaultRepos = ((String) mvnConfiguration.get("org.ops4j.pax.url.mvn.defaultRepositories")); //.replaceAll("\\s+", "");
mvnConfiguration.setProperty("org.ops4j.pax.url.mvn.defaultRepositories", defaultRepos);
final String repos = ((String) mvnConfiguration.get("org.ops4j.pax.url.mvn.repositories")); //.replaceAll("\\s+", "");
mvnConfiguration.setProperty("org.ops4j.pax.url.mvn.repositories", repos);

// In karaf-3.0.0, default repo may be null.
// First check if it's null an if not then add it to repo list
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ public static Collection<File> getJarDirectories(final KarafPlatformModel karafP
// Add the lib directory for completeness, if the developer is pulling a
// target platform they better know what the are doing
directories.add(karafPlatformModel.getRootDirectory().append("lib").toFile()); // $NON-NLS-1$
directories.add(karafPlatformModel.getRootDirectory().append("lib").append("boot").toFile()); // $NON-NLS-1$

return directories;
}
Expand Down