pax_global_header00006660000000000000000000000064147377525760014541gustar00rootroot0000000000000052 comment=ad9545c50e55f334da84c3df730800d1926caf3b mojo-executor-mojo-executor-parent-2.4.1/000077500000000000000000000000001473775257600204325ustar00rootroot00000000000000mojo-executor-mojo-executor-parent-2.4.1/.github/000077500000000000000000000000001473775257600217725ustar00rootroot00000000000000mojo-executor-mojo-executor-parent-2.4.1/.github/dependabot.yml000066400000000000000000000004041473775257600246200ustar00rootroot00000000000000version: 2 updates: - package-ecosystem: "maven" directory: "/" schedule: interval: "weekly" target-branch: "main" - package-ecosystem: "github-actions" directory: "/" schedule: interval: "weekly" target-branch: "main" mojo-executor-mojo-executor-parent-2.4.1/.github/workflows/000077500000000000000000000000001473775257600240275ustar00rootroot00000000000000mojo-executor-mojo-executor-parent-2.4.1/.github/workflows/maven.yml000066400000000000000000000044471473775257600256710ustar00rootroot00000000000000# This workflow will build a Java project with Maven # For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven name: CI on: push: branches: [main] pull_request: branches: [main] jobs: build: strategy: fail-fast: false matrix: maven: [3.3.1, 3.5.4, 3.6.3, 3.8.8, 3.9.6, 4.0.0-alpha-13] jdk: [11, 17] exclude: - maven: 4.0.0-alpha-13 jdk: 11 # https://docs.github.com/en/free-pro-team@latest/actions/reference/workflow-syntax-for-github-actions#jobsjob_idif if: github.repository == 'mojo-executor/mojo-executor' && github.event_name == 'pull_request' runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - name: Set up JDK uses: actions/setup-java@v4 with: java-version: ${{ matrix.jdk }} distribution: "temurin" cache: 'maven' - name: Set up Maven run: mvn -e -B -V org.apache.maven.plugins:maven-wrapper-plugin:3.2.0:wrapper "-Dmaven=${{ matrix.maven }}" - name: Build with Maven run: ./mvnw -B -V -e install # - name: Setup tmate session # uses: mxschmitt/action-tmate@v3 # if: ${{ failure() }} - name: Codecov uses: codecov/codecov-action@v4 snapshot: if: github.repository == 'mojo-executor/mojo-executor' && github.event_name == 'push' && github.ref == 'refs/heads/main' && github.actor != 'dependabot[bot]' runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - name: Set up JDK 11 uses: actions/setup-java@v4 with: java-version: 11 distribution: "temurin" cache: 'maven' # https://github.com/marketplace/actions/maven-settings-action - name: Maven Settings uses: s4u/maven-settings-action@v3.0.0 with: sonatypeSnapshots: true githubServer: false servers: | [{ "id": "ossrh", "username": "${{ secrets.SONATYPE_USERNAME }}", "password": "${{ secrets.SONATYPE_PASSWORD }}" }] - name: Deploy Snapshot run: mvn -B -V -Dmaven.deploy.skip=releases org.apache.maven.plugins:maven-source-plugin:jar-no-fork deploy - name: Codecov uses: codecov/codecov-action@v4 mojo-executor-mojo-executor-parent-2.4.1/.gitignore000066400000000000000000000001211473775257600224140ustar00rootroot00000000000000*.ipr *.iml *.iws .idea target .classpath .project .settings .mvn/wrapper/ mvnw* mojo-executor-mojo-executor-parent-2.4.1/LICENSE.txt000066400000000000000000000010521473775257600222530ustar00rootroot00000000000000Copyright 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. mojo-executor-mojo-executor-parent-2.4.1/README.md000066400000000000000000000160731473775257600217200ustar00rootroot00000000000000[![Build Status](https://github.com/mojo-executor/mojo-executor/actions/workflows/maven.yml/badge.svg)](https://github.com/mojo-executor/mojo-executor/actions/workflows/maven.yml) [![Maven Central](https://img.shields.io/maven-central/v/org.twdata.maven/mojo-executor)](https://search.maven.org/artifact/org.twdata.maven/mojo-executor) The Mojo Executor provides a way 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 Maintainers ========================= Tim Moore --------- I'm no longer maintaining 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 Nick Cross ---------- While I am no longer actively using this plugin I am happy to review, assist with contributions, merge PRs and release new versions. I have released the last few versions rolling up all the various fixes and improvements. Cheers, — Nick News ==== - 10 Mar 2022 — [Mojo Executor 2.4.0](https://github.com/mojo-executor/mojo-executor/releases/tag/mojo-executor-parent-2.4.0) released - 10 Feb 2022 — Mojo Executor 2.3.3 released with updated dependencies - 1 Sep 2021 — Mojo Executor 2.3.2 released (by Nick Cross) with various bug fixes and minor improvements - 21 Nov 2019 — Mojo Executor 2.3.1 released (by Nick Cross) with various bug fixes and minor improvements - 4 May 2017 — Mojo Executor 2.3.0 released (by Nick Cross) with various bug fixes and minor improvements. - 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: https://search.maven.org/search?q=g:org.twdata.maven 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 ` 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 org.twdata.maven mojo-executor 2.4.0 ``` Maven Compatibility =================== - 2.4.x — Requires Maven 3.3.1 or later - 2.1.x/2.2.x — Support Maven 3.x - 2.0.x — Supports Maven 3.0.x only - 1.5.x — Supports both Maven 2.x and Maven 3.x - 1.0.1 — Supports Maven 2.x only 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) and [Nick Cross][rnc] (ncross@redhat.com) Thanks to the following contributors, who have provided patches and other assistance: - [Matthew McCullough][matthewmccullough] - [Gili Tzabari][cowwoc] — Maven 3 support - [Joseph Walton][josephw] — support for both Maven 2 and Maven 3 in the same artifact - [Olivier Lamy][olamy] & [Robert Munteanu][rombert] — Maven 3.1 support - [Jelmer Kuperus][jelmerk] — support for plugin dependencies - [msavelyev][msavelyev] & [Ivan Dyachenko][ivan-dyachenko] — support for attributes in Mojo configuration - [Christof Schoell][cschoell] — Maven 3.1 support in the 1.5.x branch [rnc]: https://github.com/rnc [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 [cowwoc]: https://github.com/cowwoc [mojo-api]: http://maven.apache.org/developers/mojo-api-specification.html mojo-executor-mojo-executor-parent-2.4.1/mojo-executor-maven-plugin/000077500000000000000000000000001473775257600256325ustar00rootroot00000000000000mojo-executor-mojo-executor-parent-2.4.1/mojo-executor-maven-plugin/pom.xml000066400000000000000000000115741473775257600271570ustar00rootroot00000000000000 4.0.0 org.twdata.maven mojo-executor-parent 2.4.1 mojo-executor-maven-plugin maven-plugin Mojo Executor Maven Plugin 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. ${maven.version} org.apache.maven maven-core provided org.apache.maven maven-model provided org.apache.maven maven-plugin-api provided org.apache.maven.plugin-tools maven-plugin-annotations provided org.apache.maven maven-embedder provided org.codehaus.plexus plexus-utils compile org.eclipse.sisu org.eclipse.sisu.plexus provided org.slf4j slf4j-api provided ${project.groupId} mojo-executor org.apache.commons commons-lang3 org.apache.maven.plugins maven-plugin-plugin default-descriptor process-classes descriptor org.apache.maven.plugins maven-invoker-plugin ${project.build.directory}/it ${project.build.directory}/it-repo src/it/settings.xml true install run mojo-executor-mojo-executor-parent-2.4.1/mojo-executor-maven-plugin/src/000077500000000000000000000000001473775257600264215ustar00rootroot00000000000000mojo-executor-mojo-executor-parent-2.4.1/mojo-executor-maven-plugin/src/it/000077500000000000000000000000001473775257600270355ustar00rootroot00000000000000mojo-executor-test-project-blocking/000077500000000000000000000000001473775257600357655ustar00rootroot00000000000000mojo-executor-mojo-executor-parent-2.4.1/mojo-executor-maven-plugin/src/itpom.xml000066400000000000000000000056661473775257600373170ustar00rootroot00000000000000mojo-executor-mojo-executor-parent-2.4.1/mojo-executor-maven-plugin/src/it/mojo-executor-test-project-blocking 4.0.0 org.twdata.maven mojo-executor-test-project-blocking 1.0-SNAPSHOT Mojo Executor - Test Project Used by the tests for the Mojo Executor Maven Plugin. org.slf4j slf4j-api 1.7.36 provided org.slf4j slf4j-nop 1.7.36 runtime junit junit-dep 4.11 test org.twdata.maven mojo-executor-maven-plugin @project.version@ test execute-mojo false true org.apache.maven.plugins maven-dependency-plugin 2.0 list postbuild.groovy000066400000000000000000000021301473775257600412350ustar00rootroot00000000000000mojo-executor-mojo-executor-parent-2.4.1/mojo-executor-maven-plugin/src/it/mojo-executor-test-project-blocking/* * 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") def text = buildLog.getText() text = text.replaceAll("\r\n", "\n") def v1 = text.contains("[INFO] Executing 'org.apache.maven.plugins:maven-dependency-plugin' in blocking mode.") def v2 = text.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.36:provided [INFO] org.slf4j:slf4j-nop:jar:1.7.36:runtime"""); return v1 && v2; mojo-executor-test-project-no-plugin-version/000077500000000000000000000000001473775257600375705ustar00rootroot00000000000000mojo-executor-mojo-executor-parent-2.4.1/mojo-executor-maven-plugin/src/itpom.xml000066400000000000000000000060711473775257600411110ustar00rootroot00000000000000mojo-executor-mojo-executor-parent-2.4.1/mojo-executor-maven-plugin/src/it/mojo-executor-test-project-no-plugin-version 4.0.0 org.twdata.maven mojo-executor-test-project-no-plugin-version 1.0-SNAPSHOT Mojo Executor - Test Project Used by the tests for the Mojo Executor Maven Plugin. org.slf4j slf4j-api 1.7.36 provided org.slf4j slf4j-nop 1.7.36 runtime junit junit-dep 4.11 test org.apache.maven.plugins maven-dependency-plugin 2.0 org.twdata.maven mojo-executor-maven-plugin @project.version@ test execute-mojo org.apache.maven.plugins maven-dependency-plugin list postbuild.groovy000066400000000000000000000017271473775257600430530ustar00rootroot00000000000000mojo-executor-mojo-executor-parent-2.4.1/mojo-executor-maven-plugin/src/it/mojo-executor-test-project-no-plugin-version/* * 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") def text = buildLog.getText() text = text.replaceAll("\r\n", "\n") return text.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.36:provided [INFO] org.slf4j:slf4j-nop:jar:1.7.36:runtime """); mojo-executor-test-project-null-maven-project/000077500000000000000000000000001473775257600377175ustar00rootroot00000000000000mojo-executor-mojo-executor-parent-2.4.1/mojo-executor-maven-plugin/src/itpom.xml000066400000000000000000000056431473775257600412440ustar00rootroot00000000000000mojo-executor-mojo-executor-parent-2.4.1/mojo-executor-maven-plugin/src/it/mojo-executor-test-project-null-maven-project 4.0.0 org.twdata.maven mojo-executor-test-project-null-maven-project 1.0-SNAPSHOT Mojo Executor - Test Project Used by the tests for the Mojo Executor Maven Plugin. org.slf4j slf4j-api 1.7.36 provided org.slf4j slf4j-nop 1.7.36 runtime junit junit-dep 4.11 test org.twdata.maven mojo-executor-maven-plugin @project.version@ test execute-mojo true org.apache.maven.plugins maven-dependency-plugin 2.0 list postbuild.groovy000066400000000000000000000017271473775257600432020ustar00rootroot00000000000000mojo-executor-mojo-executor-parent-2.4.1/mojo-executor-maven-plugin/src/it/mojo-executor-test-project-null-maven-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") def text = buildLog.getText() text = text.replaceAll("\r\n", "\n") return text.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.36:provided [INFO] org.slf4j:slf4j-nop:jar:1.7.36:runtime """); mojo-executor-test-project-quiet/000077500000000000000000000000001473775257600353245ustar00rootroot00000000000000mojo-executor-mojo-executor-parent-2.4.1/mojo-executor-maven-plugin/src/itinvoker.properties000066400000000000000000000001261473775257600411160ustar00rootroot00000000000000mojo-executor-mojo-executor-parent-2.4.1/mojo-executor-maven-plugin/src/it/mojo-executor-test-project-quietinvoker.goals=clean install -Dquiet=true invoker.goals=-q clean install -Dquiet=false pom.xml000066400000000000000000000056001473775257600366420ustar00rootroot00000000000000mojo-executor-mojo-executor-parent-2.4.1/mojo-executor-maven-plugin/src/it/mojo-executor-test-project-quiet 4.0.0 org.twdata.maven mojo-executor-test-project-quiet 1.0-SNAPSHOT Mojo Executor - Test Project Used by the tests for the Mojo Executor Maven Plugin. org.slf4j slf4j-api 1.7.36 provided org.slf4j slf4j-nop 1.7.36 runtime junit junit-dep 4.11 test org.twdata.maven mojo-executor-maven-plugin @project.version@ test execute-mojo ${quiet} org.apache.maven.plugins maven-dependency-plugin 2.0 list postbuild.groovy000066400000000000000000000017311473775257600406020ustar00rootroot00000000000000mojo-executor-mojo-executor-parent-2.4.1/mojo-executor-maven-plugin/src/it/mojo-executor-test-project-quiet/* * 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") def text = buildLog.getText() text = text.replaceAll("\r\n", "\n") return ! text.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.36:provided [INFO] org.slf4j:slf4j-nop:jar:1.7.36:runtime """); mojo-executor-test-project-with-dependencies/000077500000000000000000000000001473775257600375745ustar00rootroot00000000000000mojo-executor-mojo-executor-parent-2.4.1/mojo-executor-maven-plugin/src/itpom.xml000066400000000000000000000072551473775257600411220ustar00rootroot00000000000000mojo-executor-mojo-executor-parent-2.4.1/mojo-executor-maven-plugin/src/it/mojo-executor-test-project-with-dependencies 4.0.0 org.twdata.maven mojo-executor-test-project 1.0-SNAPSHOT Mojo Executor - Test Project Used by the tests for the Mojo Executor Maven Plugin. org.twdata.maven mojo-executor-maven-plugin @project.version@ test execute-mojo org.apache.maven.plugins maven-antrun-plugin 1.6 ant-contrib ant-contrib 1.0b3 ant ant org.apache.ant ant-nodeps 1.8.1 run ${pluginName} ran successfully. postbuild.groovy000066400000000000000000000013421473775257600430500ustar00rootroot00000000000000mojo-executor-mojo-executor-parent-2.4.1/mojo-executor-maven-plugin/src/it/mojo-executor-test-project-with-dependencies/* * 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. */ File buildLog = new File((String) basedir, "build.log") return buildLog.readLines().contains(" [echo] Mojo Executor ran successfully."); mojo-executor-test-project/000077500000000000000000000000001473775257600341775ustar00rootroot00000000000000mojo-executor-mojo-executor-parent-2.4.1/mojo-executor-maven-plugin/src/itpom.xml000066400000000000000000000055061473775257600355220ustar00rootroot00000000000000mojo-executor-mojo-executor-parent-2.4.1/mojo-executor-maven-plugin/src/it/mojo-executor-test-project 4.0.0 org.twdata.maven mojo-executor-test-project 1.0-SNAPSHOT Mojo Executor - Test Project Used by the tests for the Mojo Executor Maven Plugin. org.slf4j slf4j-api 1.7.36 provided org.slf4j slf4j-nop 1.7.36 runtime junit junit-dep 4.11 test org.twdata.maven mojo-executor-maven-plugin @project.version@ test execute-mojo org.apache.maven.plugins maven-dependency-plugin 2.0 list postbuild.groovy000066400000000000000000000017271473775257600374620ustar00rootroot00000000000000mojo-executor-mojo-executor-parent-2.4.1/mojo-executor-maven-plugin/src/it/mojo-executor-test-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") def text = buildLog.getText() text = text.replaceAll("\r\n", "\n") return text.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.36:provided [INFO] org.slf4j:slf4j-nop:jar:1.7.36:runtime """); mojo-executor-mojo-executor-parent-2.4.1/mojo-executor-maven-plugin/src/it/settings.xml000066400000000000000000000033031473775257600314160ustar00rootroot00000000000000 defaultProfile true local.central @localRepositoryUrl@ true true local.central @localRepositoryUrl@ true true mojo-executor-mojo-executor-parent-2.4.1/mojo-executor-maven-plugin/src/main/000077500000000000000000000000001473775257600273455ustar00rootroot00000000000000mojo-executor-mojo-executor-parent-2.4.1/mojo-executor-maven-plugin/src/main/java/000077500000000000000000000000001473775257600302665ustar00rootroot00000000000000mojo-executor-mojo-executor-parent-2.4.1/mojo-executor-maven-plugin/src/main/java/org/000077500000000000000000000000001473775257600310555ustar00rootroot00000000000000mojo-executor-mojo-executor-parent-2.4.1/mojo-executor-maven-plugin/src/main/java/org/twdata/000077500000000000000000000000001473775257600323415ustar00rootroot00000000000000mojo-executor-mojo-executor-parent-2.4.1/mojo-executor-maven-plugin/src/main/java/org/twdata/maven/000077500000000000000000000000001473775257600334475ustar00rootroot00000000000000mojoexecutor/000077500000000000000000000000001473775257600361135ustar00rootroot00000000000000mojo-executor-mojo-executor-parent-2.4.1/mojo-executor-maven-plugin/src/main/java/org/twdata/mavenplugin/000077500000000000000000000000001473775257600374115ustar00rootroot00000000000000mojo-executor-mojo-executor-parent-2.4.1/mojo-executor-maven-plugin/src/main/java/org/twdata/maven/mojoexecutorMojoExecutorMojo.java000066400000000000000000000131351473775257600435270ustar00rootroot00000000000000mojo-executor-mojo-executor-parent-2.4.1/mojo-executor-maven-plugin/src/main/java/org/twdata/maven/mojoexecutor/plugin/* * 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. */ package org.twdata.maven.mojoexecutor.plugin; import org.apache.commons.lang3.reflect.FieldUtils; import org.apache.maven.cli.logging.Slf4jConfiguration; import org.apache.maven.cli.logging.Slf4jConfigurationFactory; import org.apache.maven.execution.MavenSession; import org.apache.maven.model.Plugin; import org.apache.maven.plugin.AbstractMojo; import org.apache.maven.plugin.BuildPluginManager; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugins.annotations.*; import org.apache.maven.project.MavenProject; import org.codehaus.plexus.configuration.PlexusConfiguration; import org.codehaus.plexus.logging.Logger; import org.slf4j.ILoggerFactory; import org.slf4j.LoggerFactory; import java.util.HashSet; import java.util.Set; import static java.lang.String.format; import static org.twdata.maven.mojoexecutor.MojoExecutor.executeMojo; import static org.twdata.maven.mojoexecutor.MojoExecutor.executionEnvironment; import static org.twdata.maven.mojoexecutor.PlexusConfigurationUtils.toXpp3Dom; /** * Execute a Mojo using the MojoExecutor. */ @SuppressWarnings("unused") @Mojo(name = "execute-mojo", defaultPhase = LifecyclePhase.TEST, requiresDependencyResolution = ResolutionScope.TEST) public class MojoExecutorMojo extends AbstractMojo { private static final Set lockedKeys = new HashSet<>(); /** * Plugin to execute. */ @Parameter(required = true) private Plugin plugin; /** * Plugin goal to execute. */ @Parameter(required = true) private String goal; /** * Plugin configuration to use in the execution. */ @Parameter private PlexusConfiguration configuration; /** * The project currently being build. */ @Parameter(defaultValue = "${project}", readonly = true) private MavenProject mavenProject; /** * The current Maven session. */ @Parameter(defaultValue = "${session}", readonly = true) private MavenSession mavenSession; /** * The Maven BuildPluginManager component. */ @Component private BuildPluginManager pluginManager; /** * Disable logging on executed mojos */ @Parameter(defaultValue = "false") private boolean quiet; /** * Enable thread blocking per plugin GA (groupId & artifactId) */ @Parameter(defaultValue = "false") private boolean blocking; /** * Ignore injected maven projetc */ @Parameter(defaultValue = "false") private boolean ignoreMavenProject; public void execute() throws MojoExecutionException { getLog().info("Executing with maven project " + mavenProject + " for session " + mavenSession); if (quiet) { disableLogging(); } // Blocking case. if (blocking) { final String key = format("%s:%s", plugin.getGroupId(), plugin.getArtifactId()); try { lock(key); getLog().info(String.format("Executing '%s' in blocking mode.", key)); //Put your code here. //For different keys it is executed in parallel. //For equal keys it is executed synchronously. executeMojoImpl(); } catch (InterruptedException e) { final String failed = "Failed to execute mojo"; getLog().error(failed, e); throw new MojoExecutionException(failed, e); } finally { unlock(key); getLog().info(String.format("Released '%s' block.", key)); } } else { // Non blocking case. executeMojoImpl(); } } private void executeMojoImpl() throws MojoExecutionException { executeMojo(plugin, goal, toXpp3Dom(configuration), (ignoreMavenProject ? executionEnvironment(mavenSession, pluginManager) : executionEnvironment(mavenProject, mavenSession, pluginManager))); } private void disableLogging() throws MojoExecutionException { // Maven < 3.1 Logger logger; try { logger = (Logger) FieldUtils.readField(getLog(), "logger", true); } catch (IllegalAccessException e) { throw new MojoExecutionException("Unable to access logger field ", e); } logger.setThreshold(5); // Maven >= 3.1 ILoggerFactory slf4jLoggerFactory = LoggerFactory.getILoggerFactory(); Slf4jConfiguration slf4jConfiguration = Slf4jConfigurationFactory.getConfiguration(slf4jLoggerFactory); slf4jConfiguration.setRootLoggerLevel(Slf4jConfiguration.Level.ERROR); slf4jConfiguration.activate(); } private void lock(String key) throws InterruptedException { synchronized (lockedKeys) { while (!lockedKeys.add(key)) { lockedKeys.wait(); } } } private void unlock(String key) { synchronized (lockedKeys) { lockedKeys.remove(key); lockedKeys.notifyAll(); } } } mojo-executor-mojo-executor-parent-2.4.1/mojo-executor/000077500000000000000000000000001473775257600232325ustar00rootroot00000000000000mojo-executor-mojo-executor-parent-2.4.1/mojo-executor/pom.xml000066400000000000000000000060761473775257600245600ustar00rootroot00000000000000 4.0.0 org.twdata.maven mojo-executor-parent 2.4.1 mojo-executor Mojo Executor org.apache.maven maven-core provided org.apache.maven maven-model provided org.apache.maven maven-plugin-api provided org.slf4j slf4j-api provided org.codehaus.plexus plexus-utils compile org.eclipse.sisu org.eclipse.sisu.plexus provided junit junit test org.hamcrest hamcrest-core test org.mockito mockito-core test org.slf4j slf4j-simple test mojo-executor-mojo-executor-parent-2.4.1/mojo-executor/src/000077500000000000000000000000001473775257600240215ustar00rootroot00000000000000mojo-executor-mojo-executor-parent-2.4.1/mojo-executor/src/main/000077500000000000000000000000001473775257600247455ustar00rootroot00000000000000mojo-executor-mojo-executor-parent-2.4.1/mojo-executor/src/main/java/000077500000000000000000000000001473775257600256665ustar00rootroot00000000000000mojo-executor-mojo-executor-parent-2.4.1/mojo-executor/src/main/java/org/000077500000000000000000000000001473775257600264555ustar00rootroot00000000000000mojo-executor-mojo-executor-parent-2.4.1/mojo-executor/src/main/java/org/twdata/000077500000000000000000000000001473775257600277415ustar00rootroot00000000000000mojo-executor-mojo-executor-parent-2.4.1/mojo-executor/src/main/java/org/twdata/maven/000077500000000000000000000000001473775257600310475ustar00rootroot00000000000000mojo-executor-mojo-executor-parent-2.4.1/mojo-executor/src/main/java/org/twdata/maven/mojoexecutor/000077500000000000000000000000001473775257600335725ustar00rootroot00000000000000MavenCompatibilityHelper.java000066400000000000000000000105151473775257600413200ustar00rootroot00000000000000mojo-executor-mojo-executor-parent-2.4.1/mojo-executor/src/main/java/org/twdata/maven/mojoexecutor/* * Copyright 2013 Robert Munteanu * * 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. */ package org.twdata.maven.mojoexecutor; import org.apache.maven.execution.MavenSession; import org.apache.maven.model.Plugin; import org.apache.maven.plugin.BuildPluginManager; import org.apache.maven.plugin.InvalidPluginDescriptorException; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.PluginDescriptorParsingException; import org.apache.maven.plugin.PluginNotFoundException; import org.apache.maven.plugin.PluginResolutionException; import org.apache.maven.plugin.descriptor.PluginDescriptor; import org.eclipse.aether.repository.RemoteRepository; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.twdata.maven.mojoexecutor.MojoExecutor.ExecutionEnvironment; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.util.List; /** * The {@code MavenCompatibilityHelper} hides incompatibilities between Maven versions * */ public class MavenCompatibilityHelper { private static final Logger logger = LoggerFactory.getLogger( MavenCompatibilityHelper.class ); private static Method getRepositorySession; private static Method loadPlugin; static { for (Method m : MavenSession.class.getMethods()) { if ("getRepositorySession".equals(m.getName())) { getRepositorySession = m; break; } } if (getRepositorySession == null) { throw new ExceptionInInitializerError("Unable to locate getRepositorySession method"); } for (Method m : BuildPluginManager.class.getMethods()) { if ("loadPlugin".equals(m.getName())) { loadPlugin = m; break; } } if (loadPlugin == null) { throw new ExceptionInInitializerError("Unable to locate loadPluginDescriptor method"); } } public static PluginDescriptor loadPluginDescriptor(Plugin plugin, ExecutionEnvironment env, MavenSession session) throws PluginResolutionException, PluginDescriptorParsingException, InvalidPluginDescriptorException, PluginNotFoundException, MojoExecutionException { try { Object repositorySession = getRepositorySession.invoke(session); BuildPluginManager pluginManager = env.getPluginManager(); List repositories = null; if ( session.getCurrentProject() != null ) { repositories = session.getCurrentProject().getRemotePluginRepositories(); } logger.debug("Attempting to load plugin {} using pluginManager {} and repositories {}", plugin, pluginManager, repositories); return (PluginDescriptor) loadPlugin.invoke(pluginManager, plugin, repositories, repositorySession); } catch (IllegalAccessException e) { throw new MojoExecutionException("Unable to access plugin", e); } catch (InvocationTargetException e) { logger.debug("Unable to invoke plugin", e.getCause()); // Unwrap the exception to throw the correct type. if (e.getCause() instanceof PluginNotFoundException) { throw ((PluginNotFoundException) e.getCause()); } else if (e.getCause() instanceof PluginResolutionException) { throw ((PluginResolutionException) e.getCause()); } else if (e.getCause() instanceof PluginDescriptorParsingException) { throw ((PluginDescriptorParsingException) e.getCause()); } else if (e.getCause() instanceof InvalidPluginDescriptorException) { throw ((InvalidPluginDescriptorException) e.getCause()); } else { throw new MojoExecutionException("Unable to invoke plugin", e.getCause()); } } } } MojoExecutor.java000066400000000000000000000416501473775257600370070ustar00rootroot00000000000000mojo-executor-mojo-executor-parent-2.4.1/mojo-executor/src/main/java/org/twdata/maven/mojoexecutor/* * 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. */ package org.twdata.maven.mojoexecutor; import org.apache.maven.execution.MavenSession; import org.apache.maven.model.Dependency; import org.apache.maven.model.Plugin; import org.apache.maven.model.PluginManagement; import org.apache.maven.plugin.BuildPluginManager; import org.apache.maven.plugin.InvalidPluginDescriptorException; import org.apache.maven.plugin.MojoExecution; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; import org.apache.maven.plugin.PluginConfigurationException; import org.apache.maven.plugin.PluginDescriptorParsingException; import org.apache.maven.plugin.PluginManagerException; import org.apache.maven.plugin.PluginNotFoundException; import org.apache.maven.plugin.PluginResolutionException; import org.apache.maven.plugin.descriptor.MojoDescriptor; import org.apache.maven.plugin.descriptor.PluginDescriptor; import org.apache.maven.project.MavenProject; import org.codehaus.plexus.util.xml.Xpp3Dom; import org.codehaus.plexus.util.xml.Xpp3DomUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.util.Arrays; import java.util.Collections; import java.util.List; import static org.twdata.maven.mojoexecutor.PlexusConfigurationUtils.toXpp3Dom; /** * Executes an arbitrary mojo using a fluent interface. This is meant to be executed within the context of a Maven mojo. Here is an * execution that invokes the dependency plugin: *
 * 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(
 *                      project,
 *                      session,
 *                      pluginManager
 *              )
 *          );
 * 
*/ @SuppressWarnings("WeakerAccess") public class MojoExecutor { private static final Logger logger = LoggerFactory.getLogger( MojoExecutor.class ); /** * Entry point for executing a mojo * * @param plugin The plugin to execute * @param goal The goal to execute * @param configuration The execution configuration * @param env The execution environment * @throws MojoExecutionException If there are any exceptions locating or executing the mojo */ public static void executeMojo(Plugin plugin, String goal, Xpp3Dom configuration, ExecutionEnvironment env) throws MojoExecutionException { logger.debug("Running executeMojo for {}", plugin); if (configuration == null) { throw new NullPointerException("configuration may not be null"); } try { String executionId = null; if (goal != null && goal.length() > 0 && goal.indexOf('#') > -1) { int pos = goal.indexOf('#'); executionId = goal.substring(pos + 1); goal = goal.substring(0, pos); } MavenSession session = env.getMavenSession(); MavenProject currentProject = env.getMavenSession().getCurrentProject(); if ((plugin.getVersion() == null || plugin.getVersion().length() == 0) && currentProject != null) { PluginManagement pm = currentProject.getPluginManagement(); if (pm != null) { for (Plugin p : pm.getPlugins()) { if (plugin.getGroupId().equals(p.getGroupId()) && plugin.getArtifactId().equals(p.getArtifactId())) { plugin.setVersion(p.getVersion()); break; } } } } PluginDescriptor pluginDescriptor = MavenCompatibilityHelper.loadPluginDescriptor(plugin, env, session); MojoDescriptor mojoDescriptor = pluginDescriptor.getMojo(goal); if (mojoDescriptor == null) { throw new MojoExecutionException("Could not find goal '" + goal + "' in plugin " + plugin.getGroupId() + ":" + plugin.getArtifactId() + ":" + plugin.getVersion()); } MojoExecution exec = mojoExecution(mojoDescriptor, executionId, configuration); env.getPluginManager().executeMojo(session, exec); } catch (PluginConfigurationException | PluginNotFoundException | InvalidPluginDescriptorException | PluginManagerException | PluginDescriptorParsingException | MojoFailureException | PluginResolutionException e) { throw new MojoExecutionException("Unable to execute mojo", e); } } private static MojoExecution mojoExecution(MojoDescriptor mojoDescriptor, String executionId, Xpp3Dom configuration) { configuration = Xpp3DomUtils.mergeXpp3Dom(configuration, toXpp3Dom(mojoDescriptor.getMojoConfiguration())); if (executionId != null) { MojoExecution mojoExecution = new MojoExecution(mojoDescriptor, executionId); mojoExecution.setConfiguration(configuration); return mojoExecution; } else { return new MojoExecution(mojoDescriptor, configuration); } } /** * Constructs the {@link ExecutionEnvironment} instance fluently * * @param mavenProject The current Maven project * @param mavenSession The current Maven session * @param pluginManager The Build plugin manager * @return The execution environment * @throws NullPointerException if mavenProject, mavenSession or pluginManager * are null */ public static ExecutionEnvironment executionEnvironment(MavenProject mavenProject, MavenSession mavenSession, BuildPluginManager pluginManager) { return new ExecutionEnvironment(mavenProject, mavenSession, pluginManager); } /** * Constructs the {@link ExecutionEnvironment} instance fluently * * @param mavenSession The current Maven session * @param pluginManager The Build plugin manager * @return The execution environment * @throws NullPointerException if mavenProject, mavenSession or pluginManager * are null */ public static ExecutionEnvironment executionEnvironment(MavenSession mavenSession, BuildPluginManager pluginManager) { return new ExecutionEnvironment(mavenSession, pluginManager); } /** * Builds the configuration for the goal using Elements * * @param elements A list of elements for the configuration section * @return The elements transformed into the Maven-native XML format */ public static Xpp3Dom configuration(Element... elements) { Xpp3Dom dom = new Xpp3Dom("configuration"); for (Element e : elements) { dom.addChild(e.toDom()); } return dom; } /** * Defines the plugin without its version or dependencies. * * @param groupId The group id * @param artifactId The artifact id * @return The plugin instance */ public static Plugin plugin(String groupId, String artifactId) { return plugin(groupId, artifactId, null); } /** * Defines a plugin without dependencies. * * @param groupId The group id * @param artifactId The artifact id * @param version The plugin version * @return The plugin instance */ public static Plugin plugin(String groupId, String artifactId, String version) { return plugin(groupId, artifactId, version, Collections.emptyList()); } /** * Defines a plugin. * * @param groupId The group id * @param artifactId The artifact id * @param version The plugin version * @param dependencies The plugin dependencies * @return The plugin instance */ public static Plugin plugin(String groupId, String artifactId, String version, List dependencies) { Plugin plugin = new Plugin(); plugin.setArtifactId(artifactId); plugin.setGroupId(groupId); plugin.setVersion(version); plugin.setDependencies(dependencies); return plugin; } /** * Wraps the group id string in a more readable format * * @param groupId The value * @return The value */ public static String groupId(String groupId) { return groupId; } /** * Wraps the artifact id string in a more readable format * * @param artifactId The value * @return The value */ public static String artifactId(String artifactId) { return artifactId; } /** * Wraps the version string in a more readable format * * @param version The value * @return The value */ public static String version(String version) { return version; } /** * Creates a list of dependencies. * * @param dependencies the dependencies * @return A list of dependencies */ public static List dependencies(Dependency... dependencies) { return Arrays.asList(dependencies); } /** * Defines a dependency * * @param groupId The group id * @param artifactId The artifact id * @param version The plugin version * @return the dependency instance */ public static Dependency dependency(String groupId, String artifactId, String version) { Dependency dependency = new Dependency(); dependency.setGroupId(groupId); dependency.setArtifactId(artifactId); dependency.setVersion(version); return dependency; } /** * Wraps the goal string in a more readable format * * @param goal The value * @return The value */ public static String goal(String goal) { return goal; } /** * Wraps the element name string in a more readable format * * @param name The value * @return The value */ public static String name(String name) { return name; } /** * Constructs the element with a textual body * * @param name The element name * @param value The element text value * @return The element object */ public static Element element(String name, String value) { return new Element(name, value); } /** * Constructs the element with a textual body and attributes * * @param name The element name * @param value The element text value * @param attributes The element attributes * @return The element object */ public static Element element(String name, String value, Attributes attributes) { return new Element(name, value, attributes); } /** * Constructs the element with a textual body and only attribute * * @param name The element name * @param value The element text value * @param attribute The element attribute * @return The element object */ public static Element element(String name, String value, Attribute attribute) { return new Element(name, value, new Attributes(attribute)); } /** * Constructs the element containing child elements * * @param name The element name * @param elements The child elements * @return The Element object */ public static Element element(String name, Element... elements) { return new Element(name, elements); } /** * Constructs the element containing child elements and attributes * * @param name The element name * @param attributes The element attributes * @param elements The child elements * @return The Element object */ public static Element element(String name, Attributes attributes, Element... elements) { return new Element(name, attributes, elements); } /** * Constructs the element containing child elements and only attribute * * @param name The element name * @param attribute The element attribute * @param elements The child elements * @return The Element object */ public static Element element(String name, Attribute attribute, Element... elements) { return new Element(name, new Attributes(attribute), elements); } /** * Constructs the attributes wrapper * * @param attributes The attributes * @return The Attributes object */ public static Attributes attributes(Attribute ... attributes) { return new Attributes(attributes); } /** * Constructs the attribute * * @param name The attribute name * @param value The attribute value * @return The Attribute object */ public static Attribute attribute(String name, String value) { return new Attribute(name, value); } /** * Element wrapper class for configuration elements */ public static class Element { private final Element[] children; private final String name; private final String text; private final Attributes attributes; public Element(String name, Element... children) { this(name, null, new Attributes(), children); } public Element(String name, Attributes attributes, Element... children) { this(name, null, attributes, children); } public Element(String name, String text, Element... children) { this.name = name; this.text = text; this.children = children; this.attributes = new Attributes(); } public Element(String name, String text, Attributes attributes, Element... children) { this.name = name; this.text = text; this.children = children; this.attributes = attributes; } public Xpp3Dom toDom() { Xpp3Dom dom = new Xpp3Dom(name); if (text != null) { dom.setValue(text); } for (Element e : children) { dom.addChild(e.toDom()); } for(Attribute attribute : attributes.attributes) { dom.setAttribute(attribute.name, attribute.value); } return dom; } } /** * Collection of attributes wrapper class */ public static class Attributes { private List attributes; public Attributes(Attribute ... attributes) { this.attributes = Arrays.asList(attributes); } } /** * Attribute wrapper class */ public static class Attribute { private final String name; private final String value; public Attribute(String name, String value) { this.name = name; this.value = value; } } /** * Collects Maven execution information */ public static class ExecutionEnvironment { private final MavenProject mavenProject; private final MavenSession mavenSession; private final BuildPluginManager pluginManager; public ExecutionEnvironment(MavenProject mavenProject, MavenSession mavenSession, BuildPluginManager pluginManager) { if (mavenSession == null) { throw new NullPointerException("mavenSession may not be null"); } if (pluginManager == null) { throw new NullPointerException("pluginManager may not be null"); } this.mavenProject = mavenProject; this.mavenSession = mavenSession; this.pluginManager = pluginManager; } public ExecutionEnvironment(MavenSession mavenSession, BuildPluginManager pluginManager) { this ( null, mavenSession, pluginManager); } public MavenProject getMavenProject() { return mavenProject; } public MavenSession getMavenSession() { return mavenSession; } public BuildPluginManager getPluginManager() { return pluginManager; } } } PlexusConfigurationUtils.java000066400000000000000000000017001473775257600414050ustar00rootroot00000000000000mojo-executor-mojo-executor-parent-2.4.1/mojo-executor/src/main/java/org/twdata/maven/mojoexecutorpackage org.twdata.maven.mojoexecutor; import org.codehaus.plexus.configuration.PlexusConfiguration; import org.codehaus.plexus.util.xml.Xpp3Dom; public class PlexusConfigurationUtils { private PlexusConfigurationUtils() { throw new AssertionError("non-instantiable"); } /** * Converts PlexusConfiguration to a Xpp3Dom. * * @param config the PlexusConfiguration. Must not be {@code null}. * @return the Xpp3Dom representation of the PlexusConfiguration */ public static Xpp3Dom toXpp3Dom(PlexusConfiguration config) { Xpp3Dom result = new Xpp3Dom(config.getName()); result.setValue(config.getValue(null)); for (String name : config.getAttributeNames()) { result.setAttribute(name, config.getAttribute(name)); } for (PlexusConfiguration child : config.getChildren()) { result.addChild(toXpp3Dom(child)); } return result; } } mojo-executor-mojo-executor-parent-2.4.1/mojo-executor/src/test/000077500000000000000000000000001473775257600250005ustar00rootroot00000000000000mojo-executor-mojo-executor-parent-2.4.1/mojo-executor/src/test/java/000077500000000000000000000000001473775257600257215ustar00rootroot00000000000000mojo-executor-mojo-executor-parent-2.4.1/mojo-executor/src/test/java/org/000077500000000000000000000000001473775257600265105ustar00rootroot00000000000000mojo-executor-mojo-executor-parent-2.4.1/mojo-executor/src/test/java/org/twdata/000077500000000000000000000000001473775257600277745ustar00rootroot00000000000000mojo-executor-mojo-executor-parent-2.4.1/mojo-executor/src/test/java/org/twdata/maven/000077500000000000000000000000001473775257600311025ustar00rootroot00000000000000mojo-executor-mojo-executor-parent-2.4.1/mojo-executor/src/test/java/org/twdata/maven/mojoexecutor/000077500000000000000000000000001473775257600336255ustar00rootroot00000000000000MojoExecutorTest.java000066400000000000000000000377411473775257600377100ustar00rootroot00000000000000mojo-executor-mojo-executor-parent-2.4.1/mojo-executor/src/test/java/org/twdata/maven/mojoexecutor/* * 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. */ package org.twdata.maven.mojoexecutor; import org.apache.maven.execution.MavenSession; import org.apache.maven.model.Plugin; import org.apache.maven.plugin.BuildPluginManager; import org.apache.maven.plugin.MojoExecution; import org.apache.maven.plugin.descriptor.MojoDescriptor; import org.apache.maven.plugin.descriptor.PluginDescriptor; import org.apache.maven.project.MavenProject; import org.codehaus.plexus.configuration.xml.XmlPlexusConfiguration; import org.codehaus.plexus.util.xml.Xpp3Dom; import org.eclipse.aether.RepositorySystemSession; import org.hamcrest.CoreMatchers; import org.hamcrest.Description; import org.hamcrest.Matcher; import org.hamcrest.TypeSafeDiagnosingMatcher; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.AdditionalMatchers; import org.mockito.Mock; import java.util.List; import java.util.Map; import org.mockito.junit.MockitoJUnitRunner; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.CoreMatchers.sameInstance; import static org.mockito.ArgumentMatchers.anyList; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.ArgumentMatchers.isNull; import static org.mockito.ArgumentMatchers.same; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import static org.mockito.hamcrest.MockitoHamcrest.argThat; import static org.twdata.maven.mojoexecutor.MojoExecutor.artifactId; import static org.twdata.maven.mojoexecutor.MojoExecutor.attribute; import static org.twdata.maven.mojoexecutor.MojoExecutor.attributes; import static org.twdata.maven.mojoexecutor.MojoExecutor.configuration; import static org.twdata.maven.mojoexecutor.MojoExecutor.dependencies; import static org.twdata.maven.mojoexecutor.MojoExecutor.dependency; import static org.twdata.maven.mojoexecutor.MojoExecutor.element; import static org.twdata.maven.mojoexecutor.MojoExecutor.executeMojo; import static org.twdata.maven.mojoexecutor.MojoExecutor.executionEnvironment; import static org.twdata.maven.mojoexecutor.MojoExecutor.goal; import static org.twdata.maven.mojoexecutor.MojoExecutor.groupId; import static org.twdata.maven.mojoexecutor.MojoExecutor.name; import static org.twdata.maven.mojoexecutor.MojoExecutor.plugin; import static org.twdata.maven.mojoexecutor.MojoExecutor.version; @RunWith(MockitoJUnitRunner.class) public class MojoExecutorTest { @Mock MavenProject project; @Mock MavenSession session; @Mock RepositorySystemSession repositorySession; @Mock BuildPluginManager pluginManager; private MojoDescriptor copyDependenciesMojoDescriptor; @Before public void setUpMocks() throws Exception { PluginDescriptor mavenDependencyPluginDescriptor = new PluginDescriptor(); copyDependenciesMojoDescriptor = new MojoDescriptor(); copyDependenciesMojoDescriptor.setGoal("copy-dependencies"); copyDependenciesMojoDescriptor.setConfiguration(new XmlPlexusConfiguration("configuration")); copyDependenciesMojoDescriptor.setPluginDescriptor(mavenDependencyPluginDescriptor); mavenDependencyPluginDescriptor.addMojo(copyDependenciesMojoDescriptor); when(session.getRepositorySession()).thenReturn(repositorySession); when(pluginManager.loadPlugin( eq(plugin( groupId("org.apache.maven.plugins"), artifactId("maven-dependency-plugin"), version("2.0"), dependencies( dependency("org.apache.maven.plugins", "some-plugin", "1.0") ) )), AdditionalMatchers.or(anyList(), isNull()), same(repositorySession) )).thenReturn(mavenDependencyPluginDescriptor); } @Test public void executeMojoWithoutExecutionIdExecutesMojoWithAttributesInConfiguration() throws Exception { executeMojo( plugin( groupId("org.apache.maven.plugins"), artifactId("maven-dependency-plugin"), version("2.0"), dependencies( dependency("org.apache.maven.plugins", "some-plugin", "1.0") ) ), goal("copy-dependencies"), configuration( element( name("outputDirectory"), attributes( attribute("dir", "${project.build.directory}/foo"), attribute("force", "true") ) ), element( "without-attrs", element( "without-attrs", "value" ) ), element( "only-attribute", attribute("attribute", "value") ) ), executionEnvironment( project, session, pluginManager ) ); verify(pluginManager) .executeMojo( same(session), argThat(is(equalTo(new MojoExecution( copyDependenciesMojoDescriptor, configuration( element( name("outputDirectory"), attributes( attribute("dir", "${project.build.directory}/foo"), attribute("force", "true") ) ), element( "without-attrs", element( "without-attrs", "value" ) ), element( "only-attribute", attributes( attribute("attribute", "value") ) ) ) )))) ); } @Test public void executeMojoWithoutExecutionIdExecutesMojoWithExplicitConfiguration() throws Exception { executeMojo( plugin( groupId("org.apache.maven.plugins"), artifactId("maven-dependency-plugin"), version("2.0"), dependencies( dependency("org.apache.maven.plugins", "some-plugin", "1.0") ) ), goal("copy-dependencies"), configuration( element(name("outputDirectory"), "${project.build.directory}/foo") ), executionEnvironment( project, session, pluginManager ) ); verify(pluginManager) .executeMojo( same(session), argThat(is(equalTo(new MojoExecution( copyDependenciesMojoDescriptor, configuration( element(name("outputDirectory"), "${project.build.directory}/foo") ) )))) ); } @Test public void executeMojoWithoutExecutionIdExecutesMojoWithExplicitConfigurationNoProject() throws Exception { executeMojo( plugin( groupId("org.apache.maven.plugins"), artifactId("maven-dependency-plugin"), version("2.0"), dependencies( dependency("org.apache.maven.plugins", "some-plugin", "1.0") ) ), goal("copy-dependencies"), configuration( element(name("outputDirectory"), "${project.build.directory}/foo") ), executionEnvironment( null, session, pluginManager ) ); verify(pluginManager) .executeMojo( same(session), argThat(is(equalTo(new MojoExecution( copyDependenciesMojoDescriptor, configuration( element(name("outputDirectory"), "${project.build.directory}/foo") ) )))) ); } @Test public void executeMojoWithoutExecutionIdExecutesMojoWithExplicitConfigurationIgnoreProject() throws Exception { executeMojo( plugin( groupId("org.apache.maven.plugins"), artifactId("maven-dependency-plugin"), version("2.0"), dependencies( dependency("org.apache.maven.plugins", "some-plugin", "1.0") ) ), goal("copy-dependencies"), configuration( element(name("outputDirectory"), "${project.build.directory}/foo") ), executionEnvironment( session, pluginManager ) ); verify(pluginManager) .executeMojo( same(session), argThat(is(equalTo(new MojoExecution( copyDependenciesMojoDescriptor, configuration( element(name("outputDirectory"), "${project.build.directory}/foo") ) )))) ); } @Test public void executeMojoWithExecutionIdExecutesMojoWithMatchingExecutionId() throws Exception { executeMojo( plugin( groupId("org.apache.maven.plugins"), artifactId("maven-dependency-plugin"), version("2.0"), dependencies( dependency("org.apache.maven.plugins", "fake-plugin", "1.0") ) ), goal("copy-dependencies#execution"), configuration( element(name("outputDirectory"), "${project.build.directory}/foo") ), executionEnvironment( project, session, pluginManager ) ); MojoExecution mojoExecution = new MojoExecution(copyDependenciesMojoDescriptor, "execution"); mojoExecution.setConfiguration(configuration( element(name("outputDirectory"), "${project.build.directory}/foo") )); verify(pluginManager) .executeMojo( same(session), argThat(is(equalTo(mojoExecution))) ); } private static Matcher equalTo(MojoExecution mojoExecution) { return new MojoExecutionIsEqual(mojoExecution); } // This is needed because the equalTo(MojoExecution method above shadows a static import of CoreMatchers.equalTo. private static Matcher equalTo(T match) { return CoreMatchers.equalTo(match); } private static class MojoExecutionIsEqual extends TypeSafeDiagnosingMatcher { private final Matcher plugin; private final Matcher goal; private final Matcher executionId; private final Matcher mojoDescriptor; private final Matcher configuration; private final Matcher source; private final Matcher lifecyclePhase; private final Matcher>> forkedExecutions; MojoExecutionIsEqual(MojoExecution mojoExecution) { plugin = is(equalTo(mojoExecution.getPlugin())); goal = is(equalTo(mojoExecution.getGoal())); executionId = is(equalTo(mojoExecution.getExecutionId())); mojoDescriptor = is(equalTo(mojoExecution.getMojoDescriptor())); configuration = is(equalTo(mojoExecution.getConfiguration())); source = is(sameInstance(mojoExecution.getSource())); lifecyclePhase = is(equalTo(mojoExecution.getLifecyclePhase())); forkedExecutions = is(equalTo(mojoExecution.getForkedExecutions())); } @Override protected boolean matchesSafely(MojoExecution mojoExecution, Description mismatchDescription) { boolean matches = true; matches = tryMatch("plugin", plugin, mojoExecution.getPlugin(), mismatchDescription, matches); matches = tryMatch("goal", goal, mojoExecution.getGoal(), mismatchDescription, matches); matches = tryMatch("executionId", executionId, mojoExecution.getExecutionId(), mismatchDescription, matches); matches = tryMatch("mojoDescriptor", mojoDescriptor, mojoExecution.getMojoDescriptor(), mismatchDescription, matches); matches = tryMatch("configuration", configuration, mojoExecution.getConfiguration(), mismatchDescription, matches); matches = tryMatch("source", source, mojoExecution.getSource(), mismatchDescription, matches); matches = tryMatch("lifecyclePhase", lifecyclePhase, mojoExecution.getLifecyclePhase(), mismatchDescription, matches); matches = tryMatch("forkedExecutions", forkedExecutions, mojoExecution.getForkedExecutions(), mismatchDescription, matches); return matches; } private boolean tryMatch(String name, Matcher matcher, Object item, Description mismatchDescription, boolean matches) { if (!matcher.matches(item)) { reportMismatch(name, matcher, item, mismatchDescription, matches); return false; } return matches; } private void reportMismatch(String name, Matcher matcher, Object item, Description mismatchDescription, boolean firstMismatch) { if (!firstMismatch) mismatchDescription.appendText(", "); mismatchDescription.appendText(name).appendText(" "); matcher.describeMismatch(item, mismatchDescription); } public void describeTo(Description description) { description.appendText("MojoExecution with plugin ") .appendDescriptionOf(plugin) .appendText(", goal ") .appendDescriptionOf(goal) .appendText(", executionId ") .appendDescriptionOf(executionId) .appendText(", mojoDescriptor ") .appendDescriptionOf(mojoDescriptor) .appendText(", configuration ") .appendDescriptionOf(configuration) .appendText(", source ") .appendDescriptionOf(source) .appendText(", lifecyclePhase") .appendDescriptionOf(lifecyclePhase) .appendText(", forkedExecutions ") .appendDescriptionOf(forkedExecutions); } } } mojo-executor-mojo-executor-parent-2.4.1/pom.xml000066400000000000000000000341121473775257600217500ustar00rootroot00000000000000 4.0.0 org.twdata.maven mojo-executor-parent 2.4.1 pom Mojo Executor Parent The Mojo Executor provides a way to execute other Mojos (plugins) within a Maven plugin, allowing you to easily create Maven plugins that are composed of other plugins. https://mojo-executor.github.io/mojo-executor/ 2008 Apache License, Version 2.0 http://www.apache.org/licenses/LICENSE-2.0 repo mrdon Don Brown mrdon@twdata.org Original Author TimMoore Tim Moore tmoore@incrementalism.net Current Maintainer rnc Nick Cross ncross@redhat.com Current Maintainer Jelmer Kuperus Olivier Lamy olamy@apache.org Matthew McCullough matthewm@ambientideas.com Robert Munteanu robert.munteanu@gmail.com Gili Tzabari cowwoc2020@gmail.com Joseph Walton joe@kafsemo.org mojo-executor mojo-executor-maven-plugin scm:git:https://github.com/mojo-executor/mojo-executor.git scm:git:ssh://git@github.com/mojo-executor/mojo-executor.git https://github.com/mojo-executor/mojo-executor mojo-executor-parent-2.4.1 GitHub https://github.com/mojo-executor/mojo-executor/issues ossrh https://oss.sonatype.org/content/repositories/snapshots/ ossrh https://oss.sonatype.org/service/local/staging/deploy/maven2/ UTF-8 3.3.1 org.apache.maven maven ${maven.version} import pom org.apache.maven maven-model ${maven.version} org.apache.maven.plugin-tools maven-plugin-annotations 3.13.1 org.apache.maven maven-embedder ${maven.version} org.codehaus.plexus plexus-utils 3.0.24 org.eclipse.sisu org.eclipse.sisu.plexus 0.3.0 org.slf4j slf4j-api 1.7.5 ${project.groupId} mojo-executor ${project.version} junit junit 4.13.2 test org.hamcrest hamcrest-core 2.2 test org.mockito mockito-core 5.11.0 test org.apache.commons commons-lang3 3.12.0 org.slf4j slf4j-simple 1.7.5 org.apache.maven.plugins maven-compiler-plugin 3.12.1 1.8 1.8 org.apache.maven.plugins maven-plugin-plugin 3.12.0 org.apache.maven.plugins maven-invoker-plugin 3.6.1 org.apache.maven.plugins maven-deploy-plugin 3.1.1 org.apache.maven.plugins maven-javadoc-plugin 3.6.3 org.apache.maven.plugins maven-source-plugin 3.3.1 org.apache.maven.plugins maven-gpg-plugin 3.2.7 org.apache.maven.plugins maven-release-plugin 3.0.1 org.apache.maven.plugins maven-clean-plugin 3.3.2 org.apache.maven.plugins maven-install-plugin 3.1.1 org.apache.maven.plugins maven-jar-plugin 3.3.0 org.apache.maven.plugins maven-resources-plugin 3.3.1 org.apache.maven.plugins maven-surefire-plugin 3.2.5 org.jacoco jacoco-maven-plugin 0.8.12 prepare-agent report test report org.sonatype.plugins nexus-staging-maven-plugin 1.6.13 org.apache.maven.plugins maven-enforcer-plugin 3.4.1 enforce-dependencies enforce [3.3.1,4.0) Version 2.x of Mojo Executor requires Maven ${maven.version}. Use Mojo Executor 1.x with Maven 2. org.apache.maven.plugins maven-release-plugin true false release deploy org.sonatype.plugins nexus-staging-maven-plugin true ossrh https://oss.sonatype.org/ true org.jacoco jacoco-maven-plugin prepare-agent report test report release org.apache.maven.plugins maven-source-plugin attach-sources jar-no-fork org.apache.maven.plugins maven-javadoc-plugin attach-javadocs jar org.apache.maven.plugins maven-gpg-plugin sign-artifacts verify sign