From b684a5939268f2f69e71f3d3873103c896987a02 Mon Sep 17 00:00:00 2001
From: thomasduxbury <68503838+thomasduxbury@users.noreply.github.com>
Date: Thu, 13 May 2021 21:05:17 +0100
Subject: [PATCH] BAEL-4801: Copying Files with Maven (#10758)
* BAEL-4801: Copying files with Maven
* Removing unused file
* Removing src/main dirs from each sub-module, added unit tests and changed phase of plugins to 'generate-sources' so that the file is copied before unit tests execute
---
.../copy-rename-maven-plugin/pom.xml | 92 ++++++++++++++++++
.../source-files/foo.txt | 1 +
.../java/org/baeldung/CopyFileUnitTest.java | 16 ++++
.../maven-antrun-plugin/pom.xml | 94 +++++++++++++++++++
.../maven-antrun-plugin/source-files/foo.txt | 1 +
.../java/org/baeldung/CopyFileUnitTest.java | 16 ++++
.../maven-resources-plugin/pom.xml | 92 ++++++++++++++++++
.../source-files/foo.txt | 1 +
.../java/org/baeldung/CopyFileUnitTest.java | 16 ++++
maven-modules/maven-copy-files/pom.xml | 80 ++++++++++++++++
maven-modules/pom.xml | 3 +-
11 files changed, 411 insertions(+), 1 deletion(-)
create mode 100644 maven-modules/maven-copy-files/copy-rename-maven-plugin/pom.xml
create mode 100644 maven-modules/maven-copy-files/copy-rename-maven-plugin/source-files/foo.txt
create mode 100644 maven-modules/maven-copy-files/copy-rename-maven-plugin/src/test/java/org/baeldung/CopyFileUnitTest.java
create mode 100644 maven-modules/maven-copy-files/maven-antrun-plugin/pom.xml
create mode 100644 maven-modules/maven-copy-files/maven-antrun-plugin/source-files/foo.txt
create mode 100644 maven-modules/maven-copy-files/maven-antrun-plugin/src/test/java/org/baeldung/CopyFileUnitTest.java
create mode 100644 maven-modules/maven-copy-files/maven-resources-plugin/pom.xml
create mode 100644 maven-modules/maven-copy-files/maven-resources-plugin/source-files/foo.txt
create mode 100644 maven-modules/maven-copy-files/maven-resources-plugin/src/test/java/org/baeldung/CopyFileUnitTest.java
create mode 100644 maven-modules/maven-copy-files/pom.xml
diff --git a/maven-modules/maven-copy-files/copy-rename-maven-plugin/pom.xml b/maven-modules/maven-copy-files/copy-rename-maven-plugin/pom.xml
new file mode 100644
index 0000000000..24a7c48499
--- /dev/null
+++ b/maven-modules/maven-copy-files/copy-rename-maven-plugin/pom.xml
@@ -0,0 +1,92 @@
+
+
+ 4.0.0
+
+ maven-copy-files
+ com.baeldung
+ 1.0-SNAPSHOT
+
+ org.baeldung
+ copy-rename-maven-plugin
+ 1.0-SNAPSHOT
+ copy-rename-maven-plugin
+
+ UTF-8
+ 1.7
+ 1.7
+
+
+
+ junit
+ junit
+ 4.11
+ test
+
+
+
+
+
+ com.coderplus.maven.plugins
+ copy-rename-maven-plugin
+ 1.0
+
+
+ copy-file
+ generate-sources
+
+ copy
+
+
+ source-files/foo.txt
+ target/destination-folder/foo.txt
+
+
+
+
+
+
+
+
+
+
+ maven-clean-plugin
+ 3.1.0
+
+
+
+ maven-resources-plugin
+ 3.0.2
+
+
+ maven-compiler-plugin
+ 3.8.0
+
+
+ maven-surefire-plugin
+ 2.22.1
+
+
+ maven-jar-plugin
+ 3.0.2
+
+
+ maven-install-plugin
+ 2.5.2
+
+
+ maven-deploy-plugin
+ 2.8.2
+
+
+
+ maven-site-plugin
+ 3.7.1
+
+
+ maven-project-info-reports-plugin
+ 3.0.0
+
+
+
+
+
diff --git a/maven-modules/maven-copy-files/copy-rename-maven-plugin/source-files/foo.txt b/maven-modules/maven-copy-files/copy-rename-maven-plugin/source-files/foo.txt
new file mode 100644
index 0000000000..b2fa85b97f
--- /dev/null
+++ b/maven-modules/maven-copy-files/copy-rename-maven-plugin/source-files/foo.txt
@@ -0,0 +1 @@
+Copy File Example
diff --git a/maven-modules/maven-copy-files/copy-rename-maven-plugin/src/test/java/org/baeldung/CopyFileUnitTest.java b/maven-modules/maven-copy-files/copy-rename-maven-plugin/src/test/java/org/baeldung/CopyFileUnitTest.java
new file mode 100644
index 0000000000..a98db61fa9
--- /dev/null
+++ b/maven-modules/maven-copy-files/copy-rename-maven-plugin/src/test/java/org/baeldung/CopyFileUnitTest.java
@@ -0,0 +1,16 @@
+package org.baeldung;
+
+import org.junit.Test;
+
+import java.io.File;
+
+import static org.junit.Assert.assertEquals;
+
+public class CopyFileUnitTest {
+
+ @Test
+ public void whenCopyingAFileFromSourceToDestination_thenFileShouldBeInDestination() {
+ File destinationFile = new File("target/destination-folder/foo.txt");
+ assertEquals(true, destinationFile.exists());
+ }
+}
diff --git a/maven-modules/maven-copy-files/maven-antrun-plugin/pom.xml b/maven-modules/maven-copy-files/maven-antrun-plugin/pom.xml
new file mode 100644
index 0000000000..61017dd18a
--- /dev/null
+++ b/maven-modules/maven-copy-files/maven-antrun-plugin/pom.xml
@@ -0,0 +1,94 @@
+
+
+ 4.0.0
+
+ maven-copy-files
+ com.baeldung
+ 1.0-SNAPSHOT
+
+ org.baeldung
+ maven-antrun-plugin
+ 1.0-SNAPSHOT
+ maven-antrun-plugin
+
+ UTF-8
+ 1.7
+ 1.7
+
+
+
+ junit
+ junit
+ 4.11
+ test
+
+
+
+
+
+ maven-antrun-plugin
+ 3.0.0
+
+
+ generate-sources
+
+
+
+
+
+
+
+
+
+ run
+
+
+
+
+
+
+
+
+
+
+ maven-clean-plugin
+ 3.1.0
+
+
+
+ maven-resources-plugin
+ 3.0.2
+
+
+ maven-compiler-plugin
+ 3.8.0
+
+
+ maven-surefire-plugin
+ 2.22.1
+
+
+ maven-jar-plugin
+ 3.0.2
+
+
+ maven-install-plugin
+ 2.5.2
+
+
+ maven-deploy-plugin
+ 2.8.2
+
+
+
+ maven-site-plugin
+ 3.7.1
+
+
+ maven-project-info-reports-plugin
+ 3.0.0
+
+
+
+
+
diff --git a/maven-modules/maven-copy-files/maven-antrun-plugin/source-files/foo.txt b/maven-modules/maven-copy-files/maven-antrun-plugin/source-files/foo.txt
new file mode 100644
index 0000000000..b2fa85b97f
--- /dev/null
+++ b/maven-modules/maven-copy-files/maven-antrun-plugin/source-files/foo.txt
@@ -0,0 +1 @@
+Copy File Example
diff --git a/maven-modules/maven-copy-files/maven-antrun-plugin/src/test/java/org/baeldung/CopyFileUnitTest.java b/maven-modules/maven-copy-files/maven-antrun-plugin/src/test/java/org/baeldung/CopyFileUnitTest.java
new file mode 100644
index 0000000000..a98db61fa9
--- /dev/null
+++ b/maven-modules/maven-copy-files/maven-antrun-plugin/src/test/java/org/baeldung/CopyFileUnitTest.java
@@ -0,0 +1,16 @@
+package org.baeldung;
+
+import org.junit.Test;
+
+import java.io.File;
+
+import static org.junit.Assert.assertEquals;
+
+public class CopyFileUnitTest {
+
+ @Test
+ public void whenCopyingAFileFromSourceToDestination_thenFileShouldBeInDestination() {
+ File destinationFile = new File("target/destination-folder/foo.txt");
+ assertEquals(true, destinationFile.exists());
+ }
+}
diff --git a/maven-modules/maven-copy-files/maven-resources-plugin/pom.xml b/maven-modules/maven-copy-files/maven-resources-plugin/pom.xml
new file mode 100644
index 0000000000..7dbe851f95
--- /dev/null
+++ b/maven-modules/maven-copy-files/maven-resources-plugin/pom.xml
@@ -0,0 +1,92 @@
+
+
+ 4.0.0
+
+ maven-copy-files
+ com.baeldung
+ 1.0-SNAPSHOT
+
+ org.baeldung
+ maven-resources-plugin
+ 1.0-SNAPSHOT
+ maven-resoures-plugin
+
+ UTF-8
+ 1.7
+ 1.7
+
+
+
+ junit
+ junit
+ 4.11
+ test
+
+
+
+
+
+
+
+
+ maven-clean-plugin
+ 3.1.0
+
+
+
+ maven-resources-plugin
+ 3.0.2
+
+
+ copy-resource-one
+ generate-sources
+
+ copy-resources
+
+
+ ${basedir}/target/destination-folder
+
+
+ source-files
+
+ foo.txt
+
+
+
+
+
+
+
+
+ maven-compiler-plugin
+ 3.8.0
+
+
+ maven-surefire-plugin
+ 2.22.1
+
+
+ maven-jar-plugin
+ 3.0.2
+
+
+ maven-install-plugin
+ 2.5.2
+
+
+ maven-deploy-plugin
+ 2.8.2
+
+
+
+ maven-site-plugin
+ 3.7.1
+
+
+ maven-project-info-reports-plugin
+ 3.0.0
+
+
+
+
+
diff --git a/maven-modules/maven-copy-files/maven-resources-plugin/source-files/foo.txt b/maven-modules/maven-copy-files/maven-resources-plugin/source-files/foo.txt
new file mode 100644
index 0000000000..b2fa85b97f
--- /dev/null
+++ b/maven-modules/maven-copy-files/maven-resources-plugin/source-files/foo.txt
@@ -0,0 +1 @@
+Copy File Example
diff --git a/maven-modules/maven-copy-files/maven-resources-plugin/src/test/java/org/baeldung/CopyFileUnitTest.java b/maven-modules/maven-copy-files/maven-resources-plugin/src/test/java/org/baeldung/CopyFileUnitTest.java
new file mode 100644
index 0000000000..a98db61fa9
--- /dev/null
+++ b/maven-modules/maven-copy-files/maven-resources-plugin/src/test/java/org/baeldung/CopyFileUnitTest.java
@@ -0,0 +1,16 @@
+package org.baeldung;
+
+import org.junit.Test;
+
+import java.io.File;
+
+import static org.junit.Assert.assertEquals;
+
+public class CopyFileUnitTest {
+
+ @Test
+ public void whenCopyingAFileFromSourceToDestination_thenFileShouldBeInDestination() {
+ File destinationFile = new File("target/destination-folder/foo.txt");
+ assertEquals(true, destinationFile.exists());
+ }
+}
diff --git a/maven-modules/maven-copy-files/pom.xml b/maven-modules/maven-copy-files/pom.xml
new file mode 100644
index 0000000000..b7b67286bc
--- /dev/null
+++ b/maven-modules/maven-copy-files/pom.xml
@@ -0,0 +1,80 @@
+
+
+ 4.0.0
+
+ maven-modules
+ com.baeldung
+ 0.0.1-SNAPSHOT
+
+ com.baeldung
+ maven-copy-files
+ 1.0-SNAPSHOT
+ pom
+ maven-copy-files
+
+ http://www.example.com
+
+ UTF-8
+ 1.7
+ 1.7
+
+
+
+ junit
+ junit
+ 4.11
+ test
+
+
+
+
+
+
+
+
+ maven-clean-plugin
+ 3.1.0
+
+
+
+ maven-resources-plugin
+ 3.0.2
+
+
+ maven-compiler-plugin
+ 3.8.0
+
+
+ maven-surefire-plugin
+ 2.22.1
+
+
+ maven-jar-plugin
+ 3.0.2
+
+
+ maven-install-plugin
+ 2.5.2
+
+
+ maven-deploy-plugin
+ 2.8.2
+
+
+
+ maven-site-plugin
+ 3.7.1
+
+
+ maven-project-info-reports-plugin
+ 3.0.0
+
+
+
+
+
+ maven-resources-plugin
+ maven-antrun-plugin
+ copy-rename-maven-plugin
+
+
diff --git a/maven-modules/pom.xml b/maven-modules/pom.xml
index 6fd9997c30..0f146e26da 100644
--- a/maven-modules/pom.xml
+++ b/maven-modules/pom.xml
@@ -16,6 +16,7 @@
+ maven-copy-files
maven-custom-plugin
maven-exec-plugin
maven-integration-test
@@ -33,4 +34,4 @@
maven-printing-plugins
-
\ No newline at end of file
+