diff --git a/maven-modules/maven-plugins/.gitignore b/maven-modules/maven-plugins/.gitignore new file mode 100644 index 0000000000..bae0b0d7ce --- /dev/null +++ b/maven-modules/maven-plugins/.gitignore @@ -0,0 +1,2 @@ +/output-resources +/.idea/ diff --git a/maven-modules/maven-plugins/README.md b/maven-modules/maven-plugins/README.md new file mode 100644 index 0000000000..4210a3bb20 --- /dev/null +++ b/maven-modules/maven-plugins/README.md @@ -0,0 +1,11 @@ +## Apache Maven + +This module contains articles about the core Maven plugins. Other Maven plugins (such as the Maven WAR Plugin) have their own dedicated modules. + +### Relevant Articles + +- [Guide to the Core Maven Plugins](https://www.baeldung.com/core-maven-plugins) +- [Maven Resources Plugin](https://www.baeldung.com/maven-resources-plugin) +- [The Maven Verifier Plugin](https://www.baeldung.com/maven-verifier-plugin) +- [The Maven Clean Plugin](https://www.baeldung.com/maven-clean-plugin) +- [Maven Enforcer Plugin](https://www.baeldung.com/maven-enforcer-plugin) diff --git a/maven-modules/maven-plugins/custom-rule/pom.xml b/maven-modules/maven-plugins/custom-rule/pom.xml new file mode 100644 index 0000000000..0fb551e71b --- /dev/null +++ b/maven-modules/maven-plugins/custom-rule/pom.xml @@ -0,0 +1,54 @@ + + + 4.0.0 + custom-rule + custom-rule + + + com.baeldung + maven-plugins + 0.0.1-SNAPSHOT + + + + + + org.apache.maven.enforcer + enforcer-api + ${api.version} + + + org.apache.maven + maven-project + ${maven.version} + + + org.apache.maven + maven-core + ${maven.version} + + + org.apache.maven + maven-artifact + ${maven.version} + + + org.apache.maven + maven-plugin-api + ${maven.version} + + + org.codehaus.plexus + plexus-container-default + ${plexus-container-default.version} + + + + + 3.0.0-M2 + 2.0.9 + 1.0-alpha-9 + + + diff --git a/maven-modules/maven-plugins/custom-rule/src/main/java/com/baeldung/enforcer/MyCustomRule.java b/maven-modules/maven-plugins/custom-rule/src/main/java/com/baeldung/enforcer/MyCustomRule.java new file mode 100644 index 0000000000..db636c2308 --- /dev/null +++ b/maven-modules/maven-plugins/custom-rule/src/main/java/com/baeldung/enforcer/MyCustomRule.java @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2019 PloyRef + * Created by Seun Matt + * on 19 - 2 - 2019 + */ + +package com.baeldung.enforcer; + +import org.apache.maven.enforcer.rule.api.EnforcerRule; +import org.apache.maven.enforcer.rule.api.EnforcerRuleException; +import org.apache.maven.enforcer.rule.api.EnforcerRuleHelper; +import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluationException; + +public class MyCustomRule implements EnforcerRule { + + public void execute(EnforcerRuleHelper enforcerRuleHelper) throws EnforcerRuleException { + + try { + + String groupId = (String) enforcerRuleHelper.evaluate("${project.groupId}"); + + if (groupId == null || !groupId.startsWith("com.baeldung")) { + throw new EnforcerRuleException("Project group id does not start with com.baeldung"); + } + + } + catch (ExpressionEvaluationException ex ) { + throw new EnforcerRuleException( "Unable to lookup an expression " + ex.getLocalizedMessage(), ex ); + } + } + + public boolean isCacheable() { + return false; + } + + public boolean isResultValid(EnforcerRule enforcerRule) { + return false; + } + + public String getCacheId() { + return null; + } +} diff --git a/maven-modules/maven-plugins/input-resources/baeldung.png b/maven-modules/maven-plugins/input-resources/baeldung.png new file mode 100644 index 0000000000..488f52e56e Binary files /dev/null and b/maven-modules/maven-plugins/input-resources/baeldung.png differ diff --git a/maven-modules/maven-plugins/input-resources/baeldung.txt b/maven-modules/maven-plugins/input-resources/baeldung.txt new file mode 100644 index 0000000000..6006764753 --- /dev/null +++ b/maven-modules/maven-plugins/input-resources/baeldung.txt @@ -0,0 +1 @@ +Welcome to ${resources.name}! \ No newline at end of file diff --git a/maven-modules/maven-plugins/input-resources/verifications.xml b/maven-modules/maven-plugins/input-resources/verifications.xml new file mode 100644 index 0000000000..c59b5086f6 --- /dev/null +++ b/maven-modules/maven-plugins/input-resources/verifications.xml @@ -0,0 +1,9 @@ + + + + input-resources/baeldung.txt + Welcome + + + \ No newline at end of file diff --git a/maven-modules/maven-plugins/maven-enforcer/pom.xml b/maven-modules/maven-plugins/maven-enforcer/pom.xml new file mode 100644 index 0000000000..01f97a061e --- /dev/null +++ b/maven-modules/maven-plugins/maven-enforcer/pom.xml @@ -0,0 +1,75 @@ + + + 4.0.0 + maven-enforcer + maven-enforcer + + + com.baeldung + maven-plugins + 0.0.1-SNAPSHOT + + + + + + org.apache.maven.plugins + maven-enforcer-plugin + 3.0.0-M2 + + + + + + + + + + enforce + + enforce + + + + + + 3.0 + Invalid Maven version. It should, at least, be 3.0 + + + 1.8 + + + ui + WARN + + + cook + WARN + + + local,base + Missing active profiles + WARN + + + + + + + + + + maven-verifier-plugin + ${maven.verifier.version} + + ../input-resources/verifications.xml + false + + + + + + \ No newline at end of file diff --git a/maven-modules/maven-plugins/pom.xml b/maven-modules/maven-plugins/pom.xml new file mode 100644 index 0000000000..43bcf1f422 --- /dev/null +++ b/maven-modules/maven-plugins/pom.xml @@ -0,0 +1,135 @@ + + + 4.0.0 + maven-plugins + 0.0.1-SNAPSHOT + maven-plugins + pom + + + com.baeldung + parent-modules + 1.0.0-SNAPSHOT + ../.. + + + + + + maven-resources-plugin + ${maven.resources.version} + + output-resources + + + input-resources + + *.png + + true + + + + + + maven-compiler-plugin + ${maven.compiler.version} + + ${java.version} + ${java.version} + + -Xlint:unchecked + + + + + maven-verifier-plugin + ${maven.verifier.version} + + input-resources/verifications.xml + + + + + verify + + + + + + maven-clean-plugin + ${maven.clean.version} + + + + output-resources + + + + + + + + + + default + + + + maven-surefire-plugin + ${maven.surefire.version} + + + DataTest.java + + + TestFail.java + DataCheck.java + + true + + + + + + + surefire + + + + maven-surefire-plugin + ${maven.surefire.version} + + + integration-test + + test + + + + none + + + **/*IntegrationTest + + + + + + + + + + + + 3.0.2 + 3.8.0 + 2.22.0 + 2.22.0 + 1.1 + 3.0.0 + 3.0.0 + + + \ No newline at end of file