Skip to content

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also .

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also .
...
  • 2 commits
  • 2 files changed
  • 0 commit comments
  • 2 contributors
Showing with 21 additions and 19 deletions.
  1. +2 −0 pom.xml
  2. +19 −19 src/main/java/com/sirrapa/maven/plugins/nodejs/NodeJsMojo.java
View
2 pom.xml
@@ -12,6 +12,8 @@
<version>0.8.15-001</version>
<packaging>maven-plugin</packaging>
<properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<pluginTestingVersion>2.1</pluginTestingVersion>
<mavenPluginPluginVersion>3.2</mavenPluginPluginVersion>
View
38 src/main/java/com/sirrapa/maven/plugins/nodejs/NodeJsMojo.java
@@ -18,13 +18,12 @@
import org.codehaus.plexus.util.cli.CommandLineException;
import org.codehaus.plexus.util.cli.CommandLineUtils;
import org.codehaus.plexus.util.cli.Commandline;
-import org.codehaus.plexus.util.cli.StreamConsumer;
/**
* Goal which runs Nodejs.
*/
@Mojo(name = "compile", requiresDependencyResolution = ResolutionScope.COMPILE,
- defaultPhase = LifecyclePhase.PROCESS_SOURCES, threadSafe = true)
+ defaultPhase = LifecyclePhase.PROCESS_SOURCES, threadSafe = true)
public class NodeJsMojo extends AbstractDependencyMojo {
@@ -88,17 +87,13 @@ public void execute() throws MojoExecutionException {
executeNodeJs();
}
- }
- catch (ArtifactResolutionException e) {
+ } catch (ArtifactResolutionException e) {
throw new MojoExecutionException("Unable to locate artifact: '" + nodeJsArtifactString + "' in any repository.", e);
- }
- catch (ArtifactNotFoundException e) {
+ } catch (ArtifactNotFoundException e) {
throw new MojoExecutionException("Unable to locate artifact: '" + nodeJsArtifactString + "' in any repository.", e);
- }
- catch (CommandLineException e) {
+ } catch (CommandLineException e) {
throw new MojoExecutionException("Command execution failed.", e);
- }
- catch (NodeJsPluginException e) {
+ } catch (NodeJsPluginException e) {
throw new MojoExecutionException("", e);
}
}
@@ -112,10 +107,9 @@ public void execute() throws MojoExecutionException {
protected String getNodeJsExecutable(String osFamily) {
getLog().debug("Determing executable for osFamily = " + osFamily);
StringBuilder sb = new StringBuilder(nodejsDirectory.getAbsolutePath());
- if (Os.FAMILY_WINDOWS.equals(osFamily)|| Os.FAMILY_DOS.equals(osFamily)) {
+ if (Os.FAMILY_WINDOWS.equals(osFamily) || Os.FAMILY_DOS.equals(osFamily)) {
sb.append(File.separator).append("node.exe");
- }
- else {
+ } else {
sb.append(File.separator).append("bin").append(File.separator).append("node");
}
getLog().info("Determined executable for osFamily: " + sb.toString());
@@ -124,28 +118,34 @@ protected String getNodeJsExecutable(String osFamily) {
/**
* Executes the given commandline
+ *
* @param commandLine
* @return
* @throws CommandLineException
*/
protected void executeCommandLine(Commandline commandLine)
- throws CommandLineException, MojoExecutionException {
+ throws CommandLineException, MojoExecutionException {
getLog().info("Executing command: " + commandLine.toString());
CommandLineUtils.StringStreamConsumer systemErr = new CommandLineUtils.StringStreamConsumer();
CommandLineUtils.StringStreamConsumer systemOut = new CommandLineUtils.StringStreamConsumer();
int exitCode = CommandLineUtils.executeCommandLine(commandLine, systemOut, systemErr);
String output = StringUtils.isEmpty(systemOut.getOutput()) ? null : '\n' + systemOut.getOutput().trim();
+ if (StringUtils.isNotEmpty(output)) {
+ getLog().info(output);
+ }
if (exitCode != 0) {
+ output = StringUtils.isEmpty(systemOut.getOutput()) ? null : '\n' + systemErr.getOutput().trim();
if (StringUtils.isNotEmpty(output)) {
- getLog().info(output);
+ getLog().error(output);
}
- throw new MojoExecutionException("Result of " + commandLine + " execution is: '" + exitCode + "'.");
+ throw new MojoExecutionException("Result of " + commandLine + " execution is: '" + exitCode + "'.");
}
}
/**
* Create an CommandLine for the given executable
+ *
* @param workDir
* @param executable
* @param moduleName
@@ -181,6 +181,7 @@ protected Commandline getCommandLine(File workDir, String executable, String mod
/**
* Execute nodejs for every module in #modules.
+ *
* @throws MojoExecutionException
* @throws CommandLineException
*/
@@ -209,7 +210,7 @@ protected void unpackNodeJs(Artifact nodeJsArtifact, File outputDirectory) throw
* Resolve the nodejs artifact from the repos #remoteRepositories and #localRepository.
*
* @return The desired Artifact file if resolved
- * @throws ArtifactNotFoundException if artifact was not resolved
+ * @throws ArtifactNotFoundException if artifact was not resolved
* @throws ArtifactResolutionException if there went something wrong while resolving
*/
protected Artifact resolveNodeJsArtifact() throws ArtifactNotFoundException, ArtifactResolutionException {
@@ -229,13 +230,12 @@ protected Artifact resolveNodeJsArtifact() throws ArtifactNotFoundException, Art
* @throws NodeJsPluginException if the configuration is invalid
*/
protected void initializeModulesConfiguration()
- throws NodeJsPluginException {
+ throws NodeJsPluginException {
nodejsClassifier = Os.OS_FAMILY;
if (modules == null) {
throw new NodeJsPluginException("No NodeJs modules configured.");
}
}
-
}

No commit comments for this range

Something went wrong with that request. Please try again.