Skip to content

Commit

Permalink
[all] Fixing the Janus library definition.
Browse files Browse the repository at this point in the history
The Janus library definition must be of type K_APPLICATION, not a
K_SYSTE, in order to be included into the run-time classpath.

close #521

Signed-off-by: Stéphane Galland <galland@arakhne.org>
  • Loading branch information
gallandarakhneorg committed Oct 27, 2016
1 parent 172faff commit 55ab308
Show file tree
Hide file tree
Showing 16 changed files with 127 additions and 80 deletions.
Expand Up @@ -108,11 +108,6 @@ public synchronized void reset() {
this.entries = null;
}

@Override
public int getKind() {
return K_SYSTEM;
}

@Override
public IPath getPath() {
return this.containerPath;
Expand Down
Expand Up @@ -31,6 +31,9 @@
import io.sarl.eclipse.util.BundleUtil;

/** Classpath container dedicated to the SARL environment.
*
* <p>The SARL classpath container is a system library, i.e. it will not be included into the run-time
* classpath.
*
* @author $Author: sgalland$
* @version $FullVersion$
Expand All @@ -55,6 +58,11 @@ public SARLClasspathContainer(IPath containerPath) {
super(containerPath);
}

@Override
public int getKind() {
return K_SYSTEM;
}

@Override
protected void updateBundleList(Set<String> entries) {
for (final String rootBundleName : SARL_ROOT_BUNDLE_NAMES) {
Expand Down
Expand Up @@ -21,6 +21,8 @@

package io.sarl.eclipse.buildpath;

import java.text.MessageFormat;

import org.eclipse.jdt.core.IClasspathEntry;
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.internal.ui.JavaPluginImages;
Expand Down Expand Up @@ -58,7 +60,12 @@ public void createControl(Composite parent) {
final Composite composite = new Composite(parent, SWT.NONE);
composite.setLayout(new FillLayout());
final Label label = new Label(composite, SWT.NONE);
label.setText(Messages.SARLContainerWizardPage_1);
final StringBuilder text = new StringBuilder();
for (final String entry : SARLClasspathContainer.SARL_ROOT_BUNDLE_NAMES) {
text.append(entry);
text.append("\n"); //$NON-NLS-1$
}
label.setText(MessageFormat.format(Messages.SARLContainerWizardPage_1, text.toString()));
setControl(composite);
}

Expand Down
@@ -1,4 +1,10 @@
SARLClasspathContainer_0=SARL Libraries
SARLClasspathContainerInitializer_0=Classpath container update
SARLContainerWizardPage_0=This read-only container manages the SARL dependencies.
SARLContainerWizardPage_1=This library provides all required and convenient dependencies for SARL projects.
SARLContainerWizardPage_1=\
This library provides all required and convenient\n\
libraries for compiling SARL projects.\n\n\
The major included libraries are:\n\
{0}\n\n\
Other libraries may be included according to the dependency\n\
hierarchy of the libraries above.
Expand Up @@ -23,7 +23,6 @@

import java.io.File;
import java.io.IOException;
import java.lang.ref.SoftReference;
import java.net.MalformedURLException;
import java.net.URISyntaxException;
import java.net.URL;
Expand Down Expand Up @@ -102,9 +101,6 @@ public final class BundleUtil {

private static final String DEFAULT_PATH_TO_CLASSES_IN_MAVEN_PROJECT = "target/classes"; //$NON-NLS-1$

private static SoftReference<Map<Bundle, Pair<Version, List<BundleDependency>>>> bundleDependencies =
new SoftReference<>(null);

private BundleUtil() {
//
}
Expand Down Expand Up @@ -234,54 +230,6 @@ public static IPath getJavadocBundlePath(Bundle bundle, IPath bundleLocation) {
return sourcesPath;
}

private static Map<Bundle, Pair<Version, List<BundleDependency>>> getBundleDependencies() {
Map<Bundle, Pair<Version, List<BundleDependency>>> repository = bundleDependencies.get();
if (repository == null) {
repository = new TreeMap<>(new Comparator<Bundle>() {
@Override
public int compare(Bundle o1, Bundle o2) {
return o1.getSymbolicName().compareTo(o2.getSymbolicName());
}
});
bundleDependencies = new SoftReference<>(repository);
}
return repository;
}

private static Pair<Version, List<BundleDependency>> getBundleDependencies(Bundle bundle) {
final Map<Bundle, Pair<Version, List<BundleDependency>>> repository = getBundleDependencies();
synchronized (repository) {
return repository.get(bundle);
}
}

private static void setBundleDependencies(Bundle bundle, List<BundleDependency> cpEntries) {
final Map<Bundle, Pair<Version, List<BundleDependency>>> repository = getBundleDependencies();
synchronized (repository) {
repository.put(bundle, new Pair<>(bundle.getVersion(), cpEntries));
}
}

private static void addToBundleDependencies(Bundle bundle, BundleDependency dependency) {
final Map<Bundle, Pair<Version, List<BundleDependency>>> repository = getBundleDependencies();
synchronized (repository) {
final Pair<Version, List<BundleDependency>> pair = repository.get(bundle);
if (pair == null || pair.getValue() == null) {
final List<BundleDependency> cpEntries = new ArrayList<>();
cpEntries.add(dependency);
repository.put(bundle, new Pair<>(bundle.getVersion(), cpEntries));
} else {
pair.getValue().add(dependency);
}
}
}

/** Clear any cached information by the {@link BundleUtil} functions.
*/
public static void clearCaches() {
bundleDependencies.clear();
}

/** Replies the dependencies for the given bundle.
*
* @param bundle the bundle.
Expand Down Expand Up @@ -488,6 +436,8 @@ private static class BundleDependencies implements IBundleDependencies {

private IPath binaryBundlePath;

private Map<Bundle, Pair<Version, List<BundleDependency>>> bundleDependencies;

/** Constructor.
*
* @param bundle the bundle.
Expand All @@ -503,6 +453,46 @@ private static class BundleDependencies implements IBundleDependencies {
this.javadocURLs = javadocURLs;
}

private Map<Bundle, Pair<Version, List<BundleDependency>>> getBundleDependencies() {
if (this.bundleDependencies == null) {
this.bundleDependencies = new TreeMap<>(new Comparator<Bundle>() {
@Override
public int compare(Bundle o1, Bundle o2) {
return o1.getSymbolicName().compareTo(o2.getSymbolicName());
}
});
}
return this.bundleDependencies;
}

private Pair<Version, List<BundleDependency>> getBundleDependencies(Bundle bundle) {
final Map<Bundle, Pair<Version, List<BundleDependency>>> repository = getBundleDependencies();
synchronized (repository) {
return repository.get(bundle);
}
}

private void setBundleDependencies(Bundle bundle, List<BundleDependency> cpEntries) {
final Map<Bundle, Pair<Version, List<BundleDependency>>> repository = getBundleDependencies();
synchronized (repository) {
repository.put(bundle, new Pair<>(bundle.getVersion(), cpEntries));
}
}

private void addToBundleDependencies(Bundle bundle, BundleDependency dependency) {
final Map<Bundle, Pair<Version, List<BundleDependency>>> repository = getBundleDependencies();
synchronized (repository) {
final Pair<Version, List<BundleDependency>> pair = repository.get(bundle);
if (pair == null || pair.getValue() == null) {
final List<BundleDependency> cpEntries = new ArrayList<>();
cpEntries.add(dependency);
repository.put(bundle, new Pair<>(bundle.getVersion(), cpEntries));
} else {
pair.getValue().add(dependency);
}
}
}

@Override
public String toString() {
final StringBuilder buf = new StringBuilder();
Expand All @@ -518,8 +508,7 @@ public String toString() {
return buf.toString();
}

@SuppressWarnings("synthetic-access")
private static void toDependencyTree(StringBuilder builder, String indent1, String indent2, Bundle current,
private void toDependencyTree(StringBuilder builder, String indent1, String indent2, Bundle current,
boolean isFragment, List<BundleDependency> dependencies) {
builder.append(indent1);
builder.append(current.getSymbolicName());
Expand Down Expand Up @@ -581,7 +570,6 @@ public Iterable<IRuntimeClasspathEntry> getTransitiveRuntimeClasspathEntries(boo
return () -> new RuntimeClasspathEntryIterator(getTransitiveDependencies(includeFragments));
}

@SuppressWarnings("synthetic-access")
private Pair<Version, List<BundleDependency>> getDependencyDefinition() {
Pair<Version, List<BundleDependency>> dependencies = getBundleDependencies(this.bundle);
if (dependencies == null) {
Expand Down Expand Up @@ -687,7 +675,7 @@ private static BundleDependency updateBundleClassPath(Bundle bundle, IClasspathE
* boolean specifying if we are at the first recursive call, in this case we use the {@link #directDependencies}
* collections to filter the dependencies that are really useful.
*/
@SuppressWarnings({ "checkstyle:nestedifdepth", "synthetic-access" })
@SuppressWarnings({"checkstyle:nestedifdepth"})
private void extractAllBundleDependencies(Bundle bundle, boolean firstCall) {
final BundleWiring bundleWiring = bundle.adapt(BundleWiring.class);
final List<BundleWire> bundleWires = bundleWiring.getRequiredWires(null);
Expand Down Expand Up @@ -736,7 +724,7 @@ private void extractAllBundleDependencies(Bundle bundle, boolean firstCall) {
* @param bundleInstallURL the URL where the specified bundle is stored
* @return the Path to the output folder used to store .class file if any (if we are in an eclipse project (debug mode))
*/
@SuppressWarnings({"synthetic-access", "checkstyle:cyclomaticcomplexity"})
@SuppressWarnings("checkstyle:cyclomaticcomplexity")
private IPath readDotClasspathAndReferencestoClasspath(Bundle parent, Bundle bundle, URL bundleInstallURL) {
IPath outputLocation = null;
BundleDependency mainDependency = null;
Expand Down Expand Up @@ -939,7 +927,7 @@ public IRuntimeClasspathEntry next() {
* @mavengroupid $GroupId$
* @mavenartifactid $ArtifactId$
*/
private static class TransitiveDependencyIterator implements Iterator<BundleDependency> {
private class TransitiveDependencyIterator implements Iterator<BundleDependency> {

private final boolean includeFragments;

Expand Down
Expand Up @@ -23,7 +23,6 @@

import com.google.common.base.Strings;
import org.eclipse.core.runtime.IPath;
import org.eclipse.jdt.core.IAccessRule;
import org.eclipse.jdt.core.IClasspathAttribute;
import org.eclipse.jdt.core.IClasspathEntry;
import org.eclipse.jdt.core.IType;
Expand Down Expand Up @@ -215,7 +214,7 @@ public static IClasspathEntry newLibraryEntry(Bundle bundle, IPath precomputedBu
bundlePath,
sourceBundlePath,
null,
new IAccessRule[] {},
null,
extraAttributes,
false);
}
Expand Down
Expand Up @@ -13,16 +13,14 @@ Require-Bundle: io.sarl.core;bundle-version="0.5.0",
com.google.inject;bundle-version="4.0.0",
org.apache.commons.cli;bundle-version="1.3.1",
org.eclipse.jdt.core;bundle-version="3.12.1",
org.eclipse.jdt.launching;bundle-version="3.8.100",
org.eclipse.core.runtime;bundle-version="3.12.0",
org.eclipse.ui.workbench;bundle-version="3.108.1",
org.eclipse.core.resources;bundle-version="3.11.0",
org.eclipse.jdt.ui;bundle-version="3.12.1",
org.eclipse.swt;bundle-version="3.105.1",
org.eclipse.jface;bundle-version="3.12.0",
org.arakhne.afc.core.util;bundle-version="14.0.0",
org.arakhne.afc.core.vmutils;bundle-version="14.0.0",
aopalliance;bundle-version="1.0.0"
org.arakhne.afc.core.util;bundle-version="14.0.0",
org.eclipse.swt;bundle-version="3.105.1",
org.eclipse.jdt.launching;bundle-version="3.8.100"
Bundle-Activator: io.janusproject.eclipse.JanusEclipsePlugin
Bundle-ActivationPolicy: lazy
Bundle-Vendor: %Bundle-Vendor
Expand Down
Expand Up @@ -35,6 +35,7 @@
import java.util.Properties;
import java.util.UUID;
import java.util.logging.Logger;
import java.util.regex.Pattern;

import com.google.common.base.Strings;
import com.google.inject.Module;
Expand Down Expand Up @@ -181,6 +182,10 @@ public final class Boot {
*/
public static final String CLI_OPTION_SHOWDEFAULTS_LONG = "showdefaults"; //$NON-NLS-1$

/** Short command-line option for "show the classpath".
*/
public static final String CLI_OPTION_SHOWCLASSPATH = "showclasspath"; //$NON-NLS-1$

/** Short command-line option for "show CLI arguments".
*/
public static final String CLI_OPTION_SHOWCLIARGUMENTS_LONG = "cli"; //$NON-NLS-1$
Expand Down Expand Up @@ -227,6 +232,9 @@ public static String[] parseCommandLine(String[] args) {
case CLI_OPTION_SHOWDEFAULTS_LONG:
showDefaults();
return null;
case CLI_OPTION_SHOWCLASSPATH:
showClasspath();
return null;
case CLI_OPTION_SHOWCLIARGUMENTS_LONG:
showCommandLineArguments(args);
return null;
Expand Down Expand Up @@ -433,6 +441,9 @@ public static Options getOptions() {
options.addOption(CLI_OPTION_SHOWDEFAULTS_SHORT, CLI_OPTION_SHOWDEFAULTS_LONG, false,
Messages.Boot_13);

options.addOption(CLI_OPTION_SHOWCLASSPATH, false,
Messages.Boot_23);

options.addOption(null, CLI_OPTION_SHOWCLIARGUMENTS_LONG, false,
Messages.Boot_14);

Expand Down Expand Up @@ -525,6 +536,22 @@ public static void showDefaults() {
getExiter().exit();
}

/**
* Show the classpath of the system properties. This function never returns.
*/
@SuppressWarnings({ "checkstyle:regexp", "resource" })
public static void showClasspath() {
final String cp = System.getProperty("java.class.path"); //$NON-NLS-1$
if (!Strings.isNullOrEmpty(cp)) {
final PrintStream ps = getConsoleLogger();
for (final String entry : cp.split(Pattern.quote(File.pathSeparator))) {
ps.println(entry);
}
ps.flush();
}
getExiter().exit();
}

/**
* Show the command line arguments. This function never returns.
*
Expand Down
Expand Up @@ -49,6 +49,7 @@ public class Messages extends NLS {
public static String Boot_20;
public static String Boot_21;
public static String Boot_22;
public static String Boot_23;
public static String Boot_3;
public static String Boot_4;
public static String Boot_5;
Expand Down
Expand Up @@ -36,6 +36,8 @@
import io.sarl.eclipse.util.Utilities.SARLBundleJavadocURLMappings;

/** Classpath container dedicated to the Janus platform.
*
* <p>The Janus classpath library is an application library, i.e. it is included into the run-time classpath.
*
* @author $Author: sgalland$
* @version $FullVersion$
Expand Down Expand Up @@ -75,6 +77,11 @@ public JanusClasspathContainer(IPath containerPath) {
super(containerPath);
}

@Override
public int getKind() {
return K_APPLICATION;
}

/** Replies the standard classpath for running the Janus platform.
*
* @return the classpath.
Expand Down
Expand Up @@ -21,6 +21,8 @@

package io.janusproject.eclipse.buildpath;

import java.text.MessageFormat;

import org.eclipse.jdt.core.IClasspathEntry;
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.internal.ui.JavaPluginImages;
Expand Down Expand Up @@ -58,7 +60,12 @@ public void createControl(Composite parent) {
final Composite composite = new Composite(parent, SWT.NONE);
composite.setLayout(new FillLayout());
final Label label = new Label(composite, SWT.NONE);
label.setText(Messages.JanusContainerWizardPage_1);
final StringBuilder text = new StringBuilder();
for (final String entry : JanusClasspathContainer.JANUS_ROOT_BUNDLE_NAMES) {
text.append(entry);
text.append("\n"); //$NON-NLS-1$
}
label.setText(MessageFormat.format(Messages.JanusContainerWizardPage_1, text.toString()));
setControl(composite);
}

Expand Down

0 comments on commit 55ab308

Please sign in to comment.