Commit 33c87a1a authored by Emmanuel Bourg's avatar Emmanuel Bourg

Merge tag 'upstream/2.3.0'

Upstream version 2.3.0
parents 644dc782 feb27cc7
*.ipr
*.iml
*.iws
.idea
target
.classpath
.project
.settings
# use http://docs.travis-ci.com/user/workers/container-based-infrastructure/
sudo: false
language: java
#maven:
# - '3.0.5'
# - '3.5.0'
jdk:
- oraclejdk7
# cache local Maven repo: http://docs.travis-ci.com/user/caching/
cache:
directories:
- '$HOME/.m2/repository'
before_install:
- wget https://archive.apache.org/dist/maven/maven-3/3.0.5/binaries/apache-maven-3.0.5-bin.zip
- unzip -q apache-maven-3.0.5-bin.zip
- wget https://archive.apache.org/dist/maven/maven-3/3.5.0/binaries/apache-maven-3.5.0-bin.zip
- unzip -q apache-maven-3.5.0-bin.zip
env:
matrix:
- MAVEN=$PWD/apache-maven-3.0.5
- MAVEN=$PWD/apache-maven-3.5.0
install: /bin/true
script: export M2_HOME=$MAVEN ; export PATH=$M2_HOME/bin:$PATH ; mvn --version ; mvn clean install
Copyright 2008-2013 Don Brown
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
[![Build Status](https://travis-ci.org/TimMoore/mojo-executor.svg?branch=master)](https://travis-ci.org/TimMoore/mojo-executor)
The Mojo Executor provides a way to to execute other Mojos (plugins) within a Maven plugin, allowing you to easily create Maven plugins that are composed of other plugins.
Note from the Maintainer
========================
I'm no longer maintaning this project actively, as I no longer use it (and have moved away from Maven and Java entirely). It's a simple library that does its job, and a lot of people are using it effectively in its current state.
I am happy to continue reviewing and merging pull requests, and releasing new versions to Maven Central. Most of the contributions so far have come from other people, and I'm very grateful to the people that have helped to improve Mojo Executor.
I do want to make it clear, however, that I won't be personally working on any bug reports or feature requests that come through the issue tracker without a pull request. I hope the community of Mojo Executor users will help answer questions and troubleshoot problems reported there.
If anyone in the community would like to take over as full-time maintainer, let's talk! Email me at tmoore@incrementalism.net and we can set up a Skype call or Google Hangout to discuss it in detail.
Cheers,
— Tim
News
====
- 27 Mar 2014 — Mojo Executor 1.5.2 released with support for Maven 2 through 3.1.
- 12 Feb 2014 — I'm looking for a new maintainer for this project. If you're interested, please get in touch!
- 26 Nov 2013 — Mojo Executor 2.2.0 released with support for attributes in plugin configuration.
- 25 Aug 2013 — Mojo Executor 2.1.0 released with support for Maven 3.1.
Downloads
=========
You can download the jars, source, and javadocs from Maven central:
http://repo2.maven.org/maven2/org/twdata/maven/mojo-executor/
Example Usage
=============
MojoExecutor defines a number of builder methods that are intended to be imported statically:
``` java
import static org.twdata.maven.mojoexecutor.MojoExecutor.*
```
This is how you would execute the "copy-dependencies" goal of the Maven Dependency Plugin programmatically:
``` java
executeMojo(
plugin(
groupId("org.apache.maven.plugins"),
artifactId("maven-dependency-plugin"),
version("2.0")
),
goal("copy-dependencies"),
configuration(
element(name("outputDirectory"), "${project.build.directory}/foo")
),
executionEnvironment(
mavenProject,
mavenSession,
pluginManager
)
);
```
The project, session, and pluginManager variables should be injected via the normal Mojo injection:
``` java
@Component
private MavenProject mavenProject;
@Component
private MavenSession mavenSession;
@Component
private BuildPluginManager pluginManager;
```
An alternative form for the executionEnvironment, ignoring the optional MavenProject, is:
```
executionEnvironment(
mavenSession,
pluginManager
)
```
You might need to add other annotations to your Mojo class, depending on the needs of your plugin. Annotations declared by Mojos that you execute are _not_ automatically inherited by your enclosing Mojo.
For example, if you are using the `maven-dependency-plugin`, as in this example, you will need to add `@requiresDependencyResolution <scope>` to your class annotations to ensure that Maven resolves the project dependencies before invoking your plugin.
See the [Mojo API Specification][mojo-api] for details on available annotations. Look at the included [example plugin](mojo-executor-maven-plugin/) for an example of use.
Maven Dependency
================
Add this to your pom.xml:
``` xml
<dependencies>
<dependency>
<groupId>org.twdata.maven</groupId>
<artifactId>mojo-executor</artifactId>
<version>2.2.0</version>
</dependency>
</dependencies>
```
There are a few versions available, and the best one to use will depend on the version(s) of Maven you need to support:
- 1.0.1 &mdash; Supports Maven 2.x only
- 1.5 &mdash; Supports both Maven 2.x and Maven 3.x
- 2.0.x &mdash; Supports Maven 3.0.x only
- 2.1.x &mdash; Supports Maven 3.0.x and 3.1.x
License
=======
Copyright 2008-2013 Don Brown
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Contributors
============
Mojo Executor was originally created by [Don Brown][mrdon] (mrdon@twdata.org).
It is currently maintained by [Tim Moore][TimMoore] (tmoore@incrementalism.net).
Thanks to the following contributors, who have provided patches and other assistance:
- [Matthew McCullough][matthewmccullough]
- Gili Tzabari (cowwoc@bbs.darktech.org) &mdash; Maven 3 support
- [Joseph Walton][josephw] &mdash; support for both Maven 2 and Maven 3 in the same artifact
- [Olivier Lamy][olamy] &amp; [Robert Munteanu][rombert] &mdash; Maven 3.1 support
- [Jelmer Kuperus][jelmerk] &mdash; support for plugin dependencies
- [msavelyev][msavelyev] &amp; [Ivan Dyachenko][ivan-dyachenko] &mdash; support for attributes in Mojo configuration
- [Christof Schoell][cschoell] &mdash; Maven 3.1 support in the 1.5.x branch
[mrdon]: https://github.com/mrdon
[TimMoore]: https://github.com/TimMoore/
[matthewmccullough]: https://github.com/matthewmccullough
[josephw]: https://github.com/josephw
[olamy]: https://github.com/olamy
[rombert]: https://github.com/rombert
[jelmerk]: https://github.com/jelmerk
[msavelyev]: https://github.com/msavelyev
[ivan-dyachenko]: https://github.com/ivan-dyachenko
[cschoell]: https://github.com/cschoell
[mojo-api]: http://maven.apache.org/developers/mojo-api-specification.html
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright 2008-2013 Don Brown
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<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>org.twdata.maven</groupId>
<artifactId>mojo-executor-parent</artifactId>
<version>2.3.0</version>
</parent>
<artifactId>mojo-executor-maven-plugin</artifactId>
<packaging>maven-plugin</packaging>
<name>Mojo Executor Maven Plugin</name>
<description>
A very simple example of how to use the Mojo Executor in a Maven plugin. This plugin allows you to specify the
group ID, artifact ID, version, goal, and configuration of a plugin to execute. Why would you use this plugin
instead of just executing the plugin directly? You wouldn't, probably! It's just for example and functional
testing purposes.
</description>
<dependencies>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-core</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-model</artifactId>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-plugin-api</artifactId>
</dependency>
<dependency>
<groupId>org.apache.maven.plugin-tools</groupId>
<artifactId>maven-plugin-annotations</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-utils</artifactId>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>mojo-executor</artifactId>
</dependency>
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-embedder</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-plugin-plugin</artifactId>
<version>3.4</version>
<executions>
<execution>
<id>default-descriptor</id>
<phase>process-classes</phase>
<goals>
<goal>descriptor</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-invoker-plugin</artifactId>
<version>2.0.0</version>
<configuration>
<!-- <debug>true</debug> -->
<cloneProjectsTo>${project.build.directory}/it</cloneProjectsTo>
<localRepositoryPath>${project.build.directory}/it-repo</localRepositoryPath>
<settingsFile>src/it/settings.xml</settingsFile>
</configuration>
<executions>
<execution>
<goals>
<goal>install</goal>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright 2008-2013 Don Brown
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<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>org.twdata.maven</groupId>
<artifactId>mojo-executor-test-project-no-plugin-version</artifactId>
<version>1.0-SNAPSHOT</version>
<name>Mojo Executor - Test Project</name>
<description>
Used by the tests for the Mojo Executor Maven Plugin.
</description>
<dependencies>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.4</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-nop</artifactId>
<version>1.7.4</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit-dep</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.0</version>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.twdata.maven</groupId>
<artifactId>mojo-executor-maven-plugin</artifactId>
<version>@project.version@</version>
<executions>
<execution>
<phase>test</phase>
<goals>
<goal>execute-mojo</goal>
</goals>
<configuration>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
</plugin>
<goal>list</goal>
<configuration>
</configuration>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
/*
* Copyright 2008-2013 Don Brown
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
File buildLog = new File((String) basedir, "build.log")
return buildLog.getText().contains("""
[INFO] The following files have been resolved:
[INFO] junit:junit:jar:4.11:test
[INFO] org.hamcrest:hamcrest-core:jar:1.3:test
[INFO] org.slf4j:slf4j-api:jar:1.7.4:provided
[INFO] org.slf4j:slf4j-nop:jar:1.7.4:runtime
""");
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright 2008-2013 Don Brown
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<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>org.twdata.maven</groupId>
<artifactId>mojo-executor-test-project-null-maven-project</artifactId>
<version>1.0-SNAPSHOT</version>
<name>Mojo Executor - Test Project</name>
<description>
Used by the tests for the Mojo Executor Maven Plugin.
</description>
<dependencies>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.4</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-nop</artifactId>
<version>1.7.4</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit-dep</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.twdata.maven</groupId>
<artifactId>mojo-executor-maven-plugin</artifactId>
<version>@project.version@</version>
<executions>
<execution>
<phase>test</phase>
<goals>
<goal>execute-mojo</goal>
</goals>
<configuration>
<ignoreMavenProject>true</ignoreMavenProject>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.0</version>
</plugin>
<goal>list</goal>
<configuration>
</configuration>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
/*
* Copyright 2008-2013 Don Brown
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
File buildLog = new File((String) basedir, "build.log")
return buildLog.getText().contains("""
[INFO] The following files have been resolved:
[INFO] junit:junit:jar:4.11:test
[INFO] org.hamcrest:hamcrest-core:jar:1.3:test
[INFO] org.slf4j:slf4j-api:jar:1.7.4:provided
[INFO] org.slf4j:slf4j-nop:jar:1.7.4:runtime
""");
invoker.goals=clean install -Dquiet=true
invoker.goals=-q clean install -Dquiet=false
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright 2008-2013 Don Brown
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<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>org.twdata.maven</groupId>
<artifactId>mojo-executor-test-project-quiet</artifactId>
<version>1.0-SNAPSHOT</version>
<name>Mojo Executor - Test Project</name>
<description>
Used by the tests for the Mojo Executor Maven Plugin.
</description>
<dependencies>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.4</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-nop</artifactId>
<version>1.7.4</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit-dep</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.twdata.maven</groupId>
<artifactId>mojo-executor-maven-plugin</artifactId>
<version>@project.version@</version>
<executions>
<execution>
<phase>test</phase>
<goals>
<goal>execute-mojo</goal>
</goals>
<configuration>
<quiet>${quiet}</quiet>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.0</version>
</plugin>
<goal>list</goal>
<configuration>
</configuration>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
/*
* Copyright 2008-2013 Don Brown
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
File buildLog = new File((String) basedir, "build.log")
return ! buildLog.getText().contains("""
[INFO] The following files have been resolved:
[INFO] junit:junit:jar:4.11:test
[INFO] org.hamcrest:hamcrest-core:jar:1.3:test
[INFO] org.slf4j:slf4j-api:jar:1.7.4:provided
[INFO] org.slf4j:slf4j-nop:jar:1.7.4:runtime
""");
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright 2008-2011 Don Brown
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<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>org.twdata.maven</groupId>
<artifactId>mojo-executor-test-project</artifactId>
<version>1.0-SNAPSHOT</version>
<name>Mojo Executor - Test Project</name>
<description>
Used by the tests for the Mojo Executor Maven Plugin.
</description>
<build>
<plugins>
<plugin>
<groupId>org.twdata.maven</groupId>
<artifactId>mojo-executor-maven-plugin</artifactId>
<version>@project.version@</version>
<executions>
<execution>
<phase>test</phase>
<goals>
<goal>execute-mojo</goal>
</goals>
<configuration>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.6</version>
<dependencies>
<dependency>
<groupId>ant-contrib</groupId>
<artifactId>ant-contrib</artifactId>
<version>1.0b3</version>
<exclusions>
<exclusion>
<groupId>ant</groupId>
<artifactId>ant</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.ant</groupId>
<artifactId>ant-nodeps</artifactId>
<version>1.8.1</version>
</dependency>
</dependencies>
</plugin>
<goal>run</goal>
<configuration>
<target>
<taskdef resource="net/sf/antcontrib/antcontrib.properties"
classpathref="maven.plugin.classpath" />