Permalink
Browse files

made some progress

  • Loading branch information...
1 parent 17165ec commit 455109235f9739d9613641eeeeeaaaf2f358e2ad @sirrapa committed Dec 16, 2012
View
35 pom.xml
@@ -12,11 +12,8 @@
<version>0.8.15-001-SNAPSHOT</version>
<packaging>maven-plugin</packaging>
<properties>
- <mavenVersion>2.2.1</mavenVersion>
- <mavenPrevVersion>2.0.9</mavenPrevVersion>
- <doxiaVersion>1.0</doxiaVersion>
<pluginTestingVersion>2.1</pluginTestingVersion>
- <mavenPluginPluginVersion>3.1</mavenPluginPluginVersion>
+ <mavenPluginPluginVersion>3.2</mavenPluginPluginVersion>
<nodejs.version>0.8.15</nodejs.version>
</properties>
@@ -66,6 +63,12 @@
<dependency>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
+ <!--<exclusions>-->
+ <!--<exclusion>-->
+ <!--<artifactId>plexus-container-default</artifactId>-->
+ <!--<groupId>org.codehaus.plexus</groupId>-->
+ <!--</exclusion>-->
+ <!--</exclusions>-->
<version>2.6</version>
</dependency>
@@ -76,38 +79,32 @@
<version>${mavenPluginPluginVersion}</version>
<scope>provided</scope>
</dependency>
+
<!-- test -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.2</version>
<scope>test</scope>
</dependency>
- <!-- this seems to be a critical dependency,
- must be declared before org.apache.maven.plugin-testing so it's first on the classpath -->
- <dependency>
+ <dependency> <!-- this seems to be a critical dependency,
+ must be declared before org.apache.maven.plugin-testing so it's first on the classpath -->
<groupId>org.apache.maven.shared</groupId>
<artifactId>maven-plugin-testing-harness</artifactId>
<version>1.1</version>
<scope>test</scope>
- <exclusions>
- <exclusion>
- <artifactId>maven-compat</artifactId>
- <groupId>org.apache.maven</groupId>
- </exclusion>
- </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven.plugin-testing</groupId>
+ <artifactId>maven-plugin-testing-tools</artifactId>
+ <version>${pluginTestingVersion}</version>
+ <scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.maven.plugin-testing</groupId>
<artifactId>maven-plugin-testing-harness</artifactId>
<version>${pluginTestingVersion}</version>
<scope>test</scope>
- <exclusions>
- <exclusion>
- <artifactId>maven-compat</artifactId>
- <groupId>org.apache.maven</groupId>
- </exclusion>
- </exclusions>
</dependency>
<dependency>
<groupId>org.codehaus.plexus</groupId>
@@ -33,7 +33,7 @@
/**
* The nodejs file to run
*/
- @Component
+ @Parameter
private PlexusConfiguration modules;
private NodeJsModule[] nodeJsModules;
@@ -52,17 +52,17 @@
* The nodejs nodejsVersion
*/
@Parameter( defaultValue = "0.8")
- private String nodejsVersion;
+ protected String nodejsVersion;
/**
* The nodejs nodejsType
*/
@Parameter(defaultValue = "tar")
- private String nodejsType;
+ protected String nodejsType;
/**
* The nodejs nodejsClassifier
*/
@Parameter
- private String nodejsClassifier;
+ protected String nodejsClassifier;
/**
* Default location used for nodejs output
@@ -92,6 +92,20 @@
{ SOLARIS_FAMILY,CLASSIFIER_UNIX_FAMILY},
{ MAC_FAMILY,CLASSIFIER_MAC_FAMILY }};
+ /**
+ * Getter for property 'modules'.
+ *
+ * @return Value for property modules
+ */
+ public PlexusConfiguration getModules() { return modules; }
+
+ /**
+ * Setter for property 'modules'.
+ *
+ * @param modules Value to set for property 'modules'.
+ */
+ public void setModules(PlexusConfiguration modules) { this.modules = modules; }
+
/**
* Execution of NodeJs
@@ -134,9 +148,9 @@ protected int executeCommandLine(Commandline commandLine, StreamConsumer stream1
protected String getNodeJsExecutable(String osFamily) {
StringBuilder sb = new StringBuilder(workingDirectory.getAbsolutePath());
if(!"win".equalsIgnoreCase(StringUtils.substring(osFamily,0, 3))) {
- sb.append("bin").append(File.separator).append("nodejs");
+ sb.append(File.separator).append("bin").append(File.separator).append("nodejs");
}else {
- sb.append("nodejs.exe");
+ sb.append(File.separator).append("nodejs.exe");
}
return sb.toString();
}
@@ -11,8 +11,6 @@
import org.apache.maven.artifact.handler.manager.DefaultArtifactHandlerManager;
import org.apache.maven.artifact.repository.DefaultArtifactRepository;
import org.apache.maven.artifact.repository.layout.DefaultRepositoryLayout;
-import org.apache.maven.artifact.resolver.DefaultArtifactResolver;
-import org.apache.maven.artifact.transform.DefaultArtifactTransformationManager;
import org.apache.maven.plugin.testing.AbstractMojoTestCase;
import org.apache.maven.plugin.testing.ArtifactStubFactory;
import org.apache.maven.plugin.testing.stubs.StubArtifactResolver;
@@ -39,39 +37,39 @@ private void loadMojo(String pomFileName) throws Exception {
mojo.setLocal(repository);
mojo.setFactory(new DefaultArtifactFactory());
- mojo.setResolver(new StubArtifactResolver(new ArtifactStubFactory(mojo.workingDirectory,true),false,false));
+ mojo.setResolver(new StubArtifactResolver(new ArtifactStubFactory(mojo.workingDirectory, true), false, false));
DefaultArtifactHandlerManager artifactHandlerManager = new DefaultArtifactHandlerManager();
- setVariableValueToObject(artifactHandlerManager,"artifactHandlers",new HashMap());
+ setVariableValueToObject(artifactHandlerManager, "artifactHandlers", new HashMap());
Map<String, ?> handlerDescriptors = getContainer().getComponentDescriptorMap(ArtifactHandler.ROLE);
- if (handlerDescriptors != null) {
+ if (handlerDescriptors != null) {
mojo.getLog().debug("Registering all unregistered ArtifactHandlers...");
- Set<String> existingHints = artifactHandlerManager.getHandlerTypes();
- if (existingHints != null) {
+ Set<String> existingHints = artifactHandlerManager.getHandlerTypes();
+ if (existingHints != null) {
for (String hint : existingHints) {
- handlerDescriptors.remove(hint);
+ handlerDescriptors.remove(hint);
}
- }
+ }
if (handlerDescriptors.isEmpty()) {
- mojo.getLog().debug("All ArtifactHandlers are registered. Continuing...");
+ mojo.getLog().debug("All ArtifactHandlers are registered. Continuing...");
} else {
- Map<String, ArtifactHandler> unregisteredHandlers = new HashMap<String, ArtifactHandler>(handlerDescriptors .size());
-
- for (String hint : handlerDescriptors.keySet()) {
- try {
- unregisteredHandlers.put(hint, (ArtifactHandler) lookup(ArtifactHandler.ROLE, hint));
- mojo.getLog().info("Adding ArtifactHandler for: " + hint);
- } catch (ComponentLookupException e) {
- mojo.getLog().warn("Failed to lookup ArtifactHandler with hint: " + hint + ". Reason: " + e.getMessage(), e);
+ Map<String, ArtifactHandler> unregisteredHandlers = new HashMap<String, ArtifactHandler>(handlerDescriptors.size());
+
+ for (String hint : handlerDescriptors.keySet()) {
+ try {
+ unregisteredHandlers.put(hint, (ArtifactHandler) lookup(ArtifactHandler.ROLE, hint));
+ mojo.getLog().info("Adding ArtifactHandler for: " + hint);
+ } catch (ComponentLookupException e) {
+ mojo.getLog().warn("Failed to lookup ArtifactHandler with hint: " + hint + ". Reason: " + e.getMessage(), e);
+ }
}
- }
- artifactHandlerManager.addHandlers(unregisteredHandlers);
+ artifactHandlerManager.addHandlers(unregisteredHandlers);
}
- }
- setVariableValueToObject(mojo.getFactory(),"artifactHandlerManager",artifactHandlerManager);
+ }
+ setVariableValueToObject(mojo.getFactory(), "artifactHandlerManager", artifactHandlerManager);
}
public void testMojoLookup() throws Exception {
@@ -130,5 +128,38 @@ public void testUnpackNodeJs() throws Exception {
Artifact artifact = mojo.resolveNodeJsArtifact();
assertNotNull("NodeJs artifact is null", artifact);
+
+ setVariableValueToObject(mojo, "workingDirectory", new File(System.getProperty("java.io.tmpdir"), "nodejs"));
+ File tmpDir = new File(System.getProperty("java.io.tmpdir"), "nodejs");
+ try {
+ tmpDir.mkdirs();
+ mojo.unpackNodeJs(artifact, tmpDir);
+
+ String nodejsEx = mojo.getNodeJsExecutable(mojo.getOSClassifier());
+
+ assertTrue(String.format("Extract of nodejs to '%s' failed", tmpDir.getAbsolutePath()), new File(nodejsEx ).exists());
+
+ } finally {
+ tmpDir.delete();
+ }
+ }
+
+ public void testGetNodeJsExecutable() throws Exception {
+ loadMojo("plugin-config.xml");
+ mojo.initializeModulesConfiguration();
+
+ setVariableValueToObject(mojo, "workingDirectory", new File(System.getProperty("java.io.tmpdir")+ "nodejs/"));
+ String nodejsEx;
+
+ for (String[] family : NodeJsMojo.OS_CLASSIFIER_FAMILIES) {
+ nodejsEx = mojo.getNodeJsExecutable(family[0]);
+ System.out.println("nodejsEx = " + nodejsEx);
+
+ if (NodeJsMojo.WINDOWS_FAMILY.endsWith(family[0])) {
+ assertTrue(String.format("The nodejs executable for %s family is invalid", family), nodejsEx.endsWith("/nodejs/nodejs.exe"));
+ } else {
+ assertTrue(String.format("The nodejs executable for %s family is invalid", family), nodejsEx.endsWith("/nodejs/bin/nodejs"));
+ }
+ }
}
}
@@ -11,7 +11,6 @@
<groupId>com.sirrapa.maven.plugins</groupId>
<artifactId>nodejs-maven-plugin</artifactId>
<configuration>
- <goal>compile</goal>
<nodejsGroupId>org.nodejs</nodejsGroupId>
<nodejsArtifactId>nodejs</nodejsArtifactId>
<nodejsVersion>0.8.15</nodejsVersion>
Oops, something went wrong.

0 comments on commit 4551092

Please sign in to comment.