[BAEL-4823] Maven plugin management (#10957)

* [BAEL-4823] Maven plugin management

* [BAEL-4823] Minor code cleanup
This commit is contained in:
Haroon Khan 2021-07-13 13:34:34 +01:00 committed by GitHub
parent 5f655de832
commit 611d074aa4
6 changed files with 123 additions and 0 deletions

View File

@ -0,0 +1,63 @@
<?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>
<version>0.0.1-SNAPSHOT</version>
<parent>
<artifactId>maven-modules</artifactId>
<groupId>com.baeldung</groupId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>plugin-management</artifactId>
<packaging>pom</packaging>
<modules>
<module>submodule-1</module>
<module>submodule-2</module>
</modules>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>${maven.bulid.helper.plugin}</version>
<executions>
<execution>
<id>add-resource</id>
<phase>generate-resources</phase>
<goals>
<goal>add-resource</goal>
</goals>
<configuration>
<resources>
<resource>
<directory>src/resources</directory>
<targetPath>json</targetPath>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven.compiler.plugin}</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
<properties>
<maven.compiler.plugin>3.8.1</maven.compiler.plugin>
<maven.bulid.helper.plugin>3.2.0</maven.bulid.helper.plugin>
</properties>
</project>

View File

@ -0,0 +1,23 @@
<?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>submodule-1</artifactId>
<parent>
<artifactId>plugin-management</artifactId>
<groupId>com.baeldung</groupId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>

View File

@ -0,0 +1,3 @@
{
"key": "value"
}

View File

@ -0,0 +1,19 @@
package com.baeldung;
import org.junit.jupiter.api.Test;
import java.io.File;
import java.net.URL;
import static org.junit.jupiter.api.Assertions.assertTrue;
class CopiesAdditionalResourcesUnitTest {
@Test
void givenAdditionalResource_whenCopyingFromSourceToDestination_thenShouldBeInDestination() {
URL resource = getClass().getClassLoader().getResource("json/include.json");
File destinationFile = new File(resource.getFile());
assertTrue(destinationFile.exists());
}
}

View File

@ -0,0 +1,14 @@
<?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>submodule-2</artifactId>
<parent>
<artifactId>plugin-management</artifactId>
<groupId>com.baeldung</groupId>
<version>0.0.1-SNAPSHOT</version>
</parent>
</project>

View File

@ -33,6 +33,7 @@
<module>versions-maven-plugin</module>
<module>maven-printing-plugins</module>
<module>maven-builder-plugin</module>
<module>plugin-management</module>
</modules>
</project>