-
Notifications
You must be signed in to change notification settings - Fork 98
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
198c289
commit 0134866
Showing
13 changed files
with
151 additions
and
110 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
invoker.goals = --toolchains toolchains.xml validate |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
<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/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<parent> | ||
<groupId>org.codehaus.mojo.exec.it</groupId> | ||
<artifactId>parent</artifactId> | ||
<version>0.1</version> | ||
</parent> | ||
|
||
<artifactId>toolchains-paths</artifactId> | ||
<version>0.0.1-SNAPSHOT</version> | ||
<packaging>pom</packaging> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-toolchains-plugin</artifactId> | ||
<configuration> | ||
<toolchains> | ||
<paths> | ||
<id>my-paths</id> | ||
</paths> | ||
</toolchains> | ||
</configuration> | ||
<executions> | ||
<execution> | ||
<goals> | ||
<goal>toolchain</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.codehaus.mojo</groupId> | ||
<artifactId>exec-maven-plugin</artifactId> | ||
<version>@project.version@</version> | ||
<extensions>true</extensions> | ||
<configuration> | ||
<executable>test</executable> | ||
<toolchain>paths</toolchain> | ||
</configuration> | ||
<executions> | ||
<execution> | ||
<id>execution</id> | ||
<goals> | ||
<goal>exec</goal> | ||
</goals> | ||
<phase>validate</phase> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
#! /bin/sh | ||
echo Hello from exec-maven-plugin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
echo Hello from exec-maven-plugin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?xml version="1.0" encoding="UTF8"?> | ||
<toolchains> | ||
<toolchain> | ||
<type>paths</type> | ||
<provides> | ||
<id>my-paths</id> | ||
</provides> | ||
<configuration> | ||
<paths> | ||
<path>scripts</path> | ||
</paths> | ||
</configuration> | ||
</toolchain> | ||
</toolchains> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
File log = new File(basedir, 'build.log') | ||
|
||
assert log.exists() | ||
assert log.getText().contains( "[INFO] Toolchain in exec-maven-plugin: Paths[scripts]" ) | ||
assert log.getText().contains( "Hello from exec-maven-plugin" ) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,38 +19,59 @@ | |
* under the License. | ||
*/ | ||
|
||
import java.util.Collections; | ||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.Objects; | ||
|
||
import org.apache.maven.toolchain.DefaultToolchain; | ||
import org.apache.maven.toolchain.ToolchainPrivate; | ||
import org.apache.maven.toolchain.model.ToolchainModel; | ||
import org.codehaus.plexus.logging.Logger; | ||
|
||
/** | ||
* Searches a list of configured paths for the requested tool. | ||
* | ||
* @author Markus KARG ([email protected]) | ||
*/ | ||
class PathsToolchain extends DefaultToolchain { | ||
class PathsToolchain implements ToolchainPrivate { | ||
private final ToolchainModel model; | ||
|
||
private List<String> paths; | ||
|
||
public PathsToolchain(final ToolchainModel model, final Logger logger) { | ||
super(model, "paths", logger); // NOI18N | ||
public PathsToolchain(ToolchainModel model) { | ||
this.model = model; | ||
} | ||
|
||
@Override | ||
public ToolchainModel getModel() { | ||
return model; | ||
} | ||
|
||
public List<String> getPaths() { | ||
return this.paths; | ||
@Override | ||
public String getType() { | ||
return model.getType(); | ||
} | ||
|
||
public void setPaths(final List<String> paths) { | ||
public void setPaths(List<String> paths) { | ||
this.paths = paths; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "Paths" + this.getPaths(); // NOI18N | ||
private List<String> getPaths() { | ||
return paths != null ? paths : Collections.emptyList(); | ||
} | ||
|
||
@Override | ||
public String findTool(final String toolName) { | ||
return ExecMojo.findExecutable(toolName, this.paths); | ||
return ExecMojo.findExecutable(toolName, getPaths()); | ||
} | ||
|
||
@Override | ||
public boolean matchesRequirements(Map<String, String> requirements) { | ||
return requirements.entrySet().stream() | ||
.anyMatch(entry -> Objects.equals(model.getProvides().get(entry.getKey()), entry.getValue())); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "Paths" + getPaths(); // NOI18N | ||
} | ||
} |
Oops, something went wrong.