Skip to content

Commit

Permalink
[maven] Remove reference to Arakhne libraries within sarl-maven-plugin.
Browse files Browse the repository at this point in the history
Signed-off-by: Stéphane Galland <galland@arakhne.org>
  • Loading branch information
gallandarakhneorg committed Oct 24, 2017
1 parent 5d3c087 commit 1379ec8
Show file tree
Hide file tree
Showing 15 changed files with 157 additions and 96 deletions.
4 changes: 0 additions & 4 deletions main/internalmaven/sarl-maven-plugin/pom.xml
Expand Up @@ -35,10 +35,6 @@
<artifactId>maven-core</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.arakhne.afc.core</groupId>
<artifactId>vmutils</artifactId>
</dependency>
<dependency>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
Expand Down
Expand Up @@ -25,6 +25,7 @@
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedHashSet;
Expand All @@ -51,7 +52,6 @@
import org.apache.maven.toolchain.ToolchainManager;
import org.apache.maven.toolchain.ToolchainPrivate;
import org.apache.maven.toolchain.java.JavaToolchain;
import org.arakhne.afc.vmutil.locale.Locale;
import org.codehaus.plexus.util.xml.Xpp3Dom;
import org.eclipse.xtext.xbase.lib.util.ReflectExtensions;

Expand Down Expand Up @@ -92,7 +92,7 @@ public void prepareExecution() throws MojoExecutionException {
this.reflect = this.injector.getInstance(ReflectExtensions.class);
}
if (this.sarlBatchCompilerProvider == null || this.reflect == null) {
throw new MojoExecutionException(Locale.getString(AbstractSarlBatchCompilerMojo.class, "INJECTION_ERROR")); //$NON-NLS-1$
throw new MojoExecutionException(Messages.AbstractSarlBatchCompilerMojo_0);
}
}

Expand Down Expand Up @@ -169,7 +169,7 @@ protected void compile(List<File> classPath, List<File> sourcePaths, File output
final Iterable<File> filtered = Iterables.filter(sourcePaths, (input) -> input.isDirectory());
if (Iterables.isEmpty(filtered)) {
final String dir = Iterables.toString(sourcePaths);
getLog().info(Locale.getString(AbstractSarlBatchCompilerMojo.class, "ERROR_0", dir)); //$NON-NLS-1$
getLog().info(MessageFormat.format(Messages.AbstractSarlBatchCompilerMojo_1, dir));
return;
}
final String baseDir = project.getBasedir().getAbsolutePath();
Expand Down Expand Up @@ -197,9 +197,9 @@ protected void compile(List<File> classPath, List<File> sourcePaths, File output
if (uriToProblem != null) {
filename = uriToProblem.toFileString();
} else {
filename = Locale.getString(AbstractSarlBatchCompilerMojo.class, "NO_FILE_NAME"); //$NON-NLS-1$
filename = Messages.AbstractSarlBatchCompilerMojo_2;
}
return Locale.getString(AbstractSarlBatchCompilerMojo.class, "ISSUE_MESSAGE", //$NON-NLS-1$
return MessageFormat.format(Messages.AbstractSarlBatchCompilerMojo_3,
filename, issue.getLineNumber(),
issue.getColumn(), issue.getMessage());
});
Expand All @@ -211,7 +211,7 @@ protected void compile(List<File> classPath, List<File> sourcePaths, File output
}
dir.append(file.getAbsolutePath());
}
throw new MojoFailureException(Locale.getString(AbstractSarlBatchCompilerMojo.class, "ERROR_1")); //$NON-NLS-1$
throw new MojoFailureException(Messages.AbstractSarlBatchCompilerMojo_4);
}
}

Expand All @@ -220,7 +220,7 @@ private String getBootClassPath() throws MojoExecutionException {
if (toolchain instanceof JavaToolchain && toolchain instanceof ToolchainPrivate) {
final JavaToolchain javaToolChain = (JavaToolchain) toolchain;
final ToolchainPrivate privateJavaToolChain = (ToolchainPrivate) toolchain;
getLog().info(Locale.getString(AbstractSarlBatchCompilerMojo.class, "USING_TOOLCHAIN", javaToolChain)); //$NON-NLS-1$
getLog().info(MessageFormat.format(Messages.AbstractSarlBatchCompilerMojo_5, javaToolChain));

String[] includes = {"jre/lib/*", "jre/lib/ext/*", "jre/lib/endorsed/*"}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
String[] excludes = new String[0];
Expand Down Expand Up @@ -249,7 +249,7 @@ private String getBootClassPath() throws MojoExecutionException {
}

private String scanBootclasspath(String javaHome, String[] includes, String[] excludes) {
getLog().debug(Locale.getString(AbstractSarlBatchCompilerMojo.class, "BOOTCLASSPATH", //$NON-NLS-1$
getLog().debug(MessageFormat.format(Messages.AbstractSarlBatchCompilerMojo_6,
javaHome, Arrays.toString(includes), Arrays.toString(excludes)));
final DirectoryScanner scanner = new DirectoryScanner();
scanner.setBasedir(new File(javaHome));
Expand Down Expand Up @@ -297,11 +297,11 @@ protected String readSarlEclipseSetting(String sourceDirectory) {
final String sarlOutputDirProp = sarlSettings.getProperty("outlet.DEFAULT_OUTPUT.directory", null); //$NON-NLS-1$
if (sarlOutputDirProp != null) {
final File srcDir = new File(sourceDirectory);
getLog().debug(Locale.getString(AbstractSarlBatchCompilerMojo.class, "SOURCE_DIR", //$NON-NLS-1$
getLog().debug(MessageFormat.format(Messages.AbstractSarlBatchCompilerMojo_7,
srcDir.getPath(), srcDir.exists()));
if (srcDir.exists() && srcDir.getParent() != null) {
final String path = new File(srcDir.getParent(), sarlOutputDirProp).getPath();
getLog().debug(Locale.getString(AbstractSarlBatchCompilerMojo.class, "APPLY_PROPERTY", sarlOutputDirProp)); //$NON-NLS-1$
getLog().debug(MessageFormat.format(Messages.AbstractSarlBatchCompilerMojo_8, sarlOutputDirProp));
return path;
}
}
Expand All @@ -311,7 +311,7 @@ protected String readSarlEclipseSetting(String sourceDirectory) {
getLog().warn(e);
}
} else {
getLog().debug(Locale.getString(AbstractSarlBatchCompilerMojo.class, "ERROR_2", this.propertiesFileLocation)); //$NON-NLS-1$
getLog().debug(MessageFormat.format(Messages.AbstractSarlBatchCompilerMojo_9, this.propertiesFileLocation));
}
}
return null;
Expand Down Expand Up @@ -341,7 +341,7 @@ protected List<File> getClassPath() throws MojoExecutionException {
if (file.exists()) {
files.add(file);
} else {
getLog().warn(Locale.getString(AbstractSarlBatchCompilerMojo.class, "ERROR_3", filename)); //$NON-NLS-1$
getLog().warn(MessageFormat.format(Messages.AbstractSarlBatchCompilerMojo_10, filename));
}
}
return files;
Expand Down
Expand Up @@ -24,6 +24,7 @@
import java.io.File;
import java.io.IOException;
import java.io.StringReader;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
Expand All @@ -46,7 +47,6 @@
import org.apache.maven.plugins.annotations.Component;
import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.repository.RepositorySystem;
import org.arakhne.afc.vmutil.locale.Locale;
import org.codehaus.plexus.configuration.PlexusConfiguration;
import org.codehaus.plexus.configuration.PlexusConfigurationException;
import org.codehaus.plexus.util.xml.Xpp3Dom;
Expand Down Expand Up @@ -238,17 +238,15 @@ protected void executeMojo(
plugin.setVersion(version);
plugin.setDependencies(Arrays.asList(dependencies));

getLog().debug(Locale.getString(AbstractSarlMojo.class, "LAUNCHING", plugin.getId())); //$NON-NLS-1$
getLog().debug(MessageFormat.format(Messages.AbstractSarlMojo_0, plugin.getId()));

final PluginDescriptor pluginDescriptor = this.mavenHelper.loadPlugin(plugin);
if (pluginDescriptor == null) {
throw new MojoExecutionException(Locale.getString(AbstractSarlMojo.class,
"PLUGIN_NOT_FOUND", plugin.getId())); //$NON-NLS-1$
throw new MojoExecutionException(MessageFormat.format(Messages.AbstractSarlMojo_1, plugin.getId()));
}
final MojoDescriptor mojoDescriptor = pluginDescriptor.getMojo(goal);
if (mojoDescriptor == null) {
throw new MojoExecutionException(Locale.getString(AbstractSarlMojo.class,
"GOAL_NOT_FOUND", goal)); //$NON-NLS-1$
throw new MojoExecutionException(MessageFormat.format(Messages.AbstractSarlMojo_2, goal));
}

final Xpp3Dom mojoXml;
Expand All @@ -275,8 +273,7 @@ protected void executeMojo(
configurationXml = mojoXml;
}

getLog().debug(Locale.getString(AbstractSarlMojo.class, "CONFIGURATION_FOR", //$NON-NLS-1$
plugin.getId(), configurationXml.toString()));
getLog().debug(MessageFormat.format(Messages.AbstractSarlMojo_3, plugin.getId(), configurationXml.toString()));

final MojoExecution execution = new MojoExecution(mojoDescriptor, configurationXml);

Expand Down Expand Up @@ -321,8 +318,8 @@ protected Dependency[] getDependenciesFor(String configurationKeyPrefix) throws
final String dependencyKey = ArtifactUtils.versionlessKey(dependencyGroupId, dependencyArtifactId);
final Dependency dependencyObject = pomDependencies.get(dependencyKey);
if (dependencyObject == null) {
throw new MojoExecutionException(Locale.getString(AbstractSarlMojo.class,
"ARTIFACT_NOT_FOUND", dependencyKey)); //$NON-NLS-1$
throw new MojoExecutionException(MessageFormat.format(
Messages.AbstractSarlMojo_4, dependencyKey));
}
dependencies.add(dependencyObject);
}
Expand Down
Expand Up @@ -23,6 +23,7 @@

import java.io.File;
import java.nio.charset.Charset;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
Expand All @@ -45,7 +46,6 @@
import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.plugins.annotations.ResolutionScope;
import org.apache.maven.project.MavenProject;
import org.arakhne.afc.vmutil.locale.Locale;

import io.sarl.lang.SARLVersion;

Expand Down Expand Up @@ -195,14 +195,12 @@ private void ensureSARLVersions() throws MojoExecutionException, MojoFailureExce
compilerVersion.getMajorVersion() + "." //$NON-NLS-1$
+ (compilerVersion.getMinorVersion() + 1)
+ ".0"); //$NON-NLS-1$
getLog().info(Locale.getString(CompileMojo.class, "CHECK_SARL_SDK", compilerVersionString, //$NON-NLS-1$
maxCompilerVersion));
getLog().info(MessageFormat.format(Messages.CompileMojo_0, compilerVersionString, maxCompilerVersion));
final StringBuilder classpath = new StringBuilder();
final Set<String> foundVersions = findSARLLibrary(compilerVersion, maxCompilerVersion, classpath,
this.tycho);
if (foundVersions.isEmpty()) {
throw new MojoFailureException(Locale.getString(CompileMojo.class, "NO_SARL_LIBRARY", //$NON-NLS-1$
classpath.toString()));
throw new MojoFailureException(MessageFormat.format(Messages.CompileMojo_1, classpath.toString()));
}
final StringBuilder versions = new StringBuilder();
for (final String version : foundVersions) {
Expand All @@ -212,9 +210,9 @@ private void ensureSARLVersions() throws MojoExecutionException, MojoFailureExce
versions.append(version);
}
if (foundVersions.size() > 1) {
getLog().info(Locale.getString(CompileMojo.class, "TOO_MUCH_SARL_VERSIONS", versions)); //$NON-NLS-1$
getLog().info(MessageFormat.format(Messages.CompileMojo_2, versions));
} else {
getLog().info(Locale.getString(CompileMojo.class, "DETECTED_SARL_VERSION", versions)); //$NON-NLS-1$
getLog().info(MessageFormat.format(Messages.CompileMojo_3, versions));
}
}

Expand All @@ -226,8 +224,7 @@ private Set<String> findSARLLibrary(ArtifactVersion compilerVersion, ArtifactVer
final String sarlLibArtifactIdTycho = this.mavenHelper.getConfig("sarl-lib.osgiBundleId"); //$NON-NLS-1$
final Set<String> foundVersions = new TreeSet<>();
for (final Artifact dep : this.mavenHelper.getSession().getCurrentProject().getArtifacts()) {
getLog().debug(Locale.getString(CompileMojo.class, "SCANNING_DEPENDENCY", //$NON-NLS-1$
dep.getGroupId(), dep.getArtifactId(), dep.getVersion()));
getLog().debug(MessageFormat.format(Messages.CompileMojo_4, dep.getGroupId(), dep.getArtifactId(), dep.getVersion()));
if (classpath.length() > 0) {
classpath.append(":"); //$NON-NLS-1$
}
Expand All @@ -247,12 +244,10 @@ private Set<String> findSARLLibrary(ArtifactVersion compilerVersion, ArtifactVer
if (gid != null && aid != null) {
final ArtifactVersion dependencyVersion = new DefaultArtifactVersion(dep.getVersion());
if (!containsVersion(dependencyVersion, compilerVersion, maxCompilerVersion)) {
final String shortMessage = Locale.getString(CompileMojo.class,
"INCOMPATIBLE_VERSION_SHORT", //$NON-NLS-1$
final String shortMessage = MessageFormat.format(Messages.CompileMojo_5,
gid, aid, dependencyVersion.toString(),
compilerVersion.toString(), maxCompilerVersion.toString());
final String longMessage = Locale.getString(CompileMojo.class,
"INCOMPATIBLE_VERSION_LONG", //$NON-NLS-1$
final String longMessage = MessageFormat.format(Messages.CompileMojo_6,
sarlLibGroupId, sarlLibArtifactId, dependencyVersion.toString(),
compilerVersion.toString(), maxCompilerVersion.toString());
throw new MojoFailureException(this, shortMessage, longMessage);
Expand All @@ -265,7 +260,7 @@ private Set<String> findSARLLibrary(ArtifactVersion compilerVersion, ArtifactVer

@SuppressWarnings("unchecked")
private void validateDependencyVersions() throws MojoExecutionException, MojoFailureException {
getLog().info(Locale.getString(CompileMojo.class, "CHECK_DEPENDENCY_VERSIONS")); //$NON-NLS-1$
getLog().info(Messages.CompileMojo_7);
final String sarlSdkGroupId = this.mavenHelper.getConfig("sarl-sdk.groupId"); //$NON-NLS-1$
final String sarlSdkArtifactId = this.mavenHelper.getConfig("sarl-sdk.artifactId"); //$NON-NLS-1$

Expand All @@ -291,8 +286,7 @@ private void validateDependencyVersions() throws MojoExecutionException, MojoFai
if (dependencyArtifact != null) {
final ArtifactVersion dependencyVersion = new DefaultArtifactVersion(dependencyArtifact.getVersion());
if (entry.getValue().compareTo(dependencyVersion) > 0) {
final String message = Locale.getString(CompileMojo.class,
"INVALID_SARL_SDK_DEPENDENCY_VERSION", //$NON-NLS-1$
final String message = MessageFormat.format(Messages.CompileMojo_8,
dependencyArtifact.getGroupId(), dependencyArtifact.getArtifactId(),
dependencyArtifact.getVersion(), entry.getValue().toString());
getLog().error(message);
Expand All @@ -303,14 +297,14 @@ private void validateDependencyVersions() throws MojoExecutionException, MojoFai
}

if (hasError) {
throw new MojoFailureException(Locale.getString(CompileMojo.class, "INVALID_SARL_SDK_DEPENDENCY_VERSION_TITLE")); //$NON-NLS-1$
throw new MojoFailureException(Messages.CompileMojo_10);
}
}

private void compileSARL() throws MojoExecutionException, MojoFailureException {
final Log log = getLog();
File outputDirectory = getOutput();
log.info(Locale.getString(CompileMojo.class, "COMPILING_SARL")); //$NON-NLS-1$
log.info(Messages.CompileMojo_9);
if (log.isDebugEnabled()) {
final StringBuilder properties = new StringBuilder();
buildPropertyString(properties);
Expand All @@ -321,7 +315,7 @@ private void compileSARL() throws MojoExecutionException, MojoFailureException {
final String settingsValue = readSarlEclipseSetting(getProject().getBuild().getSourceDirectory());
if (settingsValue != null && !settingsValue.isEmpty()) {
outputDirectory = new File(settingsValue);
getLog().info(Locale.getString(CompileMojo.class, "OUTPUT_DIR_UPDATE", outputDirectory)); //$NON-NLS-1$
getLog().info(MessageFormat.format(Messages.CompileMojo_11, outputDirectory));
}
}
final MavenProject project = getProject();
Expand Down
Expand Up @@ -22,13 +22,13 @@
package io.sarl.maven.compiler;

import java.io.File;
import java.text.MessageFormat;

import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.plugins.annotations.LifecyclePhase;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.ResolutionScope;
import org.arakhne.afc.vmutil.locale.Locale;

/** Initialization mojo for the SARL Maven compiler.
*
Expand All @@ -45,12 +45,12 @@ public class InitializeMojo extends AbstractSarlMojo {
protected void executeMojo() throws MojoExecutionException, MojoFailureException {
for (final File f : new File[] {getInput(), getOutput()}) {
final String absPath = f.getAbsolutePath();
getLog().info(Locale.getString(InitializeMojo.class, "ADD_SOURCE_FOLDERS", absPath)); //$NON-NLS-1$
getLog().info(MessageFormat.format(Messages.InitializeMojo_0, absPath));
this.mavenHelper.getSession().getCurrentProject().addCompileSourceRoot(absPath);
}
for (final File f : new File[] {getTestInput(), getTestOutput()}) {
final String absPath = f.getAbsolutePath();
getLog().info(Locale.getString(InitializeMojo.class, "ADD_TEST_SOURCE_FOLDERS", absPath)); //$NON-NLS-1$
getLog().info(MessageFormat.format(Messages.InitializeMojo_1, absPath));
this.mavenHelper.getSession().getCurrentProject().addTestCompileSourceRoot(absPath);
}
}
Expand Down
Expand Up @@ -23,6 +23,7 @@

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.text.MessageFormat;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
Expand Down Expand Up @@ -52,7 +53,6 @@
import org.apache.maven.plugin.descriptor.PluginDescriptor;
import org.apache.maven.plugin.logging.Log;
import org.apache.maven.repository.RepositorySystem;
import org.arakhne.afc.vmutil.locale.Locale;

/** This class permits to support the incompatible Maven API
* from the same Mojo code (says 3.0 and 3.1 APIs).
Expand Down Expand Up @@ -106,8 +106,7 @@ class MavenHelper {
}
}
if (method == null) {
throw new MojoExecutionException(Locale.getString(MavenHelper.class, "UNSUPPORTED_MAVEN_API"), //$NON-NLS-1$
new NoSuchMethodError("getRepositorySystem")); //$NON-NLS-1$
throw new MojoExecutionException(Messages.MavenHelper_0, new NoSuchMethodError("getRepositorySystem")); //$NON-NLS-1$
}
this.getRepositorySessionMethod = method;

Expand All @@ -119,8 +118,7 @@ class MavenHelper {
}
}
if (method == null) {
throw new MojoExecutionException(Locale.getString(MavenHelper.class, "UNSUPPORTED_MAVEN_API"), //$NON-NLS-1$
new NoSuchMethodError("loadPlugin")); //$NON-NLS-1$
throw new MojoExecutionException(Messages.MavenHelper_0, new NoSuchMethodError("loadPlugin")); //$NON-NLS-1$
}
this.loadPluginMethod = method;
}
Expand Down Expand Up @@ -160,8 +158,7 @@ public String getConfig(String key) throws MojoExecutionException {
String value = resource.getString(key);
if (value == null || value.isEmpty()) {
value = Strings.nullToEmpty(value);
this.log.warn(Locale.getString(MavenHelper.class,
"NO_CONFIGURATION_ENTRY", key)); //$NON-NLS-1$
this.log.warn(MessageFormat.format(Messages.MavenHelper_1, key));
}
return value;
}
Expand Down Expand Up @@ -307,11 +304,9 @@ public String getPluginDependencyVersion(String groupId, String artifactId) thro
if (version != null && !version.isEmpty()) {
return version;
}
throw new MojoExecutionException(Locale.getString(MavenHelper.class,
"UNKNOWN_PLUGIN_VERSION", key)); //$NON-NLS-1$
throw new MojoExecutionException(MessageFormat.format(Messages.MavenHelper_2, key));
}
throw new MojoExecutionException(Locale.getString(MavenHelper.class,
"PLUGIN_NOT_FOUND_IN_DEPS", key, deps)); //$NON-NLS-1$
throw new MojoExecutionException(MessageFormat.format(Messages.MavenHelper_3, key, deps));
}

}
Expand Up @@ -24,7 +24,6 @@
import java.util.Iterator;

import org.apache.maven.project.MavenProject;
import org.arakhne.afc.vmutil.locale.Locale;
import org.eclipse.emf.common.notify.Adapter;
import org.eclipse.emf.common.notify.impl.AdapterImpl;
import org.eclipse.emf.ecore.resource.ResourceSet;
Expand Down Expand Up @@ -55,7 +54,7 @@ public static MavenProject get(ResourceSet rs) {
return ((MavenProjectAdapter) a).project;
}
}
throw new RuntimeException(Locale.getString(MavenProjectAdapter.class, "INVALID_LINK")); //$NON-NLS-1$
throw new RuntimeException(Messages.MavenProjectAdapter_0);
}

/** Install the adapter.
Expand Down

0 comments on commit 1379ec8

Please sign in to comment.