├── .github ├── release-drafter.yml ├── dependabot.yml └── workflows │ ├── release-drafter.yml │ └── maven.yml ├── src ├── it │ ├── regex-multi │ │ ├── invoker.properties │ │ ├── src │ │ │ └── main │ │ │ │ └── resources │ │ │ │ └── test.properties │ │ ├── verify.bsh │ │ └── pom.xml │ ├── regex-valid │ │ ├── invoker.properties │ │ ├── src │ │ │ └── main │ │ │ │ └── resources │ │ │ │ └── test.properties │ │ ├── verify.bsh │ │ └── pom.xml │ ├── bsh-property │ │ ├── invoker.properties │ │ └── pom.xml │ ├── timestamp-regex │ │ ├── invoker.properties │ │ ├── src │ │ │ └── main │ │ │ │ └── resources │ │ │ │ └── test.properties │ │ ├── verify.bsh │ │ └── pom.xml │ ├── timestamp-valid │ │ ├── invoker.properties │ │ ├── src │ │ │ └── main │ │ │ │ └── resources │ │ │ │ └── test.properties │ │ ├── verify.bsh │ │ └── pom.xml │ ├── timestamp-timesource │ │ ├── invoker.properties │ │ ├── module-1 │ │ │ ├── src │ │ │ │ └── main │ │ │ │ │ └── resources │ │ │ │ │ └── test.properties │ │ │ └── pom.xml │ │ ├── module-2 │ │ │ ├── src │ │ │ │ └── main │ │ │ │ │ └── resources │ │ │ │ │ └── test.properties │ │ │ └── pom.xml │ │ ├── verify.bsh │ │ └── pom.xml │ ├── addResource │ │ ├── src │ │ │ ├── my-resources │ │ │ │ └── resource.txt │ │ │ └── my-test-resources │ │ │ │ └── test-resource.txt │ │ └── pom.xml │ ├── regex-invalid │ │ ├── src │ │ │ └── main │ │ │ │ └── resources │ │ │ │ └── test.properties │ │ ├── invoker.properties │ │ └── pom.xml │ ├── regex-nomatch │ │ ├── src │ │ │ └── main │ │ │ │ └── resources │ │ │ │ └── test.properties │ │ ├── invoker.properties │ │ └── pom.xml │ ├── reserve-ports-with-urls │ │ ├── names1.txt │ │ ├── names2.txt │ │ ├── invoker.properties │ │ ├── verify.groovy │ │ └── pom.xml │ ├── released-version │ │ ├── invoker.properties │ │ ├── verify.groovy │ │ └── pom.xml │ ├── reserve-ports │ │ ├── invoker.properties │ │ ├── verify.groovy │ │ └── pom.xml │ ├── rootlocation │ │ ├── invoker.properties │ │ ├── verify.groovy │ │ └── pom.xml │ ├── mbuildhelper-53 │ │ ├── invoker.properties │ │ ├── verify.groovy │ │ └── pom.xml │ ├── reserve-ports-with-min │ │ ├── invoker.properties │ │ └── verify.groovy │ ├── reserve-ports-to-file │ │ ├── invoker.properties │ │ ├── verify.groovy │ │ └── pom.xml │ ├── add-resource-skip │ │ ├── invoker.properties │ │ ├── verify.groovy │ │ └── pom.xml │ ├── add-source-skip │ │ ├── invoker.properties │ │ ├── verify.groovy │ │ └── pom.xml │ ├── reserve-ports-with-min-root-range │ │ ├── invoker.properties │ │ ├── verify.groovy │ │ └── pom.xml │ ├── add-test-resource-skip │ │ ├── invoker.properties │ │ ├── verify.groovy │ │ └── pom.xml │ ├── add-test-source-skip │ │ ├── invoker.properties │ │ ├── verify.groovy │ │ └── pom.xml │ ├── parse-version │ │ ├── invoker.properties │ │ ├── pom.xml │ │ └── verify.groovy │ ├── rootlocation-run-only-at-exec-root │ │ ├── invoker.properties │ │ ├── verify.groovy │ │ ├── submodule │ │ │ └── pom.xml │ │ └── pom.xml │ ├── uptodate-glob │ │ ├── prebuild.groovy │ │ ├── invoker.properties │ │ ├── verify.groovy │ │ ├── fixture.properties │ │ └── pom.xml │ ├── add-resource-skip-if-missing │ │ ├── invoker.properties │ │ ├── verify.groovy │ │ └── pom.xml │ ├── add-source-skip-if-missing │ │ ├── invoker.properties │ │ ├── verify.groovy │ │ └── pom.xml │ ├── uptodate-merge │ │ ├── prebuild.groovy │ │ ├── invoker.properties │ │ ├── verify.groovy │ │ ├── fixture.properties │ │ └── pom.xml │ ├── uptodate-multi │ │ ├── prebuild.groovy │ │ ├── invoker.properties │ │ ├── verify.groovy │ │ └── fixture.properties │ ├── add-test-resource-skip-if-missing │ │ ├── invoker.properties │ │ ├── verify.groovy │ │ └── pom.xml │ ├── add-test-source-skip-if-missing │ │ ├── invoker.properties │ │ ├── verify.groovy │ │ └── pom.xml │ ├── uptodate-flatten │ │ ├── prebuild.groovy │ │ ├── invoker.properties │ │ ├── verify.groovy │ │ ├── fixture.properties │ │ └── pom.xml │ ├── uptodate-identity │ │ ├── prebuild.groovy │ │ ├── invoker.properties │ │ ├── verify.groovy │ │ ├── fixture.properties │ │ └── pom.xml │ ├── uptodate-package │ │ ├── prebuild.groovy │ │ ├── invoker.properties │ │ ├── verify.groovy │ │ ├── fixture.properties │ │ └── pom.xml │ ├── uptodate-unpackage │ │ ├── prebuild.groovy │ │ ├── invoker.properties │ │ ├── verify.groovy │ │ ├── fixture.properties │ │ └── pom.xml │ ├── reserve-ports-with-sequence │ │ ├── invoker.properties │ │ ├── verify.groovy │ │ └── pom.xml │ ├── mbuildhelper-34 │ │ ├── invoker.properties │ │ ├── verify.groovy │ │ └── pom.xml │ ├── regex-no-match-keep-original-value-mbuildhelper-54 │ │ ├── invoker.properties │ │ ├── verify.groovy │ │ └── pom.xml │ ├── uptodate-multi-negative │ │ ├── prebuild.groovy │ │ ├── invoker.properties │ │ ├── verify.groovy │ │ └── fixture.properties │ ├── rootlocation-in-submodule │ │ ├── invoker.properties │ │ ├── verify.groovy │ │ ├── submodule │ │ │ └── pom.xml │ │ └── pom.xml │ ├── rootlocation-in-submodule-separate-parent │ │ ├── invoker.properties │ │ ├── verify.groovy │ │ ├── submodule │ │ │ └── pom.xml │ │ ├── parent │ │ │ └── pom.xml │ │ └── pom.xml │ ├── parse-version-issue-91 │ │ ├── invoker.properties │ │ ├── pom.xml │ │ └── verify.groovy │ ├── remove-project-artifact │ │ ├── invoker.properties │ │ ├── verify.groovy │ │ └── pom.xml │ ├── rootlocation-in-submodule-nested-separate-parent │ │ ├── invoker.properties │ │ ├── verify.groovy │ │ ├── modules │ │ │ ├── submodule │ │ │ │ └── pom.xml │ │ │ └── pom.xml │ │ ├── parent │ │ │ └── pom.xml │ │ └── pom.xml │ ├── rootlocation-in-submodule-deeperlevel-separate-parent │ │ ├── invoker.properties │ │ ├── verify.groovy │ │ ├── modules │ │ │ └── submodule │ │ │ │ └── pom.xml │ │ ├── parent │ │ │ └── pom.xml │ │ └── pom.xml │ ├── released-version-existing-snapshot │ │ ├── invoker.properties │ │ ├── verify.groovy │ │ ├── settings-maven-oss-snapshot.xml │ │ └── pom.xml │ ├── released-version-existing-asset │ │ ├── invoker.properties │ │ ├── verify.groovy │ │ ├── settings-maven-central.xml │ │ └── pom.xml │ ├── released-version-existing-asset-issue-108 │ │ ├── invoker.properties │ │ ├── verify.groovy │ │ ├── settings-maven-central-no-snapshot.xml │ │ └── pom.xml │ ├── reserve-ports-with-random │ │ ├── verify.groovy │ │ └── pom.xml │ ├── surefire │ │ ├── src │ │ │ └── test │ │ │ │ └── java │ │ │ │ └── org │ │ │ │ └── codehaus │ │ │ │ └── mojo │ │ │ │ └── PassReservedPortToSureFireTest.java │ │ └── pom.xml │ └── settings.xml ├── main │ ├── java │ │ └── org │ │ │ └── codehaus │ │ │ └── mojo │ │ │ └── buildhelper │ │ │ ├── versioning │ │ │ ├── Versioning.java │ │ │ └── DefaultVersioning.java │ │ │ ├── AbstractDefinePropertyMojo.java │ │ │ ├── HostnameMojo.java │ │ │ ├── LocalIpMojo.java │ │ │ ├── RegexPropertiesMojo.java │ │ │ ├── CpuCountMojo.java │ │ │ ├── MavenVersionMojo.java │ │ │ ├── AddResourceMojo.java │ │ │ ├── AddTestResourceMojo.java │ │ │ ├── UpToDatePropertiesMojo.java │ │ │ ├── Artifact.java │ │ │ ├── UpToDatePropertyMojo.java │ │ │ ├── AddSourceMojo.java │ │ │ ├── AbstractRegexPropertyMojo.java │ │ │ ├── AddTestSourceMojo.java │ │ │ └── RegexPropertyMojo.java │ └── resources │ │ └── META-INF │ │ └── m2e │ │ └── lifecycle-mapping-metadata.xml └── site │ └── site.xml ├── .gitignore ├── LICENSE.txt ├── README.md └── header.txt /.github/release-drafter.yml: -------------------------------------------------------------------------------- 1 | _extends: .github 2 | -------------------------------------------------------------------------------- /src/it/regex-multi/invoker.properties: -------------------------------------------------------------------------------- 1 | invoker.goals=compile 2 | -------------------------------------------------------------------------------- /src/it/regex-valid/invoker.properties: -------------------------------------------------------------------------------- 1 | invoker.goals=compile 2 | -------------------------------------------------------------------------------- /src/it/bsh-property/invoker.properties: -------------------------------------------------------------------------------- 1 | invoker.goals = validate 2 | -------------------------------------------------------------------------------- /src/it/timestamp-regex/invoker.properties: -------------------------------------------------------------------------------- 1 | invoker.goals=compile 2 | -------------------------------------------------------------------------------- /src/it/timestamp-valid/invoker.properties: -------------------------------------------------------------------------------- 1 | invoker.goals=compile 2 | -------------------------------------------------------------------------------- /src/it/timestamp-timesource/invoker.properties: -------------------------------------------------------------------------------- 1 | invoker.goals=compile 2 | -------------------------------------------------------------------------------- /src/it/addResource/src/my-resources/resource.txt: -------------------------------------------------------------------------------- 1 | This is just a text file. 2 | -------------------------------------------------------------------------------- /src/it/regex-multi/src/main/resources/test.properties: -------------------------------------------------------------------------------- 1 | version=${build.version} -------------------------------------------------------------------------------- /src/it/regex-valid/src/main/resources/test.properties: -------------------------------------------------------------------------------- 1 | version=${build.version} -------------------------------------------------------------------------------- /src/it/timestamp-valid/src/main/resources/test.properties: -------------------------------------------------------------------------------- 1 | version=${timestamp} -------------------------------------------------------------------------------- /src/it/regex-invalid/src/main/resources/test.properties: -------------------------------------------------------------------------------- 1 | version=${build.version} -------------------------------------------------------------------------------- /src/it/regex-nomatch/src/main/resources/test.properties: -------------------------------------------------------------------------------- 1 | version=${build.version} -------------------------------------------------------------------------------- /src/it/timestamp-regex/src/main/resources/test.properties: -------------------------------------------------------------------------------- 1 | version=${build.version} -------------------------------------------------------------------------------- /src/it/addResource/src/my-test-resources/test-resource.txt: -------------------------------------------------------------------------------- 1 | This is just a text file. 2 | -------------------------------------------------------------------------------- /src/it/reserve-ports-with-urls/names1.txt: -------------------------------------------------------------------------------- 1 | # Port names 2 | port1 3 | port2 4 | port3 -------------------------------------------------------------------------------- /src/it/reserve-ports-with-urls/names2.txt: -------------------------------------------------------------------------------- 1 | # Port names 2 | port4 3 | port5 4 | port6 -------------------------------------------------------------------------------- /src/it/released-version/invoker.properties: -------------------------------------------------------------------------------- 1 | invoker.goals = test 2 | invoker.buildResult = success -------------------------------------------------------------------------------- /src/it/reserve-ports/invoker.properties: -------------------------------------------------------------------------------- 1 | invoker.goals = test 2 | invoker.buildResult = success 3 | -------------------------------------------------------------------------------- /src/it/regex-invalid/invoker.properties: -------------------------------------------------------------------------------- 1 | invoker.goals = validate 2 | invoker.buildResult = failure 3 | -------------------------------------------------------------------------------- /src/it/regex-nomatch/invoker.properties: -------------------------------------------------------------------------------- 1 | invoker.goals = validate 2 | invoker.buildResult = failure 3 | -------------------------------------------------------------------------------- /src/it/reserve-ports-with-urls/invoker.properties: -------------------------------------------------------------------------------- 1 | invoker.goals = test 2 | invoker.buildResult = success -------------------------------------------------------------------------------- /src/it/rootlocation/invoker.properties: -------------------------------------------------------------------------------- 1 | invoker.goals = validate 2 | invoker.buildResult = success 3 | -------------------------------------------------------------------------------- /src/it/mbuildhelper-53/invoker.properties: -------------------------------------------------------------------------------- 1 | invoker.goals = validate 2 | invoker.buildResult = success 3 | -------------------------------------------------------------------------------- /src/it/reserve-ports-with-min/invoker.properties: -------------------------------------------------------------------------------- 1 | invoker.goals = test 2 | invoker.buildResult = success 3 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | target 2 | .settings 3 | .classpath 4 | .project 5 | *.iml 6 | .idea/ 7 | /bin 8 | test-output 9 | -------------------------------------------------------------------------------- /src/it/reserve-ports-to-file/invoker.properties: -------------------------------------------------------------------------------- 1 | invoker.goals = initialize 2 | invoker.buildResult = success 3 | -------------------------------------------------------------------------------- /src/it/add-resource-skip/invoker.properties: -------------------------------------------------------------------------------- 1 | invoker.goals = -X generate-sources 2 | invoker.buildResult = success 3 | -------------------------------------------------------------------------------- /src/it/add-source-skip/invoker.properties: -------------------------------------------------------------------------------- 1 | invoker.goals = -X generate-sources 2 | invoker.buildResult = success 3 | -------------------------------------------------------------------------------- /src/it/reserve-ports-with-min-root-range/invoker.properties: -------------------------------------------------------------------------------- 1 | invoker.goals = test 2 | invoker.buildResult = success 3 | -------------------------------------------------------------------------------- /src/it/add-test-resource-skip/invoker.properties: -------------------------------------------------------------------------------- 1 | invoker.goals = -X generate-sources 2 | invoker.buildResult = success 3 | -------------------------------------------------------------------------------- /src/it/add-test-source-skip/invoker.properties: -------------------------------------------------------------------------------- 1 | invoker.goals = -X generate-sources 2 | invoker.buildResult = success 3 | -------------------------------------------------------------------------------- /src/it/parse-version/invoker.properties: -------------------------------------------------------------------------------- 1 | invoker.goals = test 2 | invoker.buildResult = success 3 | invoker.debug = true 4 | -------------------------------------------------------------------------------- /src/it/rootlocation-run-only-at-exec-root/invoker.properties: -------------------------------------------------------------------------------- 1 | invoker.goals = validate 2 | invoker.buildResult = success 3 | -------------------------------------------------------------------------------- /src/it/uptodate-glob/prebuild.groovy: -------------------------------------------------------------------------------- 1 | org.codehaus.mojo.buildhelper.FixtureUtils.createResources( "target/it/uptodate-glob" ) -------------------------------------------------------------------------------- /src/it/add-resource-skip-if-missing/invoker.properties: -------------------------------------------------------------------------------- 1 | invoker.goals = -X generate-sources 2 | invoker.buildResult = success 3 | -------------------------------------------------------------------------------- /src/it/add-source-skip-if-missing/invoker.properties: -------------------------------------------------------------------------------- 1 | invoker.goals = -X generate-sources 2 | invoker.buildResult = success 3 | -------------------------------------------------------------------------------- /src/it/uptodate-merge/prebuild.groovy: -------------------------------------------------------------------------------- 1 | org.codehaus.mojo.buildhelper.FixtureUtils.createResources( "target/it/uptodate-merge" ) -------------------------------------------------------------------------------- /src/it/uptodate-multi/prebuild.groovy: -------------------------------------------------------------------------------- 1 | org.codehaus.mojo.buildhelper.FixtureUtils.createResources( "target/it/uptodate-multi" ) -------------------------------------------------------------------------------- /src/it/add-test-resource-skip-if-missing/invoker.properties: -------------------------------------------------------------------------------- 1 | invoker.goals = -X generate-sources 2 | invoker.buildResult = success 3 | -------------------------------------------------------------------------------- /src/it/add-test-source-skip-if-missing/invoker.properties: -------------------------------------------------------------------------------- 1 | invoker.goals = -X generate-sources 2 | invoker.buildResult = success 3 | -------------------------------------------------------------------------------- /src/it/uptodate-flatten/prebuild.groovy: -------------------------------------------------------------------------------- 1 | org.codehaus.mojo.buildhelper.FixtureUtils.createResources( "target/it/uptodate-flatten" ) -------------------------------------------------------------------------------- /src/it/uptodate-identity/prebuild.groovy: -------------------------------------------------------------------------------- 1 | org.codehaus.mojo.buildhelper.FixtureUtils.createResources( "target/it/uptodate-identity" ) -------------------------------------------------------------------------------- /src/it/uptodate-package/prebuild.groovy: -------------------------------------------------------------------------------- 1 | org.codehaus.mojo.buildhelper.FixtureUtils.createResources( "target/it/uptodate-package" ) -------------------------------------------------------------------------------- /src/it/uptodate-unpackage/prebuild.groovy: -------------------------------------------------------------------------------- 1 | org.codehaus.mojo.buildhelper.FixtureUtils.createResources( "target/it/uptodate-unpackage" ) -------------------------------------------------------------------------------- /src/it/reserve-ports-with-sequence/invoker.properties: -------------------------------------------------------------------------------- 1 | invoker.goals = test 2 | invoker.buildResult = success 3 | invoker.os.family = unix -------------------------------------------------------------------------------- /src/it/mbuildhelper-34/invoker.properties: -------------------------------------------------------------------------------- 1 | invoker.goals = validate 2 | invoker.buildResult = success 3 | invoker.maven.version = 3.1.0-alpha-1+ -------------------------------------------------------------------------------- /src/it/regex-no-match-keep-original-value-mbuildhelper-54/invoker.properties: -------------------------------------------------------------------------------- 1 | invoker.goals = validate 2 | invoker.buildResult = success 3 | -------------------------------------------------------------------------------- /src/it/uptodate-multi-negative/prebuild.groovy: -------------------------------------------------------------------------------- 1 | org.codehaus.mojo.buildhelper.FixtureUtils.createResources( "target/it/uptodate-multi-negative" ) -------------------------------------------------------------------------------- /src/it/rootlocation-in-submodule/invoker.properties: -------------------------------------------------------------------------------- 1 | invoker.goals = validate 2 | invoker.buildResult = success 3 | invoker.project = submodule 4 | -------------------------------------------------------------------------------- /src/it/rootlocation-in-submodule-separate-parent/invoker.properties: -------------------------------------------------------------------------------- 1 | invoker.goals = validate 2 | invoker.buildResult = success 3 | invoker.project = submodule 4 | -------------------------------------------------------------------------------- /src/it/timestamp-timesource/module-1/src/main/resources/test.properties: -------------------------------------------------------------------------------- 1 | module.version=${module.build.timestamp} 2 | session.version=${session.build.timestamp} 3 | -------------------------------------------------------------------------------- /src/it/timestamp-timesource/module-2/src/main/resources/test.properties: -------------------------------------------------------------------------------- 1 | module.version=${module.build.timestamp} 2 | session.version=${session.build.timestamp} 3 | -------------------------------------------------------------------------------- /src/it/uptodate-glob/invoker.properties: -------------------------------------------------------------------------------- 1 | invoker.goals = validate 2 | #invoker.mavenOpts = -agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=8000 3 | -------------------------------------------------------------------------------- /src/it/uptodate-merge/invoker.properties: -------------------------------------------------------------------------------- 1 | invoker.goals = validate 2 | #invoker.mavenOpts = -agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=8000 3 | -------------------------------------------------------------------------------- /src/it/uptodate-multi/invoker.properties: -------------------------------------------------------------------------------- 1 | invoker.goals = validate 2 | #invoker.mavenOpts = -agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=8000 3 | -------------------------------------------------------------------------------- /src/it/uptodate-flatten/invoker.properties: -------------------------------------------------------------------------------- 1 | invoker.goals = validate 2 | #invoker.mavenOpts = -agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=8000 3 | -------------------------------------------------------------------------------- /src/it/uptodate-identity/invoker.properties: -------------------------------------------------------------------------------- 1 | invoker.goals = validate 2 | #invoker.mavenOpts = -agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=8000 3 | -------------------------------------------------------------------------------- /src/it/uptodate-package/invoker.properties: -------------------------------------------------------------------------------- 1 | invoker.goals = validate 2 | #invoker.mavenOpts = -agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=8000 3 | -------------------------------------------------------------------------------- /src/it/uptodate-unpackage/invoker.properties: -------------------------------------------------------------------------------- 1 | invoker.goals = validate 2 | #invoker.mavenOpts = -agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=8000 3 | -------------------------------------------------------------------------------- /src/it/parse-version-issue-91/invoker.properties: -------------------------------------------------------------------------------- 1 | invoker.goals=${project.groupId}:${project.artifactId}:${project.version}:parse-version -DversionString=10.0.2-4545-RC1 2 | -------------------------------------------------------------------------------- /src/it/remove-project-artifact/invoker.properties: -------------------------------------------------------------------------------- 1 | # first install something 2 | invoker.goals.1 = install 3 | 4 | # next try to delete 5 | invoker.goals.2 = package 6 | -------------------------------------------------------------------------------- /src/it/uptodate-multi-negative/invoker.properties: -------------------------------------------------------------------------------- 1 | invoker.goals = validate 2 | #invoker.mavenOpts = -agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=8000 3 | -------------------------------------------------------------------------------- /src/it/rootlocation-in-submodule-nested-separate-parent/invoker.properties: -------------------------------------------------------------------------------- 1 | invoker.goals = validate 2 | invoker.buildResult = success 3 | invoker.project = modules/submodule 4 | -------------------------------------------------------------------------------- /src/it/rootlocation-in-submodule-deeperlevel-separate-parent/invoker.properties: -------------------------------------------------------------------------------- 1 | invoker.goals = validate 2 | invoker.buildResult = success 3 | invoker.project = modules/submodule 4 | -------------------------------------------------------------------------------- /src/it/released-version-existing-snapshot/invoker.properties: -------------------------------------------------------------------------------- 1 | invoker.goals = validate 2 | invoker.settingsFile = src/it/released-version-existing-snapshot/settings-maven-oss-snapshot.xml 3 | -------------------------------------------------------------------------------- /src/it/released-version-existing-asset/invoker.properties: -------------------------------------------------------------------------------- 1 | invoker.goals = test 2 | invoker.buildResult = success 3 | invoker.settingsFile = src/it/released-version-existing-asset/settings-maven-central.xml 4 | -------------------------------------------------------------------------------- /src/it/released-version-existing-asset-issue-108/invoker.properties: -------------------------------------------------------------------------------- 1 | invoker.goals = test 2 | invoker.buildResult = success 3 | invoker.settingsFile = src/it/released-version-existing-asset-issue-108/settings-maven-central-no-snapshot.xml 4 | -------------------------------------------------------------------------------- /src/it/mbuildhelper-53/verify.groovy: -------------------------------------------------------------------------------- 1 | File file = new File( basedir, "build.log" ); 2 | assert file.exists(); 3 | 4 | String text = file.getText("utf-8"); 5 | 6 | assert text.contains("define property propname = \"hi \"") 7 | 8 | return true; 9 | -------------------------------------------------------------------------------- /src/it/mbuildhelper-34/verify.groovy: -------------------------------------------------------------------------------- 1 | File file = new File( basedir, "build.log" ); 2 | assert file.exists(); 3 | 4 | String text = file.getText("utf-8"); 5 | 6 | assert text.contains('define property propname = "chapi bidiba"') 7 | 8 | return true; 9 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | - package-ecosystem: "maven" 4 | directory: "/" 5 | schedule: 6 | interval: "daily" 7 | - package-ecosystem: "github-actions" 8 | directory: "/" 9 | schedule: 10 | interval: "daily" 11 | -------------------------------------------------------------------------------- /.github/workflows/release-drafter.yml: -------------------------------------------------------------------------------- 1 | name: Release Drafter 2 | on: 3 | push: 4 | branches: 5 | - master 6 | workflow_dispatch: 7 | 8 | jobs: 9 | update_release_draft: 10 | uses: apache/maven-gh-actions-shared/.github/workflows/release-drafter.yml@v4 11 | -------------------------------------------------------------------------------- /src/it/regex-no-match-keep-original-value-mbuildhelper-54/verify.groovy: -------------------------------------------------------------------------------- 1 | File file = new File( basedir, "build.log" ); 2 | assert file.exists(); 3 | 4 | String text = file.getText("utf-8"); 5 | 6 | assert text.contains("define property propname = \"originalvalue\"") 7 | return true; 8 | -------------------------------------------------------------------------------- /src/it/add-source-skip/verify.groovy: -------------------------------------------------------------------------------- 1 | File file = new File( basedir, "build.log" ); 2 | assert file.exists(); 3 | 4 | String text = file.getText("utf-8"); 5 | 6 | assert text.contains("skipAddSource = true"); 7 | assert text.contains("Skipping plugin execution!"); 8 | 9 | return true; 10 | -------------------------------------------------------------------------------- /src/it/reserve-ports/verify.groovy: -------------------------------------------------------------------------------- 1 | File file = new File( basedir, "build.log" ); 2 | assert file.exists(); 3 | 4 | String text = file.getText("utf-8"); 5 | 6 | assert text.contains("port1=") 7 | assert text.contains("port2=") 8 | assert text.contains("port3=") 9 | 10 | return true; 11 | -------------------------------------------------------------------------------- /src/it/add-resource-skip/verify.groovy: -------------------------------------------------------------------------------- 1 | File file = new File( basedir, "build.log" ); 2 | assert file.exists(); 3 | 4 | String text = file.getText("utf-8"); 5 | 6 | assert text.contains("skipAddResource = true"); 7 | assert text.contains("Skipping plugin execution!"); 8 | 9 | return true; 10 | -------------------------------------------------------------------------------- /src/it/add-test-source-skip/verify.groovy: -------------------------------------------------------------------------------- 1 | File file = new File( basedir, "build.log" ); 2 | assert file.exists(); 3 | 4 | String text = file.getText("utf-8"); 5 | 6 | assert text.contains("skipAddTestSource = true"); 7 | assert text.contains("Skipping plugin execution!"); 8 | 9 | return true; 10 | -------------------------------------------------------------------------------- /src/it/reserve-ports-with-urls/verify.groovy: -------------------------------------------------------------------------------- 1 | File file = new File( basedir, "build.log" ); 2 | assert file.exists(); 3 | 4 | String text = file.getText("utf-8"); 5 | 6 | assert text.contains("port1=") 7 | assert text.contains("port2=") 8 | assert text.contains("port3=") 9 | 10 | return true; 11 | -------------------------------------------------------------------------------- /src/it/add-test-resource-skip/verify.groovy: -------------------------------------------------------------------------------- 1 | File file = new File( basedir, "build.log" ); 2 | assert file.exists(); 3 | 4 | String text = file.getText("utf-8"); 5 | 6 | assert text.contains("skipAddTestResource = true"); 7 | assert text.contains("Skipping plugin execution!"); 8 | 9 | return true; 10 | -------------------------------------------------------------------------------- /src/it/remove-project-artifact/verify.groovy: -------------------------------------------------------------------------------- 1 | File file = new File(basedir, "build.log"); 2 | assert file.exists(); 3 | 4 | String text = file.getText("utf-8"); 5 | 6 | def FS = File.separator 7 | 8 | assert 2 == text.count("org${FS}codehaus${FS}mojo${FS}remove-project-artifact-it removed.") : 'removed log should be present twice' 9 | -------------------------------------------------------------------------------- /src/it/rootlocation/verify.groovy: -------------------------------------------------------------------------------- 1 | File file = new File( basedir, "build.log" ) 2 | assert file.exists() 3 | 4 | String text = file.getText("utf-8") 5 | 6 | def rootFolderName = (text =~ /(?ms)(.*?)define property rootlocation = "(.*?)[\/\\]([^\/\\"]+)"(.*?)/)[0][3] 7 | assert rootFolderName == "rootlocation" 8 | 9 | return true 10 | -------------------------------------------------------------------------------- /src/it/rootlocation-in-submodule/verify.groovy: -------------------------------------------------------------------------------- 1 | File file = new File( basedir, "build.log" ) 2 | assert file.exists() 3 | 4 | String text = file.getText("utf-8") 5 | 6 | def rootFolderName = (text =~ /(?ms)(.*?)define property rootlocation = "(.*?)[\/\\]([^\/\\"]+)"(.*?)/)[0][3] 7 | assert rootFolderName == "rootlocation-in-submodule" 8 | 9 | return true 10 | -------------------------------------------------------------------------------- /src/it/add-source-skip-if-missing/verify.groovy: -------------------------------------------------------------------------------- 1 | File file = new File( basedir, "build.log" ); 2 | assert file.exists(); 3 | 4 | String text = file.getText("utf-8"); 5 | 6 | assert text.contains("skipAddSourceIfMissing = true"); 7 | assert text.contains("Skipping directory: "); 8 | assert text.contains("not-existing, because it does not exist."); 9 | 10 | return true; 11 | -------------------------------------------------------------------------------- /src/main/java/org/codehaus/mojo/buildhelper/versioning/Versioning.java: -------------------------------------------------------------------------------- 1 | package org.codehaus.mojo.buildhelper.versioning; 2 | 3 | public interface Versioning { 4 | 5 | int getMajor(); 6 | 7 | int getMinor(); 8 | 9 | int getPatch(); 10 | 11 | String getAsOSGiVersion(); 12 | 13 | long getBuildNumber(); 14 | 15 | String getQualifier(); 16 | } 17 | -------------------------------------------------------------------------------- /src/it/add-resource-skip-if-missing/verify.groovy: -------------------------------------------------------------------------------- 1 | File file = new File( basedir, "build.log" ); 2 | assert file.exists(); 3 | 4 | String text = file.getText("utf-8"); 5 | 6 | assert text.contains("skipAddResourceIfMissing = true"); 7 | assert text.contains("Skipping directory: "); 8 | assert text.contains("not-existing, because it does not exist"); 9 | 10 | return true; 11 | -------------------------------------------------------------------------------- /src/it/add-test-source-skip-if-missing/verify.groovy: -------------------------------------------------------------------------------- 1 | File file = new File( basedir, "build.log" ); 2 | assert file.exists(); 3 | 4 | String text = file.getText("utf-8"); 5 | 6 | assert text.contains("skipAddTestSourceIfMissing = true"); 7 | assert text.contains("Skipping directory: "); 8 | assert text.contains("not-existing, because it does not exist."); 9 | 10 | return true; 11 | -------------------------------------------------------------------------------- /src/it/add-test-resource-skip-if-missing/verify.groovy: -------------------------------------------------------------------------------- 1 | File file = new File( basedir, "build.log" ); 2 | assert file.exists(); 3 | 4 | String text = file.getText("utf-8"); 5 | 6 | assert text.contains("skipAddTestResourceIfMissing = true"); 7 | assert text.contains("Skipping directory: "); 8 | assert text.contains("not-existing, because it does not exist."); 9 | 10 | return true; 11 | -------------------------------------------------------------------------------- /src/it/released-version/verify.groovy: -------------------------------------------------------------------------------- 1 | File file = new File( basedir, "build.log" ); 2 | assert file.exists(); 3 | 4 | String text = file.getText("utf-8"); 5 | 6 | // its difficult to check the positove case with an existing released version in an IT - so currently we test only the case when no version is detected 7 | assert text.contains("No released version found.") 8 | 9 | return true; 10 | -------------------------------------------------------------------------------- /src/it/rootlocation-in-submodule-separate-parent/verify.groovy: -------------------------------------------------------------------------------- 1 | File file = new File( basedir, "build.log" ) 2 | assert file.exists() 3 | 4 | String text = file.getText("utf-8") 5 | 6 | def rootFolderName = (text =~ /(?ms)(.*?)define property rootlocation = "(.*?)[\/\\]([^\/\\"]+)"(.*?)/)[0][3] 7 | assert rootFolderName == "rootlocation-in-submodule-separate-parent" 8 | 9 | return true 10 | -------------------------------------------------------------------------------- /src/it/rootlocation-in-submodule-nested-separate-parent/verify.groovy: -------------------------------------------------------------------------------- 1 | File file = new File( basedir, "build.log" ) 2 | assert file.exists() 3 | 4 | String text = file.getText("utf-8") 5 | 6 | def rootFolderName = (text =~ /(?ms)(.*?)define property rootlocation = "(.*?)[\/\\]([^\/\\"]+)"(.*?)/)[0][3] 7 | assert rootFolderName == "rootlocation-in-submodule-nested-separate-parent" 8 | 9 | return true 10 | -------------------------------------------------------------------------------- /src/it/rootlocation-in-submodule-deeperlevel-separate-parent/verify.groovy: -------------------------------------------------------------------------------- 1 | File file = new File( basedir, "build.log" ) 2 | assert file.exists() 3 | 4 | String text = file.getText("utf-8") 5 | 6 | def rootFolderName = (text =~ /(?ms)(.*?)define property rootlocation = "(.*?)[\/\\]([^\/\\"]+)"(.*?)/)[0][3] 7 | assert rootFolderName == "rootlocation-in-submodule-deeperlevel-separate-parent" 8 | 9 | return true 10 | -------------------------------------------------------------------------------- /src/it/reserve-ports-with-random/verify.groovy: -------------------------------------------------------------------------------- 1 | File file = new File( basedir, "build.log" ); 2 | assert file.exists(); 3 | 4 | String text = file.getText("utf-8"); 5 | 6 | // FIXME: That IT could fail if the port is already taken 7 | // Only check if the reserved values are *higher* than 1024? 8 | assert text.contains("port1=900") 9 | assert text.contains("port2=900") 10 | assert text.contains("port3=900") 11 | return true; 12 | -------------------------------------------------------------------------------- /src/it/reserve-ports-with-sequence/verify.groovy: -------------------------------------------------------------------------------- 1 | File file = new File( basedir, "build.log" ); 2 | assert file.exists(); 3 | 4 | String text = file.getText("utf-8"); 5 | 6 | // FIXME: That IT could fail if the port is already taken 7 | // Only check if the reserved values are *higher* than 1024? 8 | assert text.contains("port1=9000") 9 | assert text.contains("port2=9001") 10 | assert text.contains("port3=9002") 11 | return true; 12 | -------------------------------------------------------------------------------- /src/it/reserve-ports-with-min-root-range/verify.groovy: -------------------------------------------------------------------------------- 1 | File file = new File( basedir, "build.log" ); 2 | assert file.exists(); 3 | 4 | String text = file.getText("utf-8"); 5 | 6 | // FIXME: That IT could fail if the port is already taken 7 | // Only check if the reserved values are *higher* than 1024? 8 | assert text.contains("port1=1024") 9 | assert text.contains("port2=1025") 10 | assert text.contains("port3=1026") 11 | return true; 12 | -------------------------------------------------------------------------------- /src/it/reserve-ports-to-file/verify.groovy: -------------------------------------------------------------------------------- 1 | File targetFolder = new File ( basedir, "target" ); 2 | 3 | File propsFile = new File( targetFolder, "ports.properties" ); 4 | assert propsFile.exists() 5 | 6 | Properties p = new Properties (); 7 | 8 | p.load (new FileInputStream(propsFile)); 9 | 10 | assert p.getProperty ('port1') != null; 11 | assert p.getProperty ('port2') != null; 12 | assert p.getProperty ('port3') != null; 13 | 14 | return true; 15 | -------------------------------------------------------------------------------- /src/it/uptodate-glob/verify.groovy: -------------------------------------------------------------------------------- 1 | File file = new File( basedir, "build.log" ); 2 | assert file.exists(); 3 | 4 | String text = file.getText("utf-8"); 5 | 6 | assert !text.contains('define property propname-glob = "outofdate"') : "Erroneously defined property propname-glob = \"outofdate\"" 7 | assert text.contains('define property propname-glob = "uptodate"') : "Failed to define property propname-glob = \"uptodate\"" 8 | 9 | return true; 10 | -------------------------------------------------------------------------------- /src/it/uptodate-merge/verify.groovy: -------------------------------------------------------------------------------- 1 | File file = new File( basedir, "build.log" ); 2 | assert file.exists(); 3 | 4 | String text = file.getText("utf-8"); 5 | 6 | assert !text.contains('define property propname-merge = "outofdate"') : "Erroneously defined property propname-merge = \"outofdate\"" 7 | assert text.contains('define property propname-merge = "uptodate"') : "Failed to define property propname-merge = \"uptodate\"" 8 | 9 | return true; 10 | -------------------------------------------------------------------------------- /src/it/released-version-existing-snapshot/verify.groovy: -------------------------------------------------------------------------------- 1 | File file = new File( basedir, "build.log" ); 2 | assert file.exists(); 3 | 4 | String text = file.getText("utf-8"); 5 | 6 | // we have SNAPSHOT on list 7 | assert text.matches('(?ms)^.*Resolved versions: .*-SNAPSHOT.*$') 8 | 9 | // but released version is not a SNAPSHOT 10 | assert text.matches( '(?ms)^.*Released version: .*$') 11 | assert !text.matches( '(?ms)^.*Released version: .*-SNAPSHOT.*$') 12 | -------------------------------------------------------------------------------- /src/it/uptodate-flatten/verify.groovy: -------------------------------------------------------------------------------- 1 | File file = new File( basedir, "build.log" ); 2 | assert file.exists(); 3 | 4 | String text = file.getText("utf-8"); 5 | 6 | assert !text.contains('define property propname-flatten = "outofdate"') : "Erroneously defined property propname-flatten = \"outofdate\"" 7 | assert text.contains('define property propname-flatten = "uptodate"') : "Failed to define property propname-flatten = \"uptodate\"" 8 | 9 | return true; 10 | -------------------------------------------------------------------------------- /src/it/uptodate-package/verify.groovy: -------------------------------------------------------------------------------- 1 | File file = new File( basedir, "build.log" ); 2 | assert file.exists(); 3 | 4 | String text = file.getText("utf-8"); 5 | 6 | assert !text.contains('define property propname-package = "outofdate"') : "Erroneously defined property propname-package = \"outofdate\"" 7 | assert text.contains('define property propname-package = "uptodate"') : "Failed to define property propname-package = \"uptodate\"" 8 | 9 | return true; 10 | -------------------------------------------------------------------------------- /src/it/uptodate-identity/verify.groovy: -------------------------------------------------------------------------------- 1 | File file = new File( basedir, "build.log" ); 2 | assert file.exists(); 3 | 4 | String text = file.getText("utf-8"); 5 | 6 | assert !text.contains('define property propname-identity = "outofdate"') : "Erroneously defined property propname-identity = \"outofdate\"" 7 | assert text.contains('define property propname-identity = "uptodate"') : "Failed to define property propname-identity = \"uptodate\"" 8 | 9 | return true; 10 | -------------------------------------------------------------------------------- /src/it/uptodate-unpackage/verify.groovy: -------------------------------------------------------------------------------- 1 | File file = new File( basedir, "build.log" ); 2 | assert file.exists(); 3 | 4 | String text = file.getText("utf-8"); 5 | 6 | assert !text.contains('define property propname-unpackage = "outofdate"') : "Erroneously defined property propname-unpackage = \"outofdate\"" 7 | assert text.contains('define property propname-unpackage = "uptodate"') : "Failed to define property propname-unpackage = \"uptodate\"" 8 | 9 | return true; 10 | -------------------------------------------------------------------------------- /src/it/rootlocation-run-only-at-exec-root/verify.groovy: -------------------------------------------------------------------------------- 1 | File file = new File( basedir, "build.log" ) 2 | assert file.exists() 3 | 4 | String text = file.getText("utf-8") 5 | 6 | def rootFolderName = (text =~ /(?ms)(.*?)define property rootlocation = "(.*?)[\/\\]([^\/\\"]+)"(.*?)/)[0][3] 7 | assert rootFolderName == "rootlocation-run-only-at-exec-root" 8 | 9 | assert text.contains("Skip getting the rootlocation in this project because it's not the Execution Root") 10 | 11 | return true 12 | -------------------------------------------------------------------------------- /src/it/uptodate-merge/fixture.properties: -------------------------------------------------------------------------------- 1 | src/main/resources/source/dirA/fileAA.s = 1 2 | src/main/resources/source/dirA/fileAB.s = 2 3 | src/main/resources/source/dirA/fileAX.s = 3 4 | src/main/resources/source/dirB/fileBA.s = 4 5 | src/main/resources/source/dirB/fileBB.s = 5 6 | src/main/resources/source/dirB/fileBX.s = 6 7 | src/main/resources/source/dirY/fileYA.s = 7 8 | src/main/resources/source/dirY/fileYB.s = 8 9 | src/main/resources/source/dirY/fileYX.s = 9 10 | 11 | src/main/resources/target/todir/outfile.t = 6 -------------------------------------------------------------------------------- /src/it/reserve-ports-with-min/verify.groovy: -------------------------------------------------------------------------------- 1 | File file = new File( basedir, "build.log" ); 2 | assert file.exists(); 3 | 4 | String text = file.getText("utf-8"); 5 | 6 | assert text.contains("port1=30000") 7 | assert text.contains("port2=30001") 8 | assert text.contains("port3=30002") 9 | assert text.contains("port4=30003") 10 | assert text.contains("port5=30004") 11 | assert text.contains("port6=30005") 12 | assert text.contains("port7=40000") 13 | assert text.contains("port8=40001") 14 | assert text.contains("port9=40002") 15 | return true; 16 | -------------------------------------------------------------------------------- /src/it/released-version-existing-asset/verify.groovy: -------------------------------------------------------------------------------- 1 | File file = new File( basedir, "build.log" ); 2 | assert file.exists(); 3 | 4 | String text = file.getText("utf-8"); 5 | 6 | // assert latest release of org.apache.continuum:continuum - it's in apache attic, there will be no new releases any more 7 | assert text.contains("myReleasedVersion.version=1.4.2") 8 | assert text.contains("myReleasedVersion.majorVersion=1") 9 | assert text.contains("myReleasedVersion.minorVersion=4") 10 | assert text.contains("myReleasedVersion.incrementalVersion=2") 11 | 12 | return true; 13 | -------------------------------------------------------------------------------- /src/it/regex-multi/verify.bsh: -------------------------------------------------------------------------------- 1 | import java.io.*; 2 | import java.util.*; 3 | 4 | try 5 | { 6 | File file = new File( basedir, "target/classes/test.properties" ); 7 | Properties p = new Properties(); 8 | p.load( new FileInputStream( file ) ); 9 | String value = p.getProperty( "version" ); 10 | 11 | if ( value.indexOf( "-RC" ) < 0 ) 12 | { 13 | System.err.println( "Regex not applied" ); 14 | return false; 15 | } 16 | } 17 | catch( Throwable t ) 18 | { 19 | t.printStackTrace(); 20 | return false; 21 | } 22 | 23 | return true; 24 | -------------------------------------------------------------------------------- /src/it/regex-valid/verify.bsh: -------------------------------------------------------------------------------- 1 | import java.io.*; 2 | import java.util.*; 3 | 4 | try 5 | { 6 | File file = new File( basedir, "target/classes/test.properties" ); 7 | Properties p = new Properties(); 8 | p.load( new FileInputStream( file ) ); 9 | String value = p.getProperty( "version" ); 10 | 11 | if ( value.indexOf( "-RC" ) < 0 ) 12 | { 13 | System.err.println( "Regex not applied" ); 14 | return false; 15 | } 16 | } 17 | catch( Throwable t ) 18 | { 19 | t.printStackTrace(); 20 | return false; 21 | } 22 | 23 | return true; 24 | -------------------------------------------------------------------------------- /src/it/released-version-existing-asset-issue-108/verify.groovy: -------------------------------------------------------------------------------- 1 | File file = new File( basedir, "build.log" ); 2 | assert file.exists(); 3 | 4 | String text = file.getText("utf-8"); 5 | 6 | // assert latest release of org.apache.continuum:continuum - it's in apache attic, there will be no new releases any more 7 | assert text.contains("myReleasedVersion.version=1.4.2") 8 | assert text.contains("myReleasedVersion.majorVersion=1") 9 | assert text.contains("myReleasedVersion.minorVersion=4") 10 | assert text.contains("myReleasedVersion.incrementalVersion=2") 11 | 12 | return true; 13 | -------------------------------------------------------------------------------- /src/it/timestamp-valid/verify.bsh: -------------------------------------------------------------------------------- 1 | import java.io.*; 2 | import java.util.*; 3 | 4 | try 5 | { 6 | File file = new File( basedir, "target/classes/test.properties" ); 7 | Properties p = new Properties(); 8 | p.load( new FileInputStream( file ) ); 9 | String value = p.getProperty( "version" ); 10 | 11 | if ( value.indexOf( "${timestamp}" ) >= 0 ) 12 | { 13 | System.err.println( "Timestamp not set" ); 14 | return false; 15 | } 16 | } 17 | catch( Throwable t ) 18 | { 19 | t.printStackTrace(); 20 | return false; 21 | } 22 | 23 | return true; 24 | -------------------------------------------------------------------------------- /src/it/rootlocation-in-submodule/submodule/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | 5 | 6 | org.codehaus.mojo 7 | build-helper-rootlocation-parent 8 | 1-SNAPSHOT 9 | 10 | 11 | project 12 | jar 13 | 14 | rootlocation sub project 15 | 16 | 17 | -------------------------------------------------------------------------------- /src/it/rootlocation-run-only-at-exec-root/submodule/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | 5 | 6 | org.codehaus.mojo 7 | build-helper-rootlocation-parent 8 | 1-SNAPSHOT 9 | 10 | 11 | project 12 | jar 13 | 14 | rootlocation sub project 15 | 16 | 17 | -------------------------------------------------------------------------------- /src/it/rootlocation-in-submodule-separate-parent/submodule/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | 5 | 6 | org.codehaus.mojo 7 | build-helper-rootlocation-parent 8 | 1-SNAPSHOT 9 | ../parent/pom.xml 10 | 11 | 12 | project 13 | jar 14 | 15 | rootlocation sub project 16 | 17 | 18 | -------------------------------------------------------------------------------- /src/it/uptodate-flatten/fixture.properties: -------------------------------------------------------------------------------- 1 | src/main/resources/source/dirA/fileAA.s = 1 2 | src/main/resources/source/dirA/fileAB.s = 2 3 | src/main/resources/source/dirA/fileAX.s = 3 4 | src/main/resources/source/dirB/fileBA.s = 4 5 | src/main/resources/source/dirB/fileBB.s = 5 6 | src/main/resources/source/dirB/fileBX.s = 6 7 | src/main/resources/source/dirY/fileYA.s = 7 8 | src/main/resources/source/dirY/fileYB.s = 8 9 | src/main/resources/source/dirY/fileYX.s = 9 10 | 11 | src/main/resources/target/fileAA.s = 1 12 | src/main/resources/target/fileAB.s = 3 13 | src/main/resources/target/fileAX.s = 0 14 | src/main/resources/target/fileBA.s = 5 15 | src/main/resources/target/fileBB.s = 6 16 | -------------------------------------------------------------------------------- /src/it/rootlocation-in-submodule-nested-separate-parent/modules/submodule/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | 5 | 6 | org.codehaus.mojo 7 | build-helper-rootlocation-parent 8 | 1-SNAPSHOT 9 | ../../parent/pom.xml 10 | 11 | 12 | project 13 | jar 14 | 15 | rootlocation sub project 16 | 17 | 18 | -------------------------------------------------------------------------------- /src/it/uptodate-glob/fixture.properties: -------------------------------------------------------------------------------- 1 | src/main/resources/source/dirA/fileAA.s = 1 2 | src/main/resources/source/dirA/fileAB.s = 2 3 | src/main/resources/source/dirA/fileAX.s = 3 4 | src/main/resources/source/dirB/fileBA.s = 4 5 | src/main/resources/source/dirB/fileBB.s = 5 6 | src/main/resources/source/dirB/fileBX.s = 6 7 | src/main/resources/source/dirY/fileYA.s = 7 8 | src/main/resources/source/dirY/fileYB.s = 8 9 | src/main/resources/source/dirY/fileYX.s = 9 10 | 11 | src/main/resources/target/dirA/fileAA.t = 1 12 | src/main/resources/target/dirA/fileAB.t = 3 13 | src/main/resources/target/dirA/fileAX.t = 0 14 | src/main/resources/target/dirB/fileBA.t = 5 15 | src/main/resources/target/dirB/fileBB.t = 6 16 | -------------------------------------------------------------------------------- /src/it/uptodate-unpackage/fixture.properties: -------------------------------------------------------------------------------- 1 | src/main/resources/source/dirA.fileAA.s = 1 2 | src/main/resources/source/dirA.fileAB.s = 2 3 | src/main/resources/source/dirA.fileAX.s = 3 4 | src/main/resources/source/dirB.fileBA.s = 4 5 | src/main/resources/source/dirB.fileBB.s = 5 6 | src/main/resources/source/dirB.fileBX.s = 6 7 | src/main/resources/source/dirY.fileYA.s = 7 8 | src/main/resources/source/dirY.fileYB.s = 8 9 | src/main/resources/source/dirY.fileYX.s = 9 10 | 11 | src/main/resources/target/dirA/fileAA.t = 1 12 | src/main/resources/target/dirA/fileAB.t = 3 13 | src/main/resources/target/dirA/fileAX.t = 0 14 | src/main/resources/target/dirB/fileBA.t = 5 15 | src/main/resources/target/dirB/fileBB.t = 6 -------------------------------------------------------------------------------- /src/it/rootlocation-in-submodule-deeperlevel-separate-parent/modules/submodule/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | 5 | 6 | org.codehaus.mojo 7 | build-helper-rootlocation-parent 8 | 1-SNAPSHOT 9 | ../../parent/pom.xml 10 | 11 | 12 | project 13 | jar 14 | 15 | rootlocation sub project 16 | 17 | 18 | -------------------------------------------------------------------------------- /src/it/uptodate-identity/fixture.properties: -------------------------------------------------------------------------------- 1 | src/main/resources/source/dirA/fileAA.s = 1 2 | src/main/resources/source/dirA/fileAB.s = 2 3 | src/main/resources/source/dirA/fileAX.s = 3 4 | src/main/resources/source/dirB/fileBA.s = 4 5 | src/main/resources/source/dirB/fileBB.s = 5 6 | src/main/resources/source/dirB/fileBX.s = 6 7 | src/main/resources/source/dirY/fileYA.s = 7 8 | src/main/resources/source/dirY/fileYB.s = 8 9 | src/main/resources/source/dirY/fileYX.s = 9 10 | 11 | src/main/resources/target/dirA/fileAA.s = 1 12 | src/main/resources/target/dirA/fileAB.s = 3 13 | src/main/resources/target/dirA/fileAX.s = 0 14 | src/main/resources/target/dirB/fileBA.s = 5 15 | src/main/resources/target/dirB/fileBB.s = 6 16 | -------------------------------------------------------------------------------- /src/it/uptodate-package/fixture.properties: -------------------------------------------------------------------------------- 1 | src/main/resources/source/dirA/fileAA.s = 1 2 | src/main/resources/source/dirA/fileAB.s = 2 3 | src/main/resources/source/dirA/fileAX.s = 3 4 | src/main/resources/source/dirB/fileBA.s = 4 5 | src/main/resources/source/dirB/fileBB.s = 5 6 | src/main/resources/source/dirB/fileBX.s = 6 7 | src/main/resources/source/dirY/fileYA.s = 7 8 | src/main/resources/source/dirY/fileYB.s = 8 9 | src/main/resources/source/dirY/fileYX.s = 9 10 | 11 | src/main/resources/target/dirA.fileAA.t = 1 12 | src/main/resources/target/dirA.fileAB.t = 3 13 | src/main/resources/target/dirA.fileAX.t = 0 14 | src/main/resources/target/dirB.fileBA.t = 5 15 | src/main/resources/target/dirB.fileBB.t = 6 16 | -------------------------------------------------------------------------------- /src/it/rootlocation-in-submodule-nested-separate-parent/modules/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | 5 | 6 | org.codehaus.mojo 7 | build-helper-rootlocation-parent 8 | 1-SNAPSHOT 9 | ../parent/pom.xml 10 | 11 | 12 | build-helper-rootlocation-modules 13 | pom 14 | 15 | 16 | submodule 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /src/it/timestamp-regex/verify.bsh: -------------------------------------------------------------------------------- 1 | import java.io.*; 2 | import java.util.*; 3 | import java.util.regex.*; 4 | 5 | try 6 | { 7 | File file = new File( basedir, "target/classes/test.properties" ); 8 | Properties p = new Properties(); 9 | p.load( new FileInputStream( file ) ); 10 | String value = p.getProperty( "version" ); 11 | 12 | if ( value.indexOf( "${build.version}" ) >= 0 ) 13 | { 14 | System.err.println( "Timestamp not set" ); 15 | return false; 16 | } 17 | Pattern regex = Pattern.compile( "\\d\\d:\\d\\d \\d\\d-\\d\\d-\\d\\d\\d\\d" ); 18 | if ( !regex.matcher( value ).find() ) 19 | { 20 | System.err.println( "Formatted timestamp not in property" ); 21 | return false; 22 | } 23 | } 24 | catch( Throwable t ) 25 | { 26 | t.printStackTrace(); 27 | return false; 28 | } 29 | 30 | return true; 31 | -------------------------------------------------------------------------------- /src/it/parse-version-issue-91/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | 5 | org.codehaus.mojo 6 | build-helper-maven-plugin-parse-version-issue-91 7 | 1.2.3-SNAPSHOT 8 | 9 | 10 | Issue 91: use the property versionString which is given via command line 11 | to parse this version and not the one which is contained in the pom.xml 12 | 13 | 14 | 15 | 16 | 17 | @project.groupId@ 18 | @project.artifactId@ 19 | @project.version@ 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /src/it/remove-project-artifact/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4.0.0 3 | 4 | org.codehaus.mojo 5 | remove-project-artifact-it 6 | 1.0-SNAPSHOT 7 | 8 | 9 | 10 | 11 | @project.groupId@ 12 | @project.artifactId@ 13 | @project.version@ 14 | 15 | 16 | released-version 17 | 18 | remove-project-artifact 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /src/it/rootlocation-in-submodule-separate-parent/parent/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | 5 | org.codehaus.mojo 6 | build-helper-rootlocation-parent 7 | 1-SNAPSHOT 8 | pom 9 | 10 | 11 | 12 | 13 | @project.groupId@ 14 | @project.artifactId@ 15 | @project.version@ 16 | 17 | 18 | 19 | rootlocation 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /src/it/rootlocation-in-submodule-nested-separate-parent/parent/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | 5 | org.codehaus.mojo 6 | build-helper-rootlocation-parent 7 | 1-SNAPSHOT 8 | pom 9 | 10 | 11 | 12 | 13 | @project.groupId@ 14 | @project.artifactId@ 15 | @project.version@ 16 | 17 | 18 | 19 | rootlocation 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /src/it/rootlocation-in-submodule-deeperlevel-separate-parent/parent/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | 5 | org.codehaus.mojo 6 | build-helper-rootlocation-parent 7 | 1-SNAPSHOT 8 | pom 9 | 10 | 11 | 12 | 13 | @project.groupId@ 14 | @project.artifactId@ 15 | @project.version@ 16 | 17 | 18 | 19 | rootlocation 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /src/it/rootlocation-in-submodule-separate-parent/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | 5 | 6 | org.codehaus.mojo 7 | build-helper-rootlocation-parent 8 | 1-SNAPSHOT 9 | parent/pom.xml 10 | 11 | 12 | org.codehaus.mojo 13 | build-helper-rootlocation-root 14 | 1-SNAPSHOT 15 | pom 16 | 17 | rootlocation search top root 18 | 19 | Tests that rootlocation finds the highest basedir. 20 | 21 | 22 | 23 | parent 24 | submodule 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /src/it/rootlocation-in-submodule-nested-separate-parent/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | 5 | 6 | org.codehaus.mojo 7 | build-helper-rootlocation-parent 8 | 1-SNAPSHOT 9 | parent/pom.xml 10 | 11 | 12 | org.codehaus.mojo 13 | build-helper-rootlocation-root 14 | 1-SNAPSHOT 15 | pom 16 | 17 | rootlocation search top root 18 | 19 | Tests that rootlocation finds the highest basedir. 20 | 21 | 22 | 23 | parent 24 | modules 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /src/it/surefire/src/test/java/org/codehaus/mojo/PassReservedPortToSureFireTest.java: -------------------------------------------------------------------------------- 1 | package org.codehaus.mojo; 2 | 3 | import java.io.File; 4 | 5 | import junit.framework.TestCase; 6 | 7 | public class PassReservedPortToSureFireTest 8 | extends TestCase 9 | { 10 | public void testCheckSystemProperties() 11 | throws Exception 12 | { 13 | String port = System.getProperty( "port1" ); 14 | Integer.parseInt( port ); 15 | } 16 | 17 | public void testCheckEnvironment() 18 | throws Exception 19 | { 20 | String port = System.getenv( "port1" ); 21 | Integer.parseInt( port ); 22 | } 23 | 24 | public void testCheckEnvironmentUsingMavenProject() 25 | throws Exception 26 | { 27 | String env = System.getenv( "targetDir" ); 28 | 29 | String expectEnv = new File( System.getProperty( "basedir", "." ), "target" ).getAbsolutePath(); 30 | 31 | assertEquals( expectEnv, env ); 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /src/it/rootlocation-in-submodule-deeperlevel-separate-parent/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | 5 | 6 | org.codehaus.mojo 7 | build-helper-rootlocation-parent 8 | 1-SNAPSHOT 9 | parent/pom.xml 10 | 11 | 12 | org.codehaus.mojo 13 | build-helper-rootlocation-root 14 | 1-SNAPSHOT 15 | pom 16 | 17 | rootlocation search top root 18 | 19 | Tests that rootlocation finds the highest basedir. 20 | 21 | 22 | 23 | parent 24 | modules/submodule 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /src/it/released-version-existing-asset/settings-maven-central.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | default 8 | 9 | 10 | central 11 | https://repo1.maven.org/maven2/ 12 | default 13 | 14 | 15 | 16 | 17 | central 18 | https://repo1.maven.org/maven2/ 19 | default 20 | 21 | 22 | 23 | 24 | 25 | default 26 | 27 | 28 | -------------------------------------------------------------------------------- /src/it/rootlocation/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | 5 | org.codehaus.mojo 6 | build-helper-rootlocation 7 | 1-SNAPSHOT 8 | jar 9 | 10 | rootlocation 11 | 12 | Tests that rootlocation is set. 13 | 14 | 15 | 16 | 17 | 18 | @project.groupId@ 19 | @project.artifactId@ 20 | @project.version@ 21 | 22 | 23 | 24 | rootlocation 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /.github/workflows/maven.yml: -------------------------------------------------------------------------------- 1 | # Licensed to the Apache Software Foundation (ASF) under one 2 | # or more contributor license agreements. See the NOTICE file 3 | # distributed with this work for additional information 4 | # regarding copyright ownership. The ASF licenses this file 5 | # to you under the Apache License, Version 2.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | # KIND, either express or implied. See the License for the 15 | # specific language governing permissions and limitations 16 | # under the License. 17 | 18 | name: GitHub CI 19 | 20 | on: [push, pull_request] 21 | 22 | jobs: 23 | build: 24 | name: Verify 25 | uses: apache/maven-gh-actions-shared/.github/workflows/maven-verify.yml@v4 26 | -------------------------------------------------------------------------------- /src/it/parse-version/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | 5 | org.codehaus.mojo 6 | build-helper-maven-plugin-reverse-port-it 7 | 20.4.00.0-SNAPSHOT 8 | 9 | build-helper-maven-plugin-parse-version-it 10 | 11 | 12 | 13 | 14 | package 15 | 16 | 17 | 18 | 19 | 20 | 21 | @project.groupId@ 22 | @project.artifactId@ 23 | @project.version@ 24 | 25 | 26 | 27 | parse-version-001 28 | 29 | parse-version 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /src/it/released-version-existing-snapshot/settings-maven-oss-snapshot.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | default 9 | 10 | 11 | 12 | oss-snap 13 | https://oss.sonatype.org/content/groups/public/ 14 | 15 | false 16 | fail 17 | 18 | 19 | true 20 | fail 21 | 22 | 23 | 24 | 25 | 26 | 27 | default 28 | 29 | 30 | -------------------------------------------------------------------------------- /src/it/timestamp-timesource/module-1/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4.0.0 3 | 4 | 5 | localdomain.localhost 6 | timestamp-timesource 7 | 1-SNAPSHOT 8 | 9 | 10 | timestamp-timesource-module-1 11 | jar 12 | 13 | Timestamp TimeSource Module 1 14 | 15 | 16 | 17 | 18 | src/main/resources 19 | 20 | test.properties 21 | 22 | false 23 | 24 | 25 | src/main/resources 26 | 27 | test.properties 28 | 29 | true 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /src/it/timestamp-timesource/module-2/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4.0.0 3 | 4 | 5 | localdomain.localhost 6 | timestamp-timesource 7 | 1-SNAPSHOT 8 | 9 | 10 | timestamp-timesource-module-2 11 | jar 12 | 13 | Timestamp TimeSource Module 2 14 | 15 | 16 | 17 | 18 | src/main/resources 19 | 20 | test.properties 21 | 22 | false 23 | 24 | 25 | src/main/resources 26 | 27 | test.properties 28 | 29 | true 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /src/it/rootlocation-in-submodule/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | 5 | org.codehaus.mojo 6 | build-helper-rootlocation-parent 7 | 1-SNAPSHOT 8 | pom 9 | 10 | rootlocation search top root 11 | 12 | Tests that rootlocation finds the highest basedir. 13 | 14 | 15 | 16 | submodule 17 | 18 | 19 | 20 | 21 | 22 | @project.groupId@ 23 | @project.artifactId@ 24 | @project.version@ 25 | 26 | 27 | 28 | rootlocation 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | 2 | The MIT License 3 | 4 | Copyright 2006-2012 The Codehaus. 5 | Copyright 2015-2016 The MojoHaus. 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy of 8 | this software and associated documentation files \(the "Software"\), to deal in 9 | the Software without restriction, including without limitation the rights to 10 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 11 | of the Software, and to permit persons to whom the Software is furnished to do 12 | so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in all 15 | copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | SOFTWARE. 24 | -------------------------------------------------------------------------------- /src/it/parse-version/verify.groovy: -------------------------------------------------------------------------------- 1 | 2 | File file = new File( basedir, "build.log" ); 3 | assert file.exists(); 4 | 5 | String text = file.getText("utf-8"); 6 | 7 | assert text.contains("major: 20") 8 | assert text.contains("minor: 4") 9 | assert text.contains("incremental: 0") 10 | assert text.contains("buildnumber: 0") 11 | assert text.contains("qualifier: 0-SNAPSHOT") 12 | 13 | assert text.contains("define property parsedVersion.majorVersion = \"20\"") 14 | assert text.contains("define property parsedVersion.minorVersion = \"4\"") 15 | assert text.contains("define property parsedVersion.incrementalVersion = \"0\"") 16 | assert text.contains("define property parsedVersion.nextMajorVersion = \"21\"") 17 | assert text.contains("define property parsedVersion.nextMinorVersion = \"5\"") 18 | assert text.contains("define property parsedVersion.nextIncrementalVersion = \"1\"") 19 | assert text.contains("define property parsedVersion.nextBuildNumber = \"1\"") 20 | assert text.contains("define property parsedVersion.qualifier = \"0-SNAPSHOT\"") 21 | assert text.contains("define property parsedVersion.buildNumber = \"0\"") 22 | assert text.contains("define property parsedVersion.osgiVersion = \"20.4.0.0-SNAPSHOT\"") 23 | 24 | return true; 25 | -------------------------------------------------------------------------------- /src/it/released-version-existing-snapshot/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4.0.0 3 | 4 | 5 | 6 | org.codehaus.mojo 7 | versions-maven-plugin 8 | 1.0.0-SNAPHOST 9 | build-helper-maven-plugin-released-version-it 10 | 11 | 12 | 13 | 14 | @project.groupId@ 15 | @project.artifactId@ 16 | @project.version@ 17 | 18 | 19 | released-version 20 | 21 | released-version 22 | 23 | 24 | myReleasedVersion 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # MojoHaus Build Helper Maven Plugin 2 | 3 | [![The MIT License](https://img.shields.io/github/license/mojohaus/build-helper-maven-plugin.svg?label=License)](https://opensource.org/licenses/MIT) 4 | [![Maven Central](https://img.shields.io/maven-central/v/org.codehaus.mojo/build-helper-maven-plugin.svg?label=Maven%20Central)](https://search.maven.org/artifact/org.codehaus.mojo/build-helper-maven-plugin) 5 | [![Build Status](https://github.com/mojohaus/build-helper-maven-plugin/workflows/GitHub%20CI/badge.svg?branch=master)](https://github.com/mojohaus/build-helper-maven-plugin/actions/workflows/maven.yml?query=branch%3Amaster) 6 | 7 | This is the [build-helper-maven-plugin](http://www.mojohaus.org/build-helper-maven-plugin/) contains 8 | serveral goals to support you in different kinds of task, like parsing version information, 9 | add supplemental source/test folders to a Maven project or attach supplemental artifacts. 10 | 11 | More details can be found on the [goals overview page](http://www.mojohaus.org/build-helper-maven-plugin/). 12 | 13 | ## Releasing 14 | 15 | * Make sure `gpg-agent` is running. 16 | * Execute `mvn -B release:prepare release:perform` 17 | 18 | For publishing the site do the following: 19 | 20 | ``` 21 | cd target/checkout 22 | mvn verify site site:stage scm-publish:publish-scm 23 | ``` 24 | 25 | -------------------------------------------------------------------------------- /src/site/site.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 17 | 18 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /src/it/rootlocation-run-only-at-exec-root/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | 5 | org.codehaus.mojo 6 | build-helper-rootlocation-parent 7 | 1-SNAPSHOT 8 | pom 9 | 10 | rootlocation run only at execution root 11 | 12 | Tests that rootlocation is executed only at execution top level. 13 | 14 | 15 | 16 | submodule 17 | 18 | 19 | 20 | 21 | 22 | @project.groupId@ 23 | @project.artifactId@ 24 | @project.version@ 25 | 26 | 27 | 28 | rootlocation 29 | 30 | 31 | true 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /header.txt: -------------------------------------------------------------------------------- 1 | ^package 2 | ^\s*$ 3 | ^/\*\s*$ 4 | ^ \* The MIT License\s*$ 5 | ^ \*\s*$ 6 | ^ \* Copyright \(c\) \d{4}(-\d{4}){0,1}, The Codehaus\s*$ 7 | ^ \*\s*$ 8 | ^ \* Permission is hereby granted, free of charge, to any person obtaining a copy of\s*$ 9 | ^ \* this software and associated documentation files \(the "Software"\), to deal in\s*$ 10 | ^ \* the Software without restriction, including without limitation the rights to\s*$ 11 | ^ \* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies\s*$ 12 | ^ \* of the Software, and to permit persons to whom the Software is furnished to do\s*$ 13 | ^ \* so, subject to the following conditions:\s*$ 14 | ^ \*\s*$ 15 | ^ \* The above copyright notice and this permission notice shall be included in all\s*$ 16 | ^ \* copies or substantial portions of the Software\.\s*$ 17 | ^ \*\s*$ 18 | ^ \* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\s*$ 19 | ^ \* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\s*$ 20 | ^ \* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\s*$ 21 | ^ \* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\s*$ 22 | ^ \* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\s*$ 23 | ^ \* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\s*$ 24 | ^ \* SOFTWARE\.\s*$ 25 | ^ \*/\s*$ 26 | ^\s*$ 27 | -------------------------------------------------------------------------------- /src/it/add-source-skip/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | 5 | build-helper 6 | integration-test 7 | 1.0-SNAPSHOT 8 | 9 | 10 | 11 | 12 | @project.groupId@ 13 | @project.artifactId@ 14 | @project.version@ 15 | 16 | 17 | integration-test 18 | generate-sources 19 | 20 | add-source 21 | 22 | 23 | 24 | ${project.basedir}/not-existing 25 | 26 | true 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /src/it/add-test-source-skip/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | 5 | build-helper 6 | integration-test 7 | 1.0-SNAPSHOT 8 | 9 | 10 | 11 | 12 | @project.groupId@ 13 | @project.artifactId@ 14 | @project.version@ 15 | 16 | 17 | integration-test 18 | generate-sources 19 | 20 | add-test-source 21 | 22 | 23 | 24 | ${project.basedir}/not-existing 25 | 26 | true 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /src/it/add-source-skip-if-missing/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | 5 | build-helper 6 | integration-test 7 | 1.0-SNAPSHOT 8 | 9 | 10 | 11 | 12 | @project.groupId@ 13 | @project.artifactId@ 14 | @project.version@ 15 | 16 | 17 | integration-test 18 | generate-sources 19 | 20 | add-source 21 | 22 | 23 | 24 | ${project.basedir}/not-existing 25 | 26 | true 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /src/it/add-test-source-skip-if-missing/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | 5 | build-helper 6 | integration-test 7 | 1.0-SNAPSHOT 8 | 9 | 10 | 11 | 12 | @project.groupId@ 13 | @project.artifactId@ 14 | @project.version@ 15 | 16 | 17 | integration-test 18 | generate-sources 19 | 20 | add-test-source 21 | 22 | 23 | 24 | ${project.basedir}/not-existing 25 | 26 | true 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /src/it/released-version-existing-asset-issue-108/settings-maven-central-no-snapshot.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | default 8 | 9 | 10 | central 11 | https://repo1.maven.org/maven2/ 12 | default 13 | 14 | true 15 | never 16 | 17 | 18 | false 19 | 20 | 21 | 22 | 23 | 24 | central 25 | https://repo1.maven.org/maven2/ 26 | default 27 | 28 | true 29 | never 30 | 31 | 32 | false 33 | 34 | 35 | 36 | 37 | 38 | 39 | default 40 | 41 | 42 | -------------------------------------------------------------------------------- /src/it/add-resource-skip/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | 5 | build-helper 6 | integration-test 7 | 1.0-SNAPSHOT 8 | 9 | 10 | 11 | 12 | @project.groupId@ 13 | @project.artifactId@ 14 | @project.version@ 15 | 16 | 17 | integration-test 18 | generate-sources 19 | 20 | add-resource 21 | 22 | 23 | 24 | 25 | ${project.basedir}/not-existing 26 | does-not-matter 27 | 28 | 29 | true 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /src/it/mbuildhelper-34/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | 5 | org.codehaus.mojo 6 | build-helper-mbuildhelper-34 7 | 1-SNAPSHOT 8 | jar 9 | 10 | Regex valid with spaces replacement 11 | 12 | 13 | 14 | src/main/resources 15 | 16 | test.properties 17 | 18 | false 19 | 20 | 21 | src/main/resources 22 | 23 | test.properties 24 | 25 | true 26 | 27 | 28 | 29 | 30 | @project.groupId@ 31 | @project.artifactId@ 32 | @project.version@ 33 | 34 | 35 | 36 | regex-property 37 | 38 | 39 | propname 40 | chapi chapo bidiba 41 | chapo 42 | 43 | true 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | -------------------------------------------------------------------------------- /src/it/add-test-resource-skip/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | 5 | build-helper 6 | integration-test 7 | 1.0-SNAPSHOT 8 | 9 | 10 | 11 | 12 | @project.groupId@ 13 | @project.artifactId@ 14 | @project.version@ 15 | 16 | 17 | integration-test 18 | generate-sources 19 | 20 | add-test-resource 21 | 22 | 23 | 24 | 25 | ${project.basedir}/not-existing 26 | does-not-matter 27 | 28 | 29 | true 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /src/it/add-resource-skip-if-missing/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | 5 | build-helper 6 | integration-test 7 | 1.0-SNAPSHOT 8 | 9 | 10 | 11 | 12 | @project.groupId@ 13 | @project.artifactId@ 14 | @project.version@ 15 | 16 | 17 | integration-test 18 | generate-sources 19 | 20 | add-resource 21 | 22 | 23 | 24 | 25 | ${project.basedir}/not-existing 26 | does-not-matter 27 | 28 | 29 | true 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /src/it/bsh-property/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | 5 | org.codehaus.mojo 6 | build-helper-maven-plugin-bsh-property-it 7 | 1-SNAPSHOT 8 | jar 9 | 10 | bsh-property IT 11 | 12 | Tests that a Beanshell script can be run, access project, session and settings, and define properties. 13 | 14 | 15 | 16 | 17 | 18 | @project.groupId@ 19 | @project.artifactId@ 20 | @project.version@ 21 | 22 | 23 | 24 | bsh-property 25 | 26 | 27 | 28 | name 29 | root 30 | local 31 | 32 | 33 | name = project.getName(); 34 | root = session.getExecutionRootDirectory(); 35 | local = settings.getLocalRepository(); 36 | plexus = session.getContainer(); 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /src/it/add-test-resource-skip-if-missing/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | 5 | build-helper 6 | integration-test 7 | 1.0-SNAPSHOT 8 | 9 | 10 | 11 | 12 | @project.groupId@ 13 | @project.artifactId@ 14 | @project.version@ 15 | 16 | 17 | integration-test 18 | generate-sources 19 | 20 | add-test-resource 21 | 22 | 23 | 24 | 25 | ${project.basedir}/not-existing 26 | does-not-matter 27 | 28 | 29 | true 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /src/it/timestamp-valid/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4.0.0 3 | 4 | localdomain.localhost 5 | timestamp-valid 6 | 1-SNAPSHOT 7 | jar 8 | 9 | Timestamp Valid 10 | 11 | Tests that a valid timestamp gets generated 12 | 13 | 14 | 15 | 16 | 17 | src/main/resources 18 | 19 | test.properties 20 | 21 | false 22 | 23 | 24 | src/main/resources 25 | 26 | test.properties 27 | 28 | true 29 | 30 | 31 | 32 | 33 | @project.groupId@ 34 | @project.artifactId@ 35 | @project.version@ 36 | 37 | 38 | 39 | timestamp-property 40 | 41 | 42 | timestamp 43 | en_US 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | -------------------------------------------------------------------------------- /src/main/resources/META-INF/m2e/lifecycle-mapping-metadata.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | add-resource 8 | add-source 9 | add-test-resource 10 | add-test-source 11 | bsh-property 12 | cpu-count 13 | local-ip 14 | maven-version 15 | parse-version 16 | regex-properties 17 | regex-property 18 | released-version 19 | reserve-network-port 20 | timestamp-property 21 | uptodate-properties 22 | uptodate-property 23 | rootlocation 24 | 25 | 26 | 27 | 28 | true 29 | true 30 | 31 | 32 | 33 | 34 | 35 | 36 | attach-artifact 37 | remove-project-artifact 38 | 39 | 40 | 41 | 42 | false 43 | false 44 | 45 | 46 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /src/it/mbuildhelper-53/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | 5 | org.codehaus.mojo 6 | build-helper-mbuildhelper-53 7 | 1-SNAPSHOT 8 | jar 9 | 10 | Regex valid with empty replacement 11 | 12 | Tests that an empty replacement works (previously failing as if replacement was not specified). 13 | 14 | 15 | 16 | 17 | 18 | src/main/resources 19 | 20 | test.properties 21 | 22 | false 23 | 24 | 25 | src/main/resources 26 | 27 | test.properties 28 | 29 | true 30 | 31 | 32 | 33 | 34 | @project.groupId@ 35 | @project.artifactId@ 36 | @project.version@ 37 | 38 | 39 | 40 | regex-property 41 | 42 | 43 | propname 44 | hi you 45 | you 46 | 47 | false 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | -------------------------------------------------------------------------------- /src/it/regex-no-match-keep-original-value-mbuildhelper-54/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | 5 | org.codehaus.mojo 6 | build-helper-mbuildhelper-54 7 | 1-SNAPSHOT 8 | jar 9 | 10 | Regex valid with empty replacement 11 | 12 | Tests no replacement keeps original value. 13 | 14 | 15 | 16 | 17 | 18 | src/main/resources 19 | 20 | test.properties 21 | 22 | false 23 | 24 | 25 | src/main/resources 26 | 27 | test.properties 28 | 29 | true 30 | 31 | 32 | 33 | 34 | @project.groupId@ 35 | @project.artifactId@ 36 | @project.version@ 37 | 38 | 39 | execution1 40 | 41 | regex-property 42 | 43 | 44 | propname 45 | originalvalue 46 | nomatch 47 | 48 | false 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | -------------------------------------------------------------------------------- /src/it/reserve-ports-to-file/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | 5 | org.codehaus.mojo 6 | build-helper-maven-plugin-reverse-port-it 7 | 1.0-SNAPSHOT 8 | 9 | build-helper-maven-plugin-reverse-port-it 10 | 11 | 12 | 13 | 14 | package 15 | 16 | 17 | 18 | 19 | 20 | 21 | @project.groupId@ 22 | @project.artifactId@ 23 | @project.version@ 24 | 25 | 26 | reserve-ports-to-files 27 | validate 28 | 29 | reserve-network-port 30 | 31 | 32 | ${project.build.directory}/ports.properties 33 | 34 | port1 35 | port2 36 | port3 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 54 | 55 | -------------------------------------------------------------------------------- /src/it/uptodate-multi/verify.groovy: -------------------------------------------------------------------------------- 1 | File file = new File( basedir, "build.log" ); 2 | assert file.exists(); 3 | 4 | String text = file.getText("utf-8"); 5 | 6 | assert !text.contains('define property propname-flatten = "outofdate"') : "Erroneously defined property propname-flatten = \"outofdate\"" 7 | assert text.contains('define property propname-flatten = "uptodate"') : "Failed to define property propname-flatten = \"uptodate\"" 8 | 9 | assert !text.contains('define property propname-glob = "outofdate"') : "Erroneously defined property propname-glob = \"outofdate\"" 10 | assert text.contains('define property propname-glob = "uptodate"') : "Failed to define property propname-glob = \"uptodate\"" 11 | 12 | assert !text.contains('define property propname-identity = "outofdate"') : "Erroneously defined property propname-identity = \"outofdate\"" 13 | assert text.contains('define property propname-identity = "uptodate"') : "Failed to define property propname-identity = \"uptodate\"" 14 | 15 | assert !text.contains('define property propname-merge = "outofdate"') : "Erroneously defined property propname-merge = \"outofdate\"" 16 | assert text.contains('define property propname-merge = "uptodate"') : "Failed to define property propname-merge = \"uptodate\"" 17 | 18 | assert !text.contains('define property propname-package = "outofdate"') : "Erroneously defined property propname-package = \"outofdate\"" 19 | assert text.contains('define property propname-package = "uptodate"') : "Failed to define property propname-package = \"uptodate\"" 20 | 21 | assert !text.contains('define property propname-unpackage = "outofdate"') : "Erroneously defined property propname-unpackage = \"outofdate\"" 22 | assert text.contains('define property propname-unpackage = "uptodate"') : "Failed to define property propname-unpackage = \"uptodate\"" 23 | 24 | return true; 25 | -------------------------------------------------------------------------------- /src/it/uptodate-multi-negative/verify.groovy: -------------------------------------------------------------------------------- 1 | File file = new File( basedir, "build.log" ); 2 | assert file.exists(); 3 | 4 | String text = file.getText("utf-8"); 5 | 6 | assert text.contains('define property propname-flatten = "outofdate"') : "Failed to define property propname-flatten = \"outofdate\"" 7 | assert !text.contains('define property propname-flatten = "uptodate"') : "Erroneously defined property propname-flatten = \"uptodate\"" 8 | 9 | assert text.contains('define property propname-glob = "outofdate"') : "Failed to define property propname-glob = \"outofdate\"" 10 | assert !text.contains('define property propname-glob = "uptodate"') : "Erroneously defined property propname-glob = \"uptodate\"" 11 | 12 | assert text.contains('define property propname-identity = "outofdate"') : "Failed to define property propname-identity = \"outofdate\"" 13 | assert !text.contains('define property propname-identity = "uptodate"') : "Erroneously defined property propname-identity = \"uptodate\"" 14 | 15 | assert text.contains('define property propname-merge = "outofdate"') : "Failed to define property propname-merge = \"outofdate\"" 16 | assert !text.contains('define property propname-merge = "uptodate"') : "Erroneously defined property propname-merge = \"uptodate\"" 17 | 18 | assert text.contains('define property propname-package = "outofdate"') : "Failed to define property propname-package = \"outofdate\"" 19 | assert !text.contains('define property propname-package = "uptodate"') : "Erroneously defined property propname-package = \"uptodate\"" 20 | 21 | assert text.contains('define property propname-unpackage = "outofdate"') : "Failed to define property propname-unpackage = \"outofdate\"" 22 | assert !text.contains('define property propname-unpackage = "uptodate"') : "Erroneously defined property propname-unpackage = \"uptodate\"" 23 | 24 | return true; 25 | -------------------------------------------------------------------------------- /src/it/regex-valid/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4.0.0 3 | 4 | org.codehaus.mojo 5 | build-helper-maven-plugin-regex-valid-it 6 | 1-SNAPSHOT 7 | jar 8 | 9 | Regex Valid 10 | 11 | Tests that a valid regex gets applied 12 | 13 | 14 | 15 | 16 | 17 | src/main/resources 18 | 19 | test.properties 20 | 21 | false 22 | 23 | 24 | src/main/resources 25 | 26 | test.properties 27 | 28 | true 29 | 30 | 31 | 32 | 33 | @project.groupId@ 34 | @project.artifactId@ 35 | @project.version@ 36 | 37 | 38 | 39 | regex-property 40 | 41 | 42 | build.version 43 | ${project.version} 44 | -SNAPSHOT 45 | -RC 46 | false 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | -------------------------------------------------------------------------------- /src/it/addResource/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | 5 | org.codehaus.mojo 6 | build-helper-maven-plugin-add-resource 7 | 1.0-SNAPSHOT 8 | 9 | build-helper-maven-plugin-add-resource 10 | 11 | 12 | package 13 | 14 | 15 | @project.groupId@ 16 | @project.artifactId@ 17 | @project.version@ 18 | 19 | 20 | add-resource 21 | 22 | add-resource 23 | 24 | 25 | 26 | 27 | src/my-resources 28 | my-resources 29 | 30 | 31 | 32 | 33 | 34 | add-test-resource 35 | 36 | add-test-resource 37 | 38 | 39 | 40 | 41 | src/my-test-resources 42 | my-test-resources 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | -------------------------------------------------------------------------------- /src/it/regex-invalid/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4.0.0 3 | 4 | org.codehaus.mojo 5 | build-helper-maven-plugin-regex-invalid-it 6 | 1-SNAPSHOT 7 | jar 8 | 9 | Regex Invalid 10 | 11 | Tests that a invalid regex fails the build 12 | 13 | 14 | 15 | 16 | 17 | src/main/resources 18 | 19 | test.properties 20 | 21 | false 22 | 23 | 24 | src/main/resources 25 | 26 | test.properties 27 | 28 | true 29 | 30 | 31 | 32 | 33 | @project.groupId@ 34 | @project.artifactId@ 35 | @project.version@ 36 | 37 | 38 | 39 | regex-property 40 | 41 | 42 | build.version 43 | ${project.version} 44 | -S(NAPSHOT 45 | -$1 46 | false 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | -------------------------------------------------------------------------------- /src/it/settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 21 | 22 | 23 | 24 | 25 | it-repo 26 | 27 | true 28 | 29 | 30 | 31 | local.central 32 | @localRepositoryUrl@ 33 | 34 | true 35 | 36 | 37 | true 38 | 39 | 40 | 41 | 42 | 43 | local.central 44 | @localRepositoryUrl@ 45 | 46 | true 47 | 48 | 49 | true 50 | 51 | 52 | 53 | 54 | 55 | 56 | -------------------------------------------------------------------------------- /src/it/regex-nomatch/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4.0.0 3 | 4 | org.codehaus.mojo 5 | build-helper-maven-plugin-regex-nomatch-it 6 | 1-SNAPSHOT 7 | jar 8 | 9 | Regex NoMatch 10 | 11 | Tests that failOfNoMatch will fail if no match 12 | 13 | 14 | 15 | 16 | 17 | src/main/resources 18 | 19 | test.properties 20 | 21 | false 22 | 23 | 24 | src/main/resources 25 | 26 | test.properties 27 | 28 | true 29 | 30 | 31 | 32 | 33 | @project.groupId@ 34 | @project.artifactId@ 35 | @project.version@ 36 | 37 | 38 | 39 | regex-property 40 | 41 | 42 | build.version 43 | ${project.version} 44 | NOT HERE 45 | Substitute 46 | true 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | -------------------------------------------------------------------------------- /src/it/timestamp-timesource/verify.bsh: -------------------------------------------------------------------------------- 1 | import java.io.*; 2 | import java.util.*; 3 | 4 | try 5 | { 6 | File module1File = new File( basedir, "module-1/target/classes/test.properties" ); 7 | File module2File = new File( basedir, "module-2/target/classes/test.properties" ); 8 | 9 | Properties module1Props = new Properties(); 10 | module1Props.load( new FileInputStream( module1File ) ); 11 | Properties module2Props = new Properties(); 12 | module2Props.load( new FileInputStream( module2File ) ); 13 | 14 | String module1ModuleVersion = module1Props.getProperty( "module.version" ); 15 | String module1SessionVersion = module1Props.getProperty( "session.version" ); 16 | String module2ModuleVersion = module2Props.getProperty( "module.version" ); 17 | String module2SessionVersion = module2Props.getProperty( "session.version" ); 18 | 19 | if ( module1ModuleVersion.indexOf( "${module.build.timestamp}" ) >= 0 20 | || module2ModuleVersion.indexOf( "${module.build.timestamp}" ) >= 0) 21 | { 22 | System.err.println( "Module timestamp not set" ); 23 | return false; 24 | } 25 | else if ( module1SessionVersion.indexOf( "${session.build.timestamp}" ) >= 0 26 | || module2SessionVersion.indexOf( "${session.build.timestamp}" ) >= 0) 27 | { 28 | System.err.println( "Session timestamp not set" ); 29 | return false; 30 | } 31 | 32 | if ( module1ModuleVersion.equals( module2ModuleVersion ) ) 33 | { 34 | System.err.println( "Module timestamps should not match by design" ); 35 | return false; 36 | } 37 | else if ( !module1SessionVersion.equals( module2SessionVersion ) ) 38 | { 39 | System.err.println( "Session timestamps should match by design" ); 40 | return false; 41 | } 42 | } 43 | catch( Throwable t ) 44 | { 45 | t.printStackTrace(); 46 | return false; 47 | } 48 | 49 | return true; 50 | -------------------------------------------------------------------------------- /src/it/regex-multi/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | 5 | org.codehaus.mojo 6 | build-helper-maven-plugin-regex-multi-valid-it 7 | 1-SNAPSHOT 8 | jar 9 | 10 | Regex Multi 11 | 12 | Tests that a valid regex gets applied 13 | 14 | 15 | 16 | 17 | 18 | src/main/resources 19 | 20 | test.properties 21 | 22 | false 23 | 24 | 25 | src/main/resources 26 | 27 | test.properties 28 | 29 | true 30 | 31 | 32 | 33 | 34 | @project.groupId@ 35 | @project.artifactId@ 36 | @project.version@ 37 | 38 | 39 | 40 | regex-properties 41 | 42 | 43 | 44 | 45 | build.version 46 | ${project.version} 47 | -SNAPSHOT 48 | -RC 49 | false 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | -------------------------------------------------------------------------------- /src/main/java/org/codehaus/mojo/buildhelper/versioning/DefaultVersioning.java: -------------------------------------------------------------------------------- 1 | package org.codehaus.mojo.buildhelper.versioning; 2 | 3 | /** 4 | * @author Karl Heinz Marbaise khmarbaise@apache.org 5 | */ 6 | public class DefaultVersioning implements Versioning { 7 | 8 | private VersionInformation vi; 9 | 10 | private String version; 11 | 12 | public DefaultVersioning(String version) { 13 | this.version = version; 14 | this.vi = new VersionInformation(version); 15 | } 16 | 17 | public String getVersion() { 18 | return this.version; 19 | } 20 | 21 | @Override 22 | public int getMajor() { 23 | return this.vi.getMajor(); 24 | } 25 | 26 | @Override 27 | public int getMinor() { 28 | return this.vi.getMinor(); 29 | } 30 | 31 | @Override 32 | public int getPatch() { 33 | return this.vi.getPatch(); 34 | } 35 | 36 | @Override 37 | public String getAsOSGiVersion() { 38 | StringBuffer osgiVersion = new StringBuffer(); 39 | osgiVersion.append(this.getMajor()); 40 | osgiVersion.append("." + this.getMinor()); 41 | osgiVersion.append("." + this.getPatch()); 42 | 43 | if (this.getQualifier() != null || this.getBuildNumber() != 0) { 44 | osgiVersion.append("."); 45 | 46 | if (this.getBuildNumber() != 0) { 47 | osgiVersion.append(this.getBuildNumber()); 48 | } 49 | if (this.getQualifier() != null) { 50 | // Do not allow having "." in it cause it's not allowed in OSGi. 51 | String qualifier = this.getQualifier().replaceAll("\\.", "_"); 52 | osgiVersion.append(qualifier); 53 | } 54 | } 55 | 56 | return osgiVersion.toString(); 57 | } 58 | 59 | @Override 60 | public long getBuildNumber() { 61 | return this.vi.getBuildNumber(); 62 | } 63 | 64 | @Override 65 | public String getQualifier() { 66 | return this.vi.getQualifier(); 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /src/it/parse-version-issue-91/verify.groovy: -------------------------------------------------------------------------------- 1 | 2 | File file = new File( basedir, "build.log" ); 3 | assert file.exists(); 4 | 5 | String text = file.getText("utf-8"); 6 | 7 | // versionString given on command line. see invoker.properties. 8 | assert text.contains("(f) versionString = 10.0.2-4545-RC1") 9 | // 10 | assert text.contains("major: 10") 11 | assert text.contains("minor: 0") 12 | assert text.contains("incremental: 2") 13 | assert text.contains("buildnumber: 4545") 14 | assert text.contains("qualifier: -RC1") 15 | 16 | assert text.contains("define property parsedVersion.majorVersion = \"10\"") 17 | assert text.contains("define property parsedVersion.minorVersion = \"0\"") 18 | assert text.contains("define property parsedVersion.incrementalVersion = \"2\"") 19 | assert text.contains("define property parsedVersion.buildNumber = \"4545\"") 20 | assert text.contains("define property parsedVersion.nextMajorVersion = \"11\"") 21 | assert text.contains("define property parsedVersion.nextMinorVersion = \"1\"") 22 | assert text.contains("define property parsedVersion.nextIncrementalVersion = \"3\"") 23 | assert text.contains("define property parsedVersion.nextBuildNumber = \"4546\"") 24 | assert text.contains("define property formattedVersion.majorVersion = \"10\"") 25 | assert text.contains("define property formattedVersion.minorVersion = \"00\"") 26 | assert text.contains("define property formattedVersion.incrementalVersion = \"02\"") 27 | assert text.contains("define property formattedVersion.buildNumber = \"4545\"") 28 | assert text.contains("define property formattedVersion.nextMajorVersion = \"11\"") 29 | assert text.contains("define property formattedVersion.nextMinorVersion = \"01\"") 30 | assert text.contains("define property formattedVersion.nextIncrementalVersion = \"03\"") 31 | assert text.contains("define property formattedVersion.nextBuildNumber = \"4546\"") 32 | assert text.contains("define property parsedVersion.qualifier = \"-RC1\"") 33 | assert text.contains("define property parsedVersion.qualifier? = \"--RC1\"") 34 | assert text.contains("define property parsedVersion.osgiVersion = \"10.0.2.4545-RC1\"") 35 | 36 | return true; -------------------------------------------------------------------------------- /src/main/java/org/codehaus/mojo/buildhelper/AbstractDefinePropertyMojo.java: -------------------------------------------------------------------------------- 1 | package org.codehaus.mojo.buildhelper; 2 | 3 | /* 4 | * The MIT License 5 | * 6 | * Copyright (c) 2004, The Codehaus 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy of 9 | * this software and associated documentation files (the "Software"), to deal in 10 | * the Software without restriction, including without limitation the rights to 11 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 12 | * of the Software, and to permit persons to whom the Software is furnished to do 13 | * so, subject to the following conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be included in all 16 | * copies or substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 24 | * SOFTWARE. 25 | */ 26 | 27 | import org.apache.maven.plugin.AbstractMojo; 28 | import org.apache.maven.plugins.annotations.Parameter; 29 | import org.apache.maven.project.MavenProject; 30 | 31 | public abstract class AbstractDefinePropertyMojo extends AbstractMojo { 32 | /** 33 | * The maven project 34 | */ 35 | @Parameter(readonly = true, defaultValue = "${project}") 36 | protected MavenProject project; 37 | 38 | protected void defineProperty(String name, String value) { 39 | if (getLog().isDebugEnabled()) { 40 | getLog().debug("define property " + name + " = \"" + value + "\""); 41 | } 42 | 43 | project.getProperties().put(name, value); 44 | } 45 | 46 | /** 47 | * Get the current project instance. 48 | * 49 | * @return the project 50 | */ 51 | public MavenProject getProject() { 52 | return this.project; 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /src/it/timestamp-timesource/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4.0.0 3 | 4 | localdomain.localhost 5 | timestamp-timesource 6 | 1-SNAPSHOT 7 | pom 8 | 9 | Timestamp TimeSource 10 | 11 | Tests that a fixed timestamp gets generated 12 | 13 | 14 | 15 | module-1 16 | module-2 17 | 18 | 19 | 20 | yyyy-MM-dd HH:mm:ss.SSS z 21 | 22 | 23 | 24 | 25 | 26 | @project.groupId@ 27 | @project.artifactId@ 28 | @project.version@ 29 | 30 | 31 | module-timestamp-property 32 | validate 33 | 34 | timestamp-property 35 | 36 | 37 | module.build.timestamp 38 | ${maven.build.timestamp.format} 39 | Europe/Amsterdam 40 | 41 | 42 | 43 | 44 | 45 | session-timestamp-property 46 | validate 47 | 48 | timestamp-property 49 | 50 | 51 | session.build.timestamp 52 | ${maven.build.timestamp.format} 53 | Europe/Amsterdam 54 | build 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | -------------------------------------------------------------------------------- /src/it/timestamp-regex/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4.0.0 3 | 4 | localdomain.localhost 5 | timestamp-jenkins 6 | 1-SNAPSHOT 7 | jar 8 | 9 | Timestamp Jenkins 10 | 11 | Tests that a jenkins style timestamp can be set 12 | 13 | 14 | 15 | 16 | 17 | src/main/resources 18 | 19 | test.properties 20 | 21 | false 22 | 23 | 24 | src/main/resources 25 | 26 | test.properties 27 | 28 | true 29 | 30 | 31 | 32 | 33 | @project.groupId@ 34 | @project.artifactId@ 35 | @project.version@ 36 | 37 | 38 | timestamp 39 | 40 | timestamp-property 41 | 42 | 43 | timestamp 44 | en_US 45 | hh:mm dd-MM-yyyy 46 | 47 | 48 | 49 | version 50 | 51 | regex-property 52 | 53 | 54 | build.version 55 | ${project.version} 56 | -SNAPSHOT 57 | -RC (${timestamp} private) 58 | false 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | -------------------------------------------------------------------------------- /src/it/uptodate-identity/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4.0.0 3 | 4 | org.codehaus.mojo 5 | build-helper-maven-plugin-uptodate-identity-it 6 | 1-SNAPSHOT 7 | jar 8 | 9 | UpToDate Identity 10 | Tests that uptodate-property with identity mapping works 11 | 12 | 13 | 14 | 15 | src/main/resources 16 | 17 | test.properties 18 | 19 | false 20 | 21 | 22 | src/main/resources 23 | 24 | test.properties 25 | 26 | true 27 | 28 | 29 | 30 | 31 | @project.groupId@ 32 | @project.artifactId@ 33 | @project.version@ 34 | 35 | 36 | 37 | uptodate-property 38 | 39 | 40 | propname-identity 41 | uptodate 42 | outofdate 43 | outofdate 44 | 45 | src/main/resources/source 46 | src/main/resources/target 47 | 48 | dir*/** 49 | 50 | 51 | **/*X* 52 | **/*Y/** 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | -------------------------------------------------------------------------------- /src/it/uptodate-flatten/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4.0.0 3 | 4 | org.codehaus.mojo 5 | build-helper-maven-plugin-uptodate-flatten-it 6 | 1-SNAPSHOT 7 | jar 8 | 9 | UpToDate Flatten 10 | Tests that uptodate-property with flatten mapping works 11 | 12 | 13 | 14 | 15 | src/main/resources 16 | 17 | test.properties 18 | 19 | false 20 | 21 | 22 | src/main/resources 23 | 24 | test.properties 25 | 26 | true 27 | 28 | 29 | 30 | 31 | @project.groupId@ 32 | @project.artifactId@ 33 | @project.version@ 34 | 35 | 36 | 37 | uptodate-property 38 | 39 | 40 | propname-flatten 41 | uptodate 42 | outofdate 43 | 44 | src/main/resources/source 45 | src/main/resources/target 46 | 47 | dir*/** 48 | 49 | 50 | **/*X* 51 | **/*Y/** 52 | 53 | 54 | flatten 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | -------------------------------------------------------------------------------- /src/it/uptodate-multi/fixture.properties: -------------------------------------------------------------------------------- 1 | src/main/resources/source/dirA/fileAA.s = 1 2 | src/main/resources/source/dirA/fileAB.s = 2 3 | src/main/resources/source/dirA/fileAX.s = 3 4 | src/main/resources/source/dirB/fileBA.s = 4 5 | src/main/resources/source/dirB/fileBB.s = 5 6 | src/main/resources/source/dirB/fileBX.s = 6 7 | src/main/resources/source/dirY/fileYA.s = 7 8 | src/main/resources/source/dirY/fileYB.s = 8 9 | src/main/resources/source/dirY/fileYX.s = 9 10 | 11 | src/main/resources/source/unpackage/dirA.fileAA.s = 1 12 | src/main/resources/source/unpackage/dirA.fileAB.s = 2 13 | src/main/resources/source/unpackage/dirA.fileAX.s = 3 14 | src/main/resources/source/unpackage/dirB.fileBA.s = 4 15 | src/main/resources/source/unpackage/dirB.fileBB.s = 5 16 | src/main/resources/source/unpackage/dirB.fileBX.s = 6 17 | src/main/resources/source/unpackage/dirY.fileYA.s = 7 18 | src/main/resources/source/unpackage/dirY.fileYB.s = 8 19 | src/main/resources/source/unpackage/dirY.fileYX.s = 9 20 | 21 | src/main/resources/target/flatten/fileAA.s = 1 22 | src/main/resources/target/flatten/fileAB.s = 3 23 | src/main/resources/target/flatten/fileAX.s = 0 24 | src/main/resources/target/flatten/fileBA.s = 5 25 | src/main/resources/target/flatten/fileBB.s = 6 26 | 27 | src/main/resources/target/glob/dirA/fileAA.t = 1 28 | src/main/resources/target/glob/dirA/fileAB.t = 3 29 | src/main/resources/target/glob/dirA/fileAX.t = 0 30 | src/main/resources/target/glob/dirB/fileBA.t = 5 31 | src/main/resources/target/glob/dirB/fileBB.t = 6 32 | 33 | src/main/resources/target/identity/dirA/fileAA.s = 1 34 | src/main/resources/target/identity/dirA/fileAB.s = 3 35 | src/main/resources/target/identity/dirA/fileAX.s = 0 36 | src/main/resources/target/identity/dirB/fileBA.s = 5 37 | src/main/resources/target/identity/dirB/fileBB.s = 6 38 | 39 | src/main/resources/target/merge/todir/outfile.t = 6 40 | 41 | src/main/resources/target/package/dirA.fileAA.t = 1 42 | src/main/resources/target/package/dirA.fileAB.t = 3 43 | src/main/resources/target/package/dirA.fileAX.t = 0 44 | src/main/resources/target/package/dirB.fileBA.t = 5 45 | src/main/resources/target/package/dirB.fileBB.t = 6 46 | 47 | src/main/resources/target/unpackage/dirA/fileAA.t = 1 48 | src/main/resources/target/unpackage/dirA/fileAB.t = 3 49 | src/main/resources/target/unpackage/dirA/fileAX.t = 0 50 | src/main/resources/target/unpackage/dirB/fileBA.t = 5 51 | src/main/resources/target/unpackage/dirB/fileBB.t = 6 -------------------------------------------------------------------------------- /src/it/uptodate-glob/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4.0.0 3 | 4 | org.codehaus.mojo 5 | build-helper-maven-plugin-uptodate-glob-it 6 | 1-SNAPSHOT 7 | jar 8 | 9 | UpToDate Glob 10 | Tests that uptodate-property with glob mapping works 11 | 12 | 13 | 14 | 15 | src/main/resources 16 | 17 | test.properties 18 | 19 | false 20 | 21 | 22 | src/main/resources 23 | 24 | test.properties 25 | 26 | true 27 | 28 | 29 | 30 | 31 | @project.groupId@ 32 | @project.artifactId@ 33 | @project.version@ 34 | 35 | 36 | 37 | uptodate-property 38 | 39 | 40 | propname-glob 41 | uptodate 42 | outofdate 43 | 44 | src/main/resources/source 45 | src/main/resources/target 46 | 47 | dir*/** 48 | 49 | 50 | **/*X* 51 | **/*Y/** 52 | 53 | 54 | glob 55 | *.s 56 | *.t 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | -------------------------------------------------------------------------------- /src/it/uptodate-merge/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4.0.0 3 | 4 | org.codehaus.mojo 5 | build-helper-maven-plugin-uptodate-merge-it 6 | 1-SNAPSHOT 7 | jar 8 | 9 | UpToDate Merge 10 | Tests that uptodate-property with merge mapping works 11 | 12 | 13 | 14 | 15 | src/main/resources 16 | 17 | test.properties 18 | 19 | false 20 | 21 | 22 | src/main/resources 23 | 24 | test.properties 25 | 26 | true 27 | 28 | 29 | 30 | 31 | @project.groupId@ 32 | @project.artifactId@ 33 | @project.version@ 34 | 35 | 36 | 37 | uptodate-property 38 | 39 | 40 | propname-merge 41 | uptodate 42 | outofdate 43 | 44 | src/main/resources/source 45 | src/main/resources/target 46 | 47 | dir*/** 48 | 49 | 50 | **/*X* 51 | **/*Y/** 52 | 53 | 54 | merge 55 | file*.s 56 | todir/outfile.t 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | -------------------------------------------------------------------------------- /src/it/uptodate-package/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4.0.0 3 | 4 | org.codehaus.mojo 5 | build-helper-maven-plugin-uptodate-package-it 6 | 1-SNAPSHOT 7 | jar 8 | 9 | UpToDate Package 10 | Tests that uptodate-property with package mapping works 11 | 12 | 13 | 14 | 15 | src/main/resources 16 | 17 | test.properties 18 | 19 | false 20 | 21 | 22 | src/main/resources 23 | 24 | test.properties 25 | 26 | true 27 | 28 | 29 | 30 | 31 | @project.groupId@ 32 | @project.artifactId@ 33 | @project.version@ 34 | 35 | 36 | 37 | uptodate-property 38 | 39 | 40 | propname-package 41 | uptodate 42 | outofdate 43 | 44 | src/main/resources/source 45 | src/main/resources/target 46 | 47 | dir*/** 48 | 49 | 50 | **/*X* 51 | **/*Y/** 52 | 53 | 54 | package 55 | *.s 56 | *.t 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | -------------------------------------------------------------------------------- /src/it/uptodate-unpackage/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4.0.0 3 | 4 | org.codehaus.mojo 5 | build-helper-maven-plugin-uptodate-unpackage-it 6 | 1-SNAPSHOT 7 | jar 8 | 9 | UpToDate Unpackage 10 | Tests that uptodate-property with unpackage mapping works 11 | 12 | 13 | 14 | 15 | src/main/resources 16 | 17 | test.properties 18 | 19 | false 20 | 21 | 22 | src/main/resources 23 | 24 | test.properties 25 | 26 | true 27 | 28 | 29 | 30 | 31 | @project.groupId@ 32 | @project.artifactId@ 33 | @project.version@ 34 | 35 | 36 | 37 | uptodate-property 38 | 39 | 40 | propname-unpackage 41 | uptodate 42 | outofdate 43 | 44 | src/main/resources/source 45 | src/main/resources/target 46 | 47 | dir*.s 48 | 49 | 50 | *X* 51 | *Y* 52 | 53 | 54 | unpackage 55 | *.s 56 | *.t 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | -------------------------------------------------------------------------------- /src/main/java/org/codehaus/mojo/buildhelper/HostnameMojo.java: -------------------------------------------------------------------------------- 1 | package org.codehaus.mojo.buildhelper; 2 | 3 | /* 4 | * The MIT License 5 | * 6 | * Copyright (c) 2004, The Codehaus 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy of 9 | * this software and associated documentation files (the "Software"), to deal in 10 | * the Software without restriction, including without limitation the rights to 11 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 12 | * of the Software, and to permit persons to whom the Software is furnished to do 13 | * so, subject to the following conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be included in all 16 | * copies or substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 24 | * SOFTWARE. 25 | */ 26 | 27 | import java.net.InetAddress; 28 | import java.net.UnknownHostException; 29 | 30 | import org.apache.maven.plugin.MojoExecutionException; 31 | import org.apache.maven.plugins.annotations.LifecyclePhase; 32 | import org.apache.maven.plugins.annotations.Mojo; 33 | import org.apache.maven.plugins.annotations.Parameter; 34 | 35 | /** 36 | * Retrieve current hostname and place it under a configurable project property 37 | * 38 | * @author John Patrick 39 | * @since 3.0.0 40 | */ 41 | @Mojo(name = "hostname", defaultPhase = LifecyclePhase.PROCESS_TEST_CLASSES, threadSafe = true) 42 | public class HostnameMojo extends AbstractDefinePropertyMojo { 43 | 44 | /** 45 | * The name of the property in which to store the hostname. 46 | */ 47 | @Parameter(defaultValue = "hostname") 48 | private String hostnameProperty; 49 | 50 | public void execute() throws MojoExecutionException { 51 | try { 52 | defineProperty(this.hostnameProperty, InetAddress.getLocalHost().getHostName()); 53 | } catch (UnknownHostException e) { 54 | throw new MojoExecutionException("Unable to retrieve hostname.", e); 55 | } 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /src/main/java/org/codehaus/mojo/buildhelper/LocalIpMojo.java: -------------------------------------------------------------------------------- 1 | package org.codehaus.mojo.buildhelper; 2 | 3 | /* 4 | * The MIT License 5 | * 6 | * Copyright (c) 2004, The Codehaus 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy of 9 | * this software and associated documentation files (the "Software"), to deal in 10 | * the Software without restriction, including without limitation the rights to 11 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 12 | * of the Software, and to permit persons to whom the Software is furnished to do 13 | * so, subject to the following conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be included in all 16 | * copies or substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 24 | * SOFTWARE. 25 | */ 26 | 27 | import java.net.InetAddress; 28 | import java.net.UnknownHostException; 29 | 30 | import org.apache.maven.plugin.MojoExecutionException; 31 | import org.apache.maven.plugins.annotations.LifecyclePhase; 32 | import org.apache.maven.plugins.annotations.Mojo; 33 | import org.apache.maven.plugins.annotations.Parameter; 34 | 35 | /** 36 | * Retrieve current host IP address and place it under a configurable project property 37 | * 38 | * @author Dan T. Tran 39 | * @since 1.8 40 | */ 41 | @Mojo(name = "local-ip", defaultPhase = LifecyclePhase.PROCESS_TEST_CLASSES, threadSafe = true) 42 | public class LocalIpMojo extends AbstractDefinePropertyMojo { 43 | 44 | /** 45 | * The name of the property in which to store the localhost ipaddress. 46 | */ 47 | @Parameter(defaultValue = "local.ip") 48 | private String localIpProperty; 49 | 50 | public void execute() throws MojoExecutionException { 51 | try { 52 | defineProperty(this.localIpProperty, InetAddress.getLocalHost().getHostAddress()); 53 | } catch (UnknownHostException e) { 54 | throw new MojoExecutionException("Unable to retrieve localhost address.", e); 55 | } 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /src/main/java/org/codehaus/mojo/buildhelper/RegexPropertiesMojo.java: -------------------------------------------------------------------------------- 1 | package org.codehaus.mojo.buildhelper; 2 | 3 | /* 4 | * The MIT License 5 | * 6 | * Copyright (c) 2004, The Codehaus 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy of 9 | * this software and associated documentation files (the "Software"), to deal in 10 | * the Software without restriction, including without limitation the rights to 11 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 12 | * of the Software, and to permit persons to whom the Software is furnished to do 13 | * so, subject to the following conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be included in all 16 | * copies or substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 24 | * SOFTWARE. 25 | */ 26 | 27 | import java.util.ArrayList; 28 | import java.util.List; 29 | 30 | import org.apache.maven.plugin.MojoExecutionException; 31 | import org.apache.maven.plugin.MojoFailureException; 32 | import org.apache.maven.plugins.annotations.LifecyclePhase; 33 | import org.apache.maven.plugins.annotations.Mojo; 34 | import org.apache.maven.plugins.annotations.Parameter; 35 | 36 | /** 37 | * Sets a property by applying a regex replacement rule to a supplied value. This is similar to regex-property goal with 38 | * support for multiple regex settings using RegexPropertyConfig 39 | * 40 | * @since 1.9 41 | */ 42 | @Mojo(name = "regex-properties", defaultPhase = LifecyclePhase.VALIDATE, threadSafe = true) 43 | public class RegexPropertiesMojo extends AbstractRegexPropertyMojo { 44 | /** 45 | * List of RegexPropertyConfig to apply the regex 46 | */ 47 | @Parameter(required = false) 48 | private List regexPropertySettings = new ArrayList(); 49 | 50 | public void execute() throws MojoExecutionException, MojoFailureException { 51 | 52 | for (RegexPropertySetting setting : regexPropertySettings) { 53 | this.execute(setting); 54 | } 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /src/it/released-version/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4.0.0 3 | 4 | org.codehaus.mojo 5 | build-helper-maven-plugin-released-version-it 6 | 1.0-SNAPSHOT 7 | build-helper-maven-plugin-released-version-it 8 | 9 | 10 | package 11 | 12 | 13 | @project.groupId@ 14 | @project.artifactId@ 15 | @project.version@ 16 | 17 | 18 | released-version 19 | 20 | released-version 21 | 22 | 23 | myReleasedVersion 24 | 25 | 26 | 27 | 28 | 29 | org.apache.maven.plugins 30 | maven-antrun-plugin 31 | @maven-antrun-plugin.version@ 32 | 33 | 34 | mk-target-dir 35 | compile 36 | 37 | run 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | echo-released-version 48 | test 49 | 50 | run 51 | 52 | 53 | 54 | myReleasedVersion.version=${myReleasedVersion.version} 55 | myReleasedVersion.majorVersion=${myReleasedVersion.majorVersion} 56 | myReleasedVersion.minorVersion=${myReleasedVersion.minorVersion} 57 | myReleasedVersion.incrementalVersion=${myReleasedVersion.incrementalVersion} 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | -------------------------------------------------------------------------------- /src/main/java/org/codehaus/mojo/buildhelper/CpuCountMojo.java: -------------------------------------------------------------------------------- 1 | package org.codehaus.mojo.buildhelper; 2 | 3 | /* 4 | * The MIT License 5 | * 6 | * Copyright (c) 2004, The Codehaus 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy of 9 | * this software and associated documentation files (the "Software"), to deal in 10 | * the Software without restriction, including without limitation the rights to 11 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 12 | * of the Software, and to permit persons to whom the Software is furnished to do 13 | * so, subject to the following conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be included in all 16 | * copies or substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 24 | * SOFTWARE. 25 | */ 26 | 27 | import org.apache.maven.plugin.MojoExecutionException; 28 | import org.apache.maven.plugins.annotations.LifecyclePhase; 29 | import org.apache.maven.plugins.annotations.Mojo; 30 | import org.apache.maven.plugins.annotations.Parameter; 31 | 32 | /** 33 | * Retrieve number of CPUs with project factor, and place it under a configurable project property 34 | * 35 | * @author Dan T. Tran 36 | * @since 1.9 37 | */ 38 | @Mojo(name = "cpu-count", defaultPhase = LifecyclePhase.INITIALIZE, threadSafe = true) 39 | public class CpuCountMojo extends AbstractDefinePropertyMojo { 40 | 41 | /** 42 | * The name of the property in which to store the CPU count. 43 | */ 44 | @Parameter(defaultValue = "cpu.count") 45 | private String cpuCount; 46 | 47 | /** 48 | * Projection factor. 49 | */ 50 | @Parameter(defaultValue = "1.0") 51 | private float factor; 52 | 53 | public void execute() throws MojoExecutionException { 54 | float count = Runtime.getRuntime().availableProcessors() * factor; 55 | if (count < 1) { 56 | count = 1; 57 | } 58 | 59 | defineProperty(this.cpuCount, Integer.toString((int) count)); 60 | this.getLog().info("CPU count: " + this.getProject().getProperties().getProperty(cpuCount)); 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /src/main/java/org/codehaus/mojo/buildhelper/MavenVersionMojo.java: -------------------------------------------------------------------------------- 1 | package org.codehaus.mojo.buildhelper; 2 | 3 | /* 4 | * The MIT License 5 | * 6 | * Copyright (c) 2004, The Codehaus 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy of 9 | * this software and associated documentation files (the "Software"), to deal in 10 | * the Software without restriction, including without limitation the rights to 11 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 12 | * of the Software, and to permit persons to whom the Software is furnished to do 13 | * so, subject to the following conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be included in all 16 | * copies or substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 24 | * SOFTWARE. 25 | */ 26 | 27 | import org.apache.maven.plugins.annotations.Component; 28 | import org.apache.maven.plugins.annotations.LifecyclePhase; 29 | import org.apache.maven.plugins.annotations.Mojo; 30 | import org.apache.maven.plugins.annotations.Parameter; 31 | import org.apache.maven.rtinfo.RuntimeInformation; 32 | 33 | /** 34 | * Store the maven core version in a property maven.version. 35 | * 36 | * @author pgier 37 | * @since 1.3 38 | * @deprecated Maven since version {@code 3.0.4} has such property build in: 39 | * MNG-4112. 40 | * So goal can be removed. 41 | */ 42 | @Deprecated 43 | @Mojo(name = "maven-version", defaultPhase = LifecyclePhase.VALIDATE, threadSafe = true) 44 | public class MavenVersionMojo extends AbstractDefinePropertyMojo { 45 | 46 | /** 47 | * The RuntimeInforamtion for the current instance of Maven. 48 | */ 49 | @Component 50 | private RuntimeInformation runtime; 51 | 52 | /** 53 | * The name of the property in which to store the version of Maven. 54 | */ 55 | @Parameter(defaultValue = "maven.version") 56 | private String versionProperty; 57 | 58 | /** 59 | * Main plugin execution 60 | */ 61 | public void execute() { 62 | defineProperty(versionProperty, runtime.getMavenVersion()); 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /src/it/uptodate-multi-negative/fixture.properties: -------------------------------------------------------------------------------- 1 | src/main/resources/source/dirA/fileAA.s = 1 2 | src/main/resources/source/dirA/fileAB.s = 2 3 | src/main/resources/source/dirA/fileAX.s = 3 4 | src/main/resources/source/dirB/fileBA.s = 4 5 | src/main/resources/source/dirB/fileBB.s = 5 6 | src/main/resources/source/dirB/fileBX.s = 6 7 | src/main/resources/source/dirY/fileYA.s = 7 8 | src/main/resources/source/dirY/fileYB.s = 8 9 | src/main/resources/source/dirY/fileYX.s = 9 10 | 11 | src/main/resources/source/unpackage/dirA.fileAA.s = 1 12 | src/main/resources/source/unpackage/dirA.fileAB.s = 2 13 | src/main/resources/source/unpackage/dirA.fileAX.s = 3 14 | src/main/resources/source/unpackage/dirB.fileBA.s = 4 15 | src/main/resources/source/unpackage/dirB.fileBB.s = 5 16 | src/main/resources/source/unpackage/dirB.fileBX.s = 6 17 | src/main/resources/source/unpackage/dirY.fileYA.s = 7 18 | src/main/resources/source/unpackage/dirY.fileYB.s = 8 19 | src/main/resources/source/unpackage/dirY.fileYX.s = 9 20 | 21 | # The flatten, glob, identity and merge negative tests should fail because certain target files are older than source files. 22 | 23 | src/main/resources/target/flatten/fileAA.s = 1 24 | src/main/resources/target/flatten/fileAB.s = 1 25 | src/main/resources/target/flatten/fileAX.s = 0 26 | src/main/resources/target/flatten/fileBA.s = 3 27 | src/main/resources/target/flatten/fileBB.s = 6 28 | 29 | src/main/resources/target/glob/dirA/fileAA.t = 1 30 | src/main/resources/target/glob/dirA/fileAB.t = 1 31 | src/main/resources/target/glob/dirA/fileAX.t = 0 32 | src/main/resources/target/glob/dirB/fileBA.t = 3 33 | src/main/resources/target/glob/dirB/fileBB.t = 6 34 | 35 | src/main/resources/target/identity/dirA/fileAA.s = 1 36 | src/main/resources/target/identity/dirA/fileAB.s = 1 37 | src/main/resources/target/identity/dirA/fileAX.s = 0 38 | src/main/resources/target/identity/dirB/fileBA.s = 3 39 | src/main/resources/target/identity/dirB/fileBB.s = 6 40 | 41 | src/main/resources/target/merge/todir/outfile.t = 3 42 | 43 | # The package and unpackage negative tests should fail because certain target files are missing. 44 | 45 | #src/main/resources/target/package/dirA.fileAA.t = 1 46 | src/main/resources/target/package/dirA.fileAB.t = 3 47 | src/main/resources/target/package/dirA.fileAX.t = 0 48 | src/main/resources/target/package/dirB.fileBA.t = 5 49 | src/main/resources/target/package/dirB.fileBB.t = 6 50 | 51 | src/main/resources/target/unpackage/dirA/fileAA.t = 1 52 | src/main/resources/target/unpackage/dirA/fileAB.t = 2 53 | src/main/resources/target/unpackage/dirA/fileAX.t = 0 54 | #src/main/resources/target/unpackage/dirB/fileBA.t = 5 55 | src/main/resources/target/unpackage/dirB/fileBB.t = 6 -------------------------------------------------------------------------------- /src/it/released-version-existing-asset/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4.0.0 3 | 4 | 7 | org.apache.continuum 8 | continuum 9 | 1.0-SNAPSHOT 10 | build-helper-maven-plugin-released-version-it-mojo-parent 11 | 12 | 13 | package 14 | 15 | 16 | @project.groupId@ 17 | @project.artifactId@ 18 | @project.version@ 19 | 20 | 21 | released-version 22 | 23 | released-version 24 | 25 | 26 | myReleasedVersion 27 | 28 | 29 | 30 | 31 | 32 | org.apache.maven.plugins 33 | maven-antrun-plugin 34 | @maven-antrun-plugin.version@ 35 | 36 | 37 | mk-target-dir 38 | compile 39 | 40 | run 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | echo-released-version 51 | test 52 | 53 | run 54 | 55 | 56 | 57 | myReleasedVersion.version=${myReleasedVersion.version} 58 | myReleasedVersion.majorVersion=${myReleasedVersion.majorVersion} 59 | myReleasedVersion.minorVersion=${myReleasedVersion.minorVersion} 60 | myReleasedVersion.incrementalVersion=${myReleasedVersion.incrementalVersion} 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | -------------------------------------------------------------------------------- /src/main/java/org/codehaus/mojo/buildhelper/AddResourceMojo.java: -------------------------------------------------------------------------------- 1 | package org.codehaus.mojo.buildhelper; 2 | 3 | /* 4 | * The MIT License 5 | * 6 | * Copyright (c) 2004, The Codehaus 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy of 9 | * this software and associated documentation files (the "Software"), to deal in 10 | * the Software without restriction, including without limitation the rights to 11 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 12 | * of the Software, and to permit persons to whom the Software is furnished to do 13 | * so, subject to the following conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be included in all 16 | * copies or substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 24 | * SOFTWARE. 25 | */ 26 | 27 | import org.apache.maven.model.Resource; 28 | import org.apache.maven.plugins.annotations.LifecyclePhase; 29 | import org.apache.maven.plugins.annotations.Mojo; 30 | import org.apache.maven.plugins.annotations.Parameter; 31 | 32 | /** 33 | * Add more resource directories to the POM. 34 | * 35 | * @author Paul Gier 36 | * @since 1.3 37 | */ 38 | @Mojo(name = "add-resource", defaultPhase = LifecyclePhase.GENERATE_RESOURCES, threadSafe = true) 39 | public class AddResourceMojo extends AbstractAddResourceMojo { 40 | 41 | /** 42 | * Skip plugin execution. 43 | * 44 | * @since 3.5.0 45 | */ 46 | @Parameter(property = "buildhelper.addresource.skip", defaultValue = "false") 47 | private boolean skipAddResource; 48 | 49 | /** 50 | * If a resource directory does not exist, do not add it as a root. 51 | * 52 | * @since 3.5.0 53 | */ 54 | @Parameter(property = "buildhelper.addresource.skipIfMissing", defaultValue = "false") 55 | private boolean skipAddResourceIfMissing; 56 | 57 | public void addResource(Resource resource) { 58 | getProject().addResource(resource); 59 | if (getLog().isDebugEnabled()) { 60 | getLog().debug("Added resource: " + resource.getDirectory()); 61 | } 62 | } 63 | 64 | protected boolean isSkipIfMissing() { 65 | return skipAddResourceIfMissing; 66 | } 67 | 68 | protected boolean isSkip() { 69 | return skipAddResource; 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /src/it/surefire/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | 5 | org.codehaus.mojo 6 | test-reserve-port-with-surefire 7 | 1.0-SNAPSHOT 8 | 9 | test-reserve-port-with-surefire 10 | 11 | 12 | 13 | junit 14 | junit 15 | 4.13.1 16 | test 17 | 18 | 19 | 20 | 21 | 22 | package 23 | 24 | 25 | 26 | 27 | org.apache.maven.plugins 28 | maven-compiler-plugin 29 | @maven-compiler-plugin.version@ 30 | 31 | 1.8 32 | 1.8 33 | 34 | 35 | 36 | 37 | 38 | 39 | @project.groupId@ 40 | @project.artifactId@ 41 | @project.version@ 42 | 43 | 44 | reserve-ports 45 | process-test-resources 46 | 47 | reserve-network-port 48 | 49 | 50 | 51 | port1 52 | port2 53 | port3 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | maven-surefire-plugin 62 | @maven-surefire-plugin.version@ 63 | 64 | 65 | 66 | port1 67 | ${port1} 68 | 69 | 70 | 71 | ${port1} 72 | ${project.build.directory} 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 86 | 87 | 88 | 89 | -------------------------------------------------------------------------------- /src/it/reserve-ports-with-random/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | 5 | org.codehaus.mojo 6 | build-helper-maven-plugin-reverse-port-it 7 | 1.0-SNAPSHOT 8 | 9 | build-helper-maven-plugin-reverse-port-it 10 | 11 | 12 | 13 | 14 | package 15 | 16 | 17 | 18 | 19 | 20 | 21 | @project.groupId@ 22 | @project.artifactId@ 23 | @project.version@ 24 | 25 | 26 | 27 | reserve-ports 28 | process-test-resources 29 | 30 | reserve-network-port 31 | 32 | 33 | 34 | port1 35 | port2 36 | port3 37 | 38 | 9000 39 | 9005 40 | true 41 | 42 | 43 | 44 | 45 | 46 | 47 | org.apache.maven.plugins 48 | maven-antrun-plugin 49 | @maven-antrun-plugin.version@ 50 | 51 | 52 | mk-target-dir 53 | compile 54 | 55 | run 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | echo-reserve-ports 66 | test 67 | 68 | run 69 | 70 | 71 | 72 | port1=${port1} 73 | port2=${port2} 74 | port3=${port3} 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 93 | 94 | -------------------------------------------------------------------------------- /src/it/reserve-ports-with-sequence/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | 5 | org.codehaus.mojo 6 | build-helper-maven-plugin-reverse-port-it 7 | 1.0-SNAPSHOT 8 | 9 | build-helper-maven-plugin-reverse-port-it 10 | 11 | 12 | 13 | 14 | package 15 | 16 | 17 | 18 | 19 | 20 | 21 | @project.groupId@ 22 | @project.artifactId@ 23 | @project.version@ 24 | 25 | 26 | 27 | reserve-ports 28 | process-test-resources 29 | 30 | reserve-network-port 31 | 32 | 33 | 34 | port1 35 | port2 36 | port3 37 | 38 | 9000 39 | 9005 40 | false 41 | 42 | 43 | 44 | 45 | 46 | 47 | org.apache.maven.plugins 48 | maven-antrun-plugin 49 | @maven-antrun-plugin.version@ 50 | 51 | 52 | mk-target-dir 53 | compile 54 | 55 | run 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | echo-reserve-ports 66 | test 67 | 68 | run 69 | 70 | 71 | 72 | port1=${port1} 73 | port2=${port2} 74 | port3=${port3} 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 93 | 94 | -------------------------------------------------------------------------------- /src/it/released-version-existing-asset-issue-108/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4.0.0 3 | 4 | 9 | org.apache.continuum 10 | continuum 11 | 1.0-SNAPSHOT 12 | build-helper-maven-plugin-released-version-it 13 | 14 | 15 | package 16 | 17 | 18 | @project.groupId@ 19 | @project.artifactId@ 20 | @project.version@ 21 | 22 | 23 | released-version 24 | 25 | released-version 26 | 27 | 28 | myReleasedVersion 29 | 30 | 31 | 32 | 33 | 34 | org.apache.maven.plugins 35 | maven-antrun-plugin 36 | @maven-antrun-plugin.version@ 37 | 38 | 39 | mk-target-dir 40 | compile 41 | 42 | run 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | echo-released-version 53 | test 54 | 55 | run 56 | 57 | 58 | 59 | myReleasedVersion.version=${myReleasedVersion.version} 60 | myReleasedVersion.majorVersion=${myReleasedVersion.majorVersion} 61 | myReleasedVersion.minorVersion=${myReleasedVersion.minorVersion} 62 | myReleasedVersion.incrementalVersion=${myReleasedVersion.incrementalVersion} 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | -------------------------------------------------------------------------------- /src/main/java/org/codehaus/mojo/buildhelper/AddTestResourceMojo.java: -------------------------------------------------------------------------------- 1 | package org.codehaus.mojo.buildhelper; 2 | 3 | /* 4 | * The MIT License 5 | * 6 | * Copyright (c) 2004, The Codehaus 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy of 9 | * this software and associated documentation files (the "Software"), to deal in 10 | * the Software without restriction, including without limitation the rights to 11 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 12 | * of the Software, and to permit persons to whom the Software is furnished to do 13 | * so, subject to the following conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be included in all 16 | * copies or substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 24 | * SOFTWARE. 25 | */ 26 | 27 | import org.apache.maven.model.Resource; 28 | import org.apache.maven.plugins.annotations.LifecyclePhase; 29 | import org.apache.maven.plugins.annotations.Mojo; 30 | import org.apache.maven.plugins.annotations.Parameter; 31 | 32 | /** 33 | * Add more test resource directories to the POM. 34 | * 35 | * @author Paul Gier 36 | * @since 1.3 37 | */ 38 | @Mojo(name = "add-test-resource", defaultPhase = LifecyclePhase.GENERATE_TEST_RESOURCES, threadSafe = true) 39 | public class AddTestResourceMojo extends AbstractAddResourceMojo { 40 | 41 | /** 42 | * Skip plugin execution. 43 | * 44 | * @since 3.5.0 45 | */ 46 | @Parameter(property = "buildhelper.addtestresource.skip", defaultValue = "false") 47 | private boolean skipAddTestResource; 48 | 49 | /** 50 | * If a test resource directory does not exist, do not add it as a root. 51 | * 52 | * @since 3.5.0 53 | */ 54 | @Parameter(property = "buildhelper.addtestresource.skipIfMissing", defaultValue = "false") 55 | private boolean skipAddTestResourceIfMissing; 56 | 57 | /** 58 | * Add the resource to the project. 59 | * 60 | * @param resource the resource to add 61 | */ 62 | public void addResource(Resource resource) { 63 | getProject().addTestResource(resource); 64 | if (getLog().isDebugEnabled()) { 65 | getLog().debug("Added test resource: " + resource.getDirectory()); 66 | } 67 | } 68 | 69 | @Override 70 | protected boolean isSkip() { 71 | return skipAddTestResource; 72 | } 73 | 74 | protected boolean isSkipIfMissing() { 75 | return skipAddTestResourceIfMissing; 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /src/main/java/org/codehaus/mojo/buildhelper/UpToDatePropertiesMojo.java: -------------------------------------------------------------------------------- 1 | package org.codehaus.mojo.buildhelper; 2 | 3 | /* 4 | * The MIT License 5 | * 6 | * Copyright (c) 2004, The Codehaus 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy of 9 | * this software and associated documentation files (the "Software"), to deal in 10 | * the Software without restriction, including without limitation the rights to 11 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 12 | * of the Software, and to permit persons to whom the Software is furnished to do 13 | * so, subject to the following conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be included in all 16 | * copies or substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 24 | * SOFTWARE. 25 | */ 26 | 27 | import java.util.List; 28 | 29 | import org.apache.maven.plugin.MojoExecutionException; 30 | import org.apache.maven.plugin.MojoFailureException; 31 | import org.apache.maven.plugins.annotations.LifecyclePhase; 32 | import org.apache.maven.plugins.annotations.Mojo; 33 | import org.apache.maven.plugins.annotations.Parameter; 34 | 35 | /** 36 | * Sets multiple properties according to whether multiple sets of source and target resources are respectively up to 37 | * date. 38 | * 39 | * @author Adrian Price demonfiddler@virginmedia.com 40 | * @since 1.12 41 | */ 42 | @Mojo(name = "uptodate-properties", defaultPhase = LifecyclePhase.VALIDATE, threadSafe = true) 43 | public class UpToDatePropertiesMojo extends AbstractUpToDatePropertyMojo { 44 | /** 45 | * List of UpToDatePropertySettings to apply. 46 | */ 47 | @Parameter(required = false) 48 | private List upToDatePropertySettings; 49 | 50 | /** 51 | * Disables the plug-in execution. 52 | */ 53 | @Parameter(property = "buildhelper.uptodateproperties.skip", defaultValue = "false") 54 | private boolean skip; 55 | 56 | /** {@inheritDoc} */ 57 | @Override 58 | public void execute() throws MojoExecutionException, MojoFailureException { 59 | if (skip) { 60 | getLog().info("uptodate-properties is skipped."); 61 | return; 62 | } 63 | 64 | if (upToDatePropertySettings != null) { 65 | for (UpToDatePropertySetting config : upToDatePropertySettings) { 66 | this.execute(config); 67 | } 68 | } 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /src/it/reserve-ports-with-min-root-range/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | 5 | org.codehaus.mojo 6 | build-helper-maven-plugin-reverse-port-it 7 | 1.0-SNAPSHOT 8 | 9 | build-helper-maven-plugin-reverse-port-it 10 | 11 | 12 | 13 | 14 | package 15 | 16 | 17 | 18 | 19 | 20 | 21 | @project.groupId@ 22 | @project.artifactId@ 23 | @project.version@ 24 | 25 | 26 | 27 | reserve-ports 28 | process-test-resources 29 | 30 | reserve-network-port 31 | 32 | 33 | 34 | port1 35 | port2 36 | port3 37 | 38 | 39 | 10000 40 | 41 | 42 | 43 | 44 | 45 | 46 | org.apache.maven.plugins 47 | maven-antrun-plugin 48 | @maven-antrun-plugin.version@ 49 | 50 | 51 | mk-target-dir 52 | compile 53 | 54 | run 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | echo-reserve-ports 65 | test 66 | 67 | run 68 | 69 | 70 | 71 | port1=${port1} 72 | port2=${port2} 73 | port3=${port3} 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 92 | 93 | -------------------------------------------------------------------------------- /src/it/reserve-ports-with-urls/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4.0.0 3 | 4 | org.codehaus.mojo 5 | build-helper-maven-plugin-reverse-port-it 6 | 1.0-SNAPSHOT 7 | build-helper-maven-plugin-reverse-port-it 8 | 9 | 10 | package 11 | 12 | 13 | @project.groupId@ 14 | @project.artifactId@ 15 | @project.version@ 16 | 17 | 18 | reserve-ports 19 | process-test-resources 20 | 21 | reserve-network-port 22 | 23 | 24 | 25 | file:///${project.basedir}/names2.txt 26 | 27 | 28 | 29 | 30 | reserve-ports-to-files 31 | process-test-resources 32 | 33 | reserve-network-port 34 | 35 | 36 | ${project.build.directory}/ports.properties 37 | 38 | file:///${project.basedir}/names1.txt 39 | file:///${project.basedir}/names2.txt 40 | 41 | 42 | 43 | 44 | 45 | 46 | org.apache.maven.plugins 47 | maven-antrun-plugin 48 | @maven-antrun-plugin.version@ 49 | 50 | 51 | mk-target-dir 52 | compile 53 | 54 | run 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | echo-reserve-ports 65 | test 66 | 67 | run 68 | 69 | 70 | 71 | port1=${port1} 72 | port2=${port2} 73 | port3=${port3} 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | -------------------------------------------------------------------------------- /src/main/java/org/codehaus/mojo/buildhelper/Artifact.java: -------------------------------------------------------------------------------- 1 | package org.codehaus.mojo.buildhelper; 2 | 3 | /* 4 | * The MIT License 5 | * 6 | * Copyright (c) 2004, The Codehaus 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy of 9 | * this software and associated documentation files (the "Software"), to deal in 10 | * the Software without restriction, including without limitation the rights to 11 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 12 | * of the Software, and to permit persons to whom the Software is furnished to do 13 | * so, subject to the following conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be included in all 16 | * copies or substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 24 | * SOFTWARE. 25 | */ 26 | 27 | import java.io.File; 28 | 29 | /** 30 | *

31 | * Artifact class. 32 | *

33 | * 34 | * @author dtran 35 | */ 36 | public class Artifact { 37 | private File file; 38 | 39 | private String type = "jar"; 40 | 41 | private String classifier; 42 | 43 | /** 44 | *

45 | * Setter for the field file. 46 | *

47 | * 48 | * @param localFile a {@link java.io.File} object. 49 | */ 50 | public void setFile(File localFile) { 51 | this.file = localFile; 52 | } 53 | 54 | /** 55 | *

56 | * Getter for the field file. 57 | *

58 | * 59 | * @return a {@link java.io.File} object. 60 | */ 61 | public File getFile() { 62 | return this.file; 63 | } 64 | 65 | /** 66 | *

67 | * Setter for the field type. 68 | *

69 | * 70 | * @param type a {@link java.lang.String} object. 71 | */ 72 | public void setType(String type) { 73 | this.type = type; 74 | } 75 | 76 | /** 77 | *

78 | * Getter for the field type. 79 | *

80 | * 81 | * @return a {@link java.lang.String} object. 82 | */ 83 | public String getType() { 84 | return this.type; 85 | } 86 | 87 | /** 88 | *

89 | * Setter for the field classifier. 90 | *

91 | * 92 | * @param classifier a {@link java.lang.String} object. 93 | */ 94 | public void setClassifier(String classifier) { 95 | this.classifier = classifier; 96 | } 97 | 98 | /** 99 | *

100 | * Getter for the field classifier. 101 | *

102 | * 103 | * @return a {@link java.lang.String} object. 104 | */ 105 | public String getClassifier() { 106 | return this.classifier; 107 | } 108 | } 109 | -------------------------------------------------------------------------------- /src/main/java/org/codehaus/mojo/buildhelper/UpToDatePropertyMojo.java: -------------------------------------------------------------------------------- 1 | package org.codehaus.mojo.buildhelper; 2 | 3 | /* 4 | * The MIT License 5 | * 6 | * Copyright (c) 2004, The Codehaus 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy of 9 | * this software and associated documentation files (the "Software"), to deal in 10 | * the Software without restriction, including without limitation the rights to 11 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 12 | * of the Software, and to permit persons to whom the Software is furnished to do 13 | * so, subject to the following conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be included in all 16 | * copies or substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 24 | * SOFTWARE. 25 | */ 26 | 27 | import org.apache.maven.plugin.MojoExecutionException; 28 | import org.apache.maven.plugin.MojoFailureException; 29 | import org.apache.maven.plugins.annotations.LifecyclePhase; 30 | import org.apache.maven.plugins.annotations.Mojo; 31 | import org.apache.maven.plugins.annotations.Parameter; 32 | import org.apache.maven.shared.model.fileset.FileSet; 33 | 34 | /** 35 | * Sets a property according to whether one set of resources is up to date with respect to another. 36 | * 37 | * @author Adrian Price demonfiddler@virginmedia.com 38 | * @since 1.12 39 | */ 40 | @Mojo(name = "uptodate-property", defaultPhase = LifecyclePhase.VALIDATE, threadSafe = true) 41 | public class UpToDatePropertyMojo extends AbstractUpToDatePropertyMojo { 42 | /** 43 | * The name of the property to set. 44 | */ 45 | @Parameter(required = true) 46 | private String name; 47 | 48 | /** 49 | * Disables the plug-in execution. 50 | */ 51 | @Parameter(property = "buildhelper.uptodateproperty.skip", defaultValue = "false") 52 | private boolean skip; 53 | 54 | /** 55 | * The file set to check. 56 | */ 57 | @Parameter(required = true) 58 | private FileSet fileSet; 59 | 60 | /** 61 | * The property value to set if the up-to-date condition is fulfilled. 62 | */ 63 | @Parameter(defaultValue = "true") 64 | private String value; 65 | 66 | /** 67 | * The property value to set if the up-to-date condition is not fulfilled. 68 | */ 69 | @Parameter(alias = "else") 70 | private String elseValue; 71 | 72 | /** {@inheritDoc} */ 73 | @Override 74 | public void execute() throws MojoExecutionException, MojoFailureException { 75 | if (skip) { 76 | getLog().info("uptodate-property is skipped."); 77 | return; 78 | } 79 | 80 | UpToDatePropertySetting config = new UpToDatePropertySetting(); 81 | config.setName(name); 82 | config.setValue(value); 83 | config.setElse(elseValue); 84 | config.setFileSet(fileSet); 85 | execute(config); 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /src/it/reserve-ports/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | 5 | org.codehaus.mojo 6 | build-helper-maven-plugin-reverse-port-it 7 | 1.0-SNAPSHOT 8 | 9 | build-helper-maven-plugin-reverse-port-it 10 | 11 | 12 | 13 | 14 | package 15 | 16 | 17 | 18 | 19 | 20 | 21 | @project.groupId@ 22 | @project.artifactId@ 23 | @project.version@ 24 | 25 | 26 | 27 | reserve-ports 28 | process-test-resources 29 | 30 | reserve-network-port 31 | 32 | 33 | 34 | port1 35 | port2 36 | port3 37 | 38 | 39 | 40 | 41 | reserve-ports-to-files 42 | process-test-resources 43 | 44 | reserve-network-port 45 | 46 | 47 | ${project.build.directory}/ports.properties 48 | 49 | port3 50 | port4 51 | port5 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | org.apache.maven.plugins 60 | maven-antrun-plugin 61 | @maven-antrun-plugin.version@ 62 | 63 | 64 | mk-target-dir 65 | compile 66 | 67 | run 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | echo-reserve-ports 78 | test 79 | 80 | run 81 | 82 | 83 | 84 | port1=${port1} 85 | port2=${port2} 86 | port3=${port3} 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 105 | 106 | -------------------------------------------------------------------------------- /src/main/java/org/codehaus/mojo/buildhelper/AddSourceMojo.java: -------------------------------------------------------------------------------- 1 | package org.codehaus.mojo.buildhelper; 2 | 3 | /* 4 | * The MIT License 5 | * 6 | * Copyright (c) 2004, The Codehaus 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy of 9 | * this software and associated documentation files (the "Software"), to deal in 10 | * the Software without restriction, including without limitation the rights to 11 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 12 | * of the Software, and to permit persons to whom the Software is furnished to do 13 | * so, subject to the following conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be included in all 16 | * copies or substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 24 | * SOFTWARE. 25 | */ 26 | 27 | import java.io.File; 28 | 29 | import org.apache.maven.plugin.AbstractMojo; 30 | import org.apache.maven.plugins.annotations.LifecyclePhase; 31 | import org.apache.maven.plugins.annotations.Mojo; 32 | import org.apache.maven.plugins.annotations.Parameter; 33 | import org.apache.maven.project.MavenProject; 34 | 35 | /** 36 | * Add more source directories to the POM. 37 | * 38 | * @author Dan T. Tran 39 | * @since 1.0 40 | */ 41 | @Mojo(name = "add-source", defaultPhase = LifecyclePhase.GENERATE_SOURCES, threadSafe = true) 42 | public class AddSourceMojo extends AbstractMojo { 43 | /** 44 | * Additional source directories. 45 | * 46 | * @since 1.0 47 | */ 48 | @Parameter(property = "sources", required = true) 49 | private File[] sources; 50 | 51 | /** 52 | * @since 1.0 53 | */ 54 | @Parameter(readonly = true, defaultValue = "${project}") 55 | private MavenProject project; 56 | 57 | /** 58 | * Skip plugin execution. 59 | * 60 | * @since 3.5.0 61 | */ 62 | @Parameter(property = "buildhelper.addsource.skip", defaultValue = "false") 63 | private boolean skipAddSource; 64 | 65 | /** 66 | * If a directory does not exist, do not add it as a source root. 67 | * 68 | * @since 3.5.0 69 | */ 70 | @Parameter(property = "buildhelper.addsource.skipIfMissing", defaultValue = "false") 71 | private boolean skipAddSourceIfMissing; 72 | 73 | public void execute() { 74 | if (skipAddSource) { 75 | if (getLog().isInfoEnabled()) { 76 | getLog().info("Skipping plugin execution!"); 77 | } 78 | return; 79 | } 80 | 81 | for (File source : sources) { 82 | if (skipAddSourceIfMissing && !source.exists()) { 83 | if (getLog().isDebugEnabled()) { 84 | getLog().debug("Skipping directory: " + source + ", because it does not exist."); 85 | } 86 | } else { 87 | this.project.addCompileSourceRoot(source.getAbsolutePath()); 88 | if (getLog().isInfoEnabled()) { 89 | getLog().info("Source directory: " + source + " added."); 90 | } 91 | } 92 | } 93 | } 94 | } 95 | -------------------------------------------------------------------------------- /src/main/java/org/codehaus/mojo/buildhelper/AbstractRegexPropertyMojo.java: -------------------------------------------------------------------------------- 1 | package org.codehaus.mojo.buildhelper; 2 | 3 | /* 4 | * The MIT License 5 | * 6 | * Copyright (c) 2004, The Codehaus 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy of 9 | * this software and associated documentation files (the "Software"), to deal in 10 | * the Software without restriction, including without limitation the rights to 11 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 12 | * of the Software, and to permit persons to whom the Software is furnished to do 13 | * so, subject to the following conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be included in all 16 | * copies or substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 24 | * SOFTWARE. 25 | */ 26 | 27 | import java.util.Locale; 28 | import java.util.regex.Matcher; 29 | import java.util.regex.Pattern; 30 | import java.util.regex.PatternSyntaxException; 31 | 32 | import org.apache.maven.plugin.MojoExecutionException; 33 | import org.apache.maven.plugin.MojoFailureException; 34 | import org.codehaus.plexus.util.StringUtils; 35 | 36 | public abstract class AbstractRegexPropertyMojo extends AbstractDefinePropertyMojo { 37 | 38 | protected void execute(RegexPropertySetting config) throws MojoExecutionException, MojoFailureException { 39 | try { 40 | config.validate(); 41 | } catch (IllegalArgumentException e) { 42 | throw new MojoExecutionException(e.getMessage(), e); 43 | } 44 | 45 | Pattern pattern; 46 | try { 47 | pattern = Pattern.compile(config.getRegex()); 48 | } catch (PatternSyntaxException e) { 49 | throw new MojoExecutionException(e.getMessage(), e); 50 | } 51 | Matcher matcher = pattern.matcher(config.getValue()); 52 | 53 | if (matcher.find()) { 54 | // if the string replacement is empty, we define the value replacement to empty. 55 | config.setValue( 56 | (StringUtils.isNotEmpty(config.getReplacement()) 57 | ? matcher.replaceAll(config.getReplacement()) 58 | : matcher.replaceAll(""))); 59 | } else { 60 | if (config.isFailIfNoMatch()) { 61 | throw new MojoFailureException( 62 | "No match to regex '" + config.getRegex() + "' found in '" + config.getValue() + "'."); 63 | } else { 64 | getLog().info("No match to regex '" + config.getRegex() + "' found in '" + config.getValue() + "'. " 65 | + "The initial value '" + config.getValue() + "' is left as-is..."); 66 | } 67 | } 68 | 69 | if (config.isToLowerCase()) { 70 | config.setValue(config.getValue().toLowerCase(Locale.getDefault())); 71 | } 72 | 73 | if (config.isToUpperCase()) { 74 | config.setValue(config.getValue().toUpperCase(Locale.getDefault())); 75 | } 76 | 77 | defineProperty(config.getName(), config.getValue()); 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /src/main/java/org/codehaus/mojo/buildhelper/AddTestSourceMojo.java: -------------------------------------------------------------------------------- 1 | package org.codehaus.mojo.buildhelper; 2 | 3 | /* 4 | * The MIT License 5 | * 6 | * Copyright (c) 2004, The Codehaus 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy of 9 | * this software and associated documentation files (the "Software"), to deal in 10 | * the Software without restriction, including without limitation the rights to 11 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 12 | * of the Software, and to permit persons to whom the Software is furnished to do 13 | * so, subject to the following conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be included in all 16 | * copies or substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 24 | * SOFTWARE. 25 | */ 26 | 27 | import java.io.File; 28 | 29 | import org.apache.maven.plugin.AbstractMojo; 30 | import org.apache.maven.plugins.annotations.LifecyclePhase; 31 | import org.apache.maven.plugins.annotations.Mojo; 32 | import org.apache.maven.plugins.annotations.Parameter; 33 | import org.apache.maven.project.MavenProject; 34 | 35 | /** 36 | * Add test source directories to the POM. 37 | * 38 | * @author Dan T. Tran 39 | * @since 1.0 40 | */ 41 | @Mojo(name = "add-test-source", defaultPhase = LifecyclePhase.GENERATE_TEST_SOURCES, threadSafe = true) 42 | public class AddTestSourceMojo extends AbstractMojo { 43 | 44 | /** 45 | * Additional test source directories. 46 | * 47 | * @since 1.0 48 | */ 49 | @Parameter(required = true) 50 | private File[] sources; 51 | 52 | /** 53 | * @since 1.0 54 | */ 55 | @Parameter(readonly = true, defaultValue = "${project}") 56 | private MavenProject project; 57 | 58 | /** 59 | * Skip plugin execution. 60 | * 61 | * @since 3.5.0 62 | */ 63 | @Parameter(property = "buildhelper.addtestsource.skip", defaultValue = "false") 64 | private boolean skipAddTestSource; 65 | 66 | /** 67 | * If a directory does not exist, do not add it as a test source root. 68 | * 69 | * @since 3.5.0 70 | */ 71 | @Parameter(property = "buildhelper.addtestsource.skipIfMissing", defaultValue = "false") 72 | private boolean skipAddTestSourceIfMissing; 73 | 74 | public void execute() { 75 | if (skipAddTestSource) { 76 | if (getLog().isInfoEnabled()) { 77 | getLog().info("Skipping plugin execution!"); 78 | } 79 | return; 80 | } 81 | 82 | for (File source : sources) { 83 | if (skipAddTestSourceIfMissing && !source.exists()) { 84 | if (getLog().isDebugEnabled()) { 85 | getLog().debug("Skipping directory: " + source + ", because it does not exist."); 86 | } 87 | } else { 88 | this.project.addTestCompileSourceRoot(source.getAbsolutePath()); 89 | if (getLog().isInfoEnabled()) { 90 | getLog().info("Test Source directory: " + source + " added."); 91 | } 92 | } 93 | } 94 | } 95 | } 96 | -------------------------------------------------------------------------------- /src/main/java/org/codehaus/mojo/buildhelper/RegexPropertyMojo.java: -------------------------------------------------------------------------------- 1 | package org.codehaus.mojo.buildhelper; 2 | 3 | /* 4 | * The MIT License 5 | * 6 | * Copyright (c) 2004, The Codehaus 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy of 9 | * this software and associated documentation files (the "Software"), to deal in 10 | * the Software without restriction, including without limitation the rights to 11 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 12 | * of the Software, and to permit persons to whom the Software is furnished to do 13 | * so, subject to the following conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be included in all 16 | * copies or substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 24 | * SOFTWARE. 25 | */ 26 | 27 | import org.apache.maven.plugin.MojoExecutionException; 28 | import org.apache.maven.plugin.MojoFailureException; 29 | import org.apache.maven.plugins.annotations.LifecyclePhase; 30 | import org.apache.maven.plugins.annotations.Mojo; 31 | import org.apache.maven.plugins.annotations.Parameter; 32 | 33 | /** 34 | * Sets a property by applying a regex replacement rule to a supplied value. 35 | * 36 | * @author Stephen Connolly 37 | * @since 1.7 38 | */ 39 | @Mojo(name = "regex-property", defaultPhase = LifecyclePhase.VALIDATE, threadSafe = true) 40 | public class RegexPropertyMojo extends AbstractRegexPropertyMojo { 41 | /** 42 | * The property to set. 43 | */ 44 | @Parameter(required = true) 45 | private String name; 46 | 47 | /** 48 | * The pre-transformation value. 49 | */ 50 | @Parameter(required = true) 51 | private String value; 52 | 53 | /** 54 | * The regex to replace. 55 | */ 56 | @Parameter(required = true) 57 | private String regex; 58 | 59 | /** 60 | * The replacement. 61 | */ 62 | @Parameter(defaultValue = "") 63 | private String replacement; 64 | 65 | /** 66 | * Whether to fail if no match is found. 67 | */ 68 | @Parameter(defaultValue = "true") 69 | private boolean failIfNoMatch; 70 | 71 | /** 72 | * Make the value of the resulting property upper case. 73 | * 74 | * @since 1.11 75 | */ 76 | @Parameter(defaultValue = "false") 77 | private boolean toUpperCase; 78 | 79 | /** 80 | * Make the value of the resulting property lower case. 81 | * 82 | * @since 1.11 83 | */ 84 | @Parameter(defaultValue = "false") 85 | private boolean toLowerCase; 86 | 87 | /** 88 | * {@inheritDoc} 89 | */ 90 | public void execute() throws MojoExecutionException, MojoFailureException { 91 | RegexPropertySetting config = new RegexPropertySetting(); 92 | config.setName(name); 93 | config.setValue(value); 94 | config.setRegex(regex); 95 | config.setReplacement(replacement); 96 | config.setFailIfNoMatch(failIfNoMatch); 97 | config.setToLowerCase(toLowerCase); 98 | config.setToUpperCase(toUpperCase); 99 | 100 | this.execute(config); 101 | } 102 | } 103 | --------------------------------------------------------------------------------