Skip to content

Commit

Permalink
fix: maven deps as object for sub modules
Browse files Browse the repository at this point in the history
  • Loading branch information
darscan committed Jan 5, 2017
1 parent dfbf1a4 commit dbcdc94
Show file tree
Hide file tree
Showing 5 changed files with 94 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/module-info/maven/mvn-tree-parse.js
Expand Up @@ -18,7 +18,7 @@ function getRootProject(text) {
// Add any subsequent projects to the root as dependencies
for (var i = 1; i < projects.length; i++) {
var project = getProject(projects[i]);
root.dependencies.push(project);
root.dependencies[project.name] = project;
}
root.packageFormatVersion = packageFormatVersion;
return root;
Expand Down
20 changes: 19 additions & 1 deletion test/acceptance/cli.acceptance.test.js
Expand Up @@ -248,6 +248,23 @@ test('`monitor maven-app`', function(t) {
});
});

test('`monitor maven-multi-app`', function(t) {
t.plan(5);
chdirWorkspaces();
var proxiedCLI = proxyMavenExec('maven-multi-app/mvn-dep-tree-stdout.txt');
return proxiedCLI.monitor('maven-multi-app', {file: 'pom.xml'}).then(function() {
var req = server.popRequest();
var pkg = req.body.package;
t.equal(req.method, 'PUT', 'makes PUT request');
t.match(req.url, '/monitor/maven', 'puts at correct url');
t.equal(pkg.artifactId, 'maven-multi-app', 'specifies artifactId');
t.ok(pkg.dependencies['com.mycompany.app:simple-child'],
'specifies dependency');
t.equal(pkg.dependencies['com.mycompany.app:simple-child'].artifactId,
'simple-child', 'specifies dependency artifactId');
});
});

/**
* We can't expect all test environments to have Maven installed
* So, hijack the system exec call and return the expected output
Expand All @@ -257,10 +274,11 @@ function proxyMavenExec(execOutputFile) {
var stdout = fs.readFileSync(path.join(execOutputFile), 'utf8');
callback(null, stdout);
}
var nonCachingProxyquire = proxyquire.noPreserveCache();
return proxyquire('../../cli/commands', {
'./monitor': proxyquire('../../cli/commands/monitor', {
'../../lib/module-info': proxyquire('../../lib/module-info', {
'./maven': proxyquire('../../lib/module-info/maven', {
'./maven': nonCachingProxyquire('../../lib/module-info/maven', {
'child_process': { 'exec': exec }
})
})
Expand Down
35 changes: 35 additions & 0 deletions test/acceptance/workspaces/maven-multi-app/mvn-dep-tree-stdout.txt
@@ -0,0 +1,35 @@
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Build Order:
[INFO]
[INFO] maven-multi-app
[INFO] Simple Child Example
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building maven-multi-app 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-dependency-plugin:2.8:tree (default-cli) @ maven-multi-app ---
[INFO] digraph "com.mycompany.app:maven-multi-app:pom:1.0-SNAPSHOT" {
[INFO] }
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Simple Child Example 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-dependency-plugin:2.8:tree (default-cli) @ simple-child ---
[INFO] digraph "com.mycompany.app:simple-child:jar:1.0-SNAPSHOT" {
[INFO] "com.mycompany.app:simple-child:jar:1.0-SNAPSHOT" -> "log4j:log4j:jar:1.2.17:compile" ;
[INFO] }
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] maven-multi-app .................................... SUCCESS [ 0.769 s]
[INFO] Simple Child Example ............................... SUCCESS [ 0.068 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.193 s
[INFO] Finished at: 2017-01-05T16:05:23+00:00
[INFO] Final Memory: 12M/155M
[INFO] ------------------------------------------------------------------------
14 changes: 14 additions & 0 deletions test/acceptance/workspaces/maven-multi-app/pom.xml
@@ -0,0 +1,14 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>com.mycompany.app</groupId>
<artifactId>maven-multi-app</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>pom</packaging>
<name>maven-multi-app</name>

<modules>
<module>simple-child</module>
</modules>
</project>
25 changes: 25 additions & 0 deletions test/acceptance/workspaces/maven-multi-app/simple-child/pom.xml
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.mycompany.app</groupId>
<artifactId>maven-multi-app</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>

<artifactId>simple-child</artifactId>
<packaging>jar</packaging>
<name>Simple Child Example</name>

<dependencies>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>[1.2.14,1.3)</version>
</dependency>
</dependencies>

</project>

0 comments on commit dbcdc94

Please sign in to comment.