JAVA-49: new module for core maven plugins
This commit is contained in:
parent
25d14b9f04
commit
a794bcf0d1
|
@ -0,0 +1,2 @@
|
|||
/output-resources
|
||||
/.idea/
|
|
@ -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)
|
|
@ -0,0 +1,54 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>custom-rule</artifactId>
|
||||
<name>custom-rule</name>
|
||||
|
||||
<parent>
|
||||
<groupId>com.baeldung</groupId>
|
||||
<artifactId>maven-plugins</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
<!-- dependencies for maven plugin -->
|
||||
<dependency>
|
||||
<groupId>org.apache.maven.enforcer</groupId>
|
||||
<artifactId>enforcer-api</artifactId>
|
||||
<version>${api.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.maven</groupId>
|
||||
<artifactId>maven-project</artifactId>
|
||||
<version>${maven.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.maven</groupId>
|
||||
<artifactId>maven-core</artifactId>
|
||||
<version>${maven.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.maven</groupId>
|
||||
<artifactId>maven-artifact</artifactId>
|
||||
<version>${maven.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.maven</groupId>
|
||||
<artifactId>maven-plugin-api</artifactId>
|
||||
<version>${maven.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.codehaus.plexus</groupId>
|
||||
<artifactId>plexus-container-default</artifactId>
|
||||
<version>${plexus-container-default.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<properties>
|
||||
<api.version>3.0.0-M2</api.version>
|
||||
<maven.version>2.0.9</maven.version>
|
||||
<plexus-container-default.version>1.0-alpha-9</plexus-container-default.version>
|
||||
</properties>
|
||||
|
||||
</project>
|
|
@ -0,0 +1,43 @@
|
|||
/*
|
||||
* Copyright (c) 2019 PloyRef
|
||||
* Created by Seun Matt <smatt382@gmail.com>
|
||||
* 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;
|
||||
}
|
||||
}
|
Binary file not shown.
After Width: | Height: | Size: 4.2 KiB |
|
@ -0,0 +1 @@
|
|||
Welcome to ${resources.name}!
|
|
@ -0,0 +1,9 @@
|
|||
<verifications xmlns="http://maven.apache.org/verifications/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/verifications/1.0.0 http://maven.apache.org/xsd/verifications-1.0.0.xsd">
|
||||
<files>
|
||||
<file>
|
||||
<location>input-resources/baeldung.txt</location>
|
||||
<contains>Welcome</contains>
|
||||
</file>
|
||||
</files>
|
||||
</verifications>
|
|
@ -0,0 +1,75 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>maven-enforcer</artifactId>
|
||||
<name>maven-enforcer</name>
|
||||
|
||||
<parent>
|
||||
<groupId>com.baeldung</groupId>
|
||||
<artifactId>maven-plugins</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-enforcer-plugin</artifactId>
|
||||
<version>3.0.0-M2</version>
|
||||
<!--<dependencies>-->
|
||||
<!--<dependency>-->
|
||||
<!--<groupId>com.baeldung</groupId>-->
|
||||
<!--<artifactId>custom-rule</artifactId>-->
|
||||
<!--<version>1.0</version>-->
|
||||
<!--</dependency>-->
|
||||
<!--</dependencies>-->
|
||||
<executions>
|
||||
<execution>
|
||||
<id>enforce</id>
|
||||
<goals>
|
||||
<goal>enforce</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<rules>
|
||||
<banDuplicatePomDependencyVersions/>
|
||||
<requireMavenVersion>
|
||||
<version>3.0</version>
|
||||
<message>Invalid Maven version. It should, at least, be 3.0</message>
|
||||
</requireMavenVersion>
|
||||
<requireJavaVersion>
|
||||
<version>1.8</version>
|
||||
</requireJavaVersion>
|
||||
<requireEnvironmentVariable>
|
||||
<variableName>ui</variableName>
|
||||
<level>WARN</level>
|
||||
</requireEnvironmentVariable>
|
||||
<requireEnvironmentVariable>
|
||||
<variableName>cook</variableName>
|
||||
<level>WARN</level>
|
||||
</requireEnvironmentVariable>
|
||||
<requireActiveProfile>
|
||||
<profiles>local,base</profiles>
|
||||
<message>Missing active profiles</message>
|
||||
<level>WARN</level>
|
||||
</requireActiveProfile>
|
||||
<!--other rules -->
|
||||
<!--<myCustomRule implementation="com.baeldung.enforcer.MyCustomRule"/>-->
|
||||
</rules>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-verifier-plugin</artifactId>
|
||||
<version>${maven.verifier.version}</version>
|
||||
<configuration>
|
||||
<verificationFile>../input-resources/verifications.xml</verificationFile>
|
||||
<failOnError>false</failOnError>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
|
@ -0,0 +1,135 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>maven-plugins</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<name>maven-plugins</name>
|
||||
<packaging>pom</packaging>
|
||||
|
||||
<parent>
|
||||
<groupId>com.baeldung</groupId>
|
||||
<artifactId>parent-modules</artifactId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
<relativePath>../..</relativePath>
|
||||
</parent>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-resources-plugin</artifactId>
|
||||
<version>${maven.resources.version}</version>
|
||||
<configuration>
|
||||
<outputDirectory>output-resources</outputDirectory>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>input-resources</directory>
|
||||
<excludes>
|
||||
<exclude>*.png</exclude>
|
||||
</excludes>
|
||||
<filtering>true</filtering>
|
||||
</resource>
|
||||
</resources>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>${maven.compiler.version}</version>
|
||||
<configuration>
|
||||
<source>${java.version}</source>
|
||||
<target>${java.version}</target>
|
||||
<compilerArgs>
|
||||
<arg>-Xlint:unchecked</arg>
|
||||
</compilerArgs>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-verifier-plugin</artifactId>
|
||||
<version>${maven.verifier.version}</version>
|
||||
<configuration>
|
||||
<verificationFile>input-resources/verifications.xml</verificationFile>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>verify</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-clean-plugin</artifactId>
|
||||
<version>${maven.clean.version}</version>
|
||||
<configuration>
|
||||
<filesets>
|
||||
<fileset>
|
||||
<directory>output-resources</directory>
|
||||
</fileset>
|
||||
</filesets>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<profiles>
|
||||
<profile>
|
||||
<id>default</id>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<version>${maven.surefire.version}</version>
|
||||
<configuration>
|
||||
<excludes>
|
||||
<exclude>DataTest.java</exclude>
|
||||
</excludes>
|
||||
<includes>
|
||||
<include>TestFail.java</include>
|
||||
<include>DataCheck.java</include>
|
||||
</includes>
|
||||
<testFailureIgnore>true</testFailureIgnore>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>surefire</id>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<version>${maven.surefire.version}</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>integration-test</phase>
|
||||
<goals>
|
||||
<goal>test</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<excludes>
|
||||
<exclude>none</exclude>
|
||||
</excludes>
|
||||
<includes>
|
||||
<include>**/*IntegrationTest</include>
|
||||
</includes>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</profile>
|
||||
</profiles>
|
||||
|
||||
<properties>
|
||||
<maven.resources.version>3.0.2</maven.resources.version>
|
||||
<maven.compiler.version>3.8.0</maven.compiler.version>
|
||||
<maven.surefire.version>2.22.0</maven.surefire.version>
|
||||
<maven.failsafe.version>2.22.0</maven.failsafe.version>
|
||||
<maven.verifier.version>1.1</maven.verifier.version>
|
||||
<maven.clean.version>3.0.0</maven.clean.version>
|
||||
<maven.build.helper.version>3.0.0</maven.build.helper.version>
|
||||
</properties>
|
||||
|
||||
</project>
|
Loading…
Reference in New Issue