Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 31 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,9 @@
<scope>provided</scope>
</dependency>
<dependency>
<groupId>io.github.java-diff-utils</groupId>
<artifactId>java-diff-utils</artifactId>
<version>4.12</version>
<groupId>org.eclipse.jgit</groupId>
<artifactId>org.eclipse.jgit</artifactId>
<version>5.13.5.202508271544-r</version>
</dependency>
</dependencies>

Expand Down Expand Up @@ -133,6 +133,7 @@
<header>apache-20-license.template.txt</header>
<excludes>
<exclude>apache-20-license.template.txt</exclude>
<exclude>src/it/apply-patch-existing-file/src/**</exclude>
</excludes>
</licenseSet>
</licenseSets>
Expand Down Expand Up @@ -291,6 +292,33 @@
<extensions>true</extensions>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-invoker-plugin</artifactId>
<dependencies>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>5.14.4</version>
</dependency>
</dependencies>
<configuration>
<cloneProjectsTo>${project.build.directory}/it</cloneProjectsTo>
<localRepositoryPath>${project.build.directory}/it-repo</localRepositoryPath>
<postBuildHookScript>verify</postBuildHookScript>
<debug>true</debug>
</configuration>
<executions>
<execution>
<id>integration-tests</id>
<goals>
<goal>install</goal>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>

</plugins>
</build>

Expand Down
50 changes: 50 additions & 0 deletions src/it/apply-patch-existing-file/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<!--

Copyright [2024] [Lukas Mansour]
Modifications: Copyright (C) 2026, Evolved Binary Ltd

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

-->
<project xmlns="http://maven.apache.org/POM/4.0.0">
<modelVersion>4.0.0</modelVersion>
<groupId>com.evolvedbinary.maven.plugins.it.patch-maven-plugin</groupId>
<artifactId>apply-patch-existing-file</artifactId>
<version>1.0.0</version>
<packaging>jar</packaging>

<name>Test Applying a Patch to an Existing File</name>

<build>
<plugins>

<plugin>
<groupId>com.evolvedbinary.maven.plugins</groupId>
<artifactId>patch-maven-plugin</artifactId>
<version>@project.version@</version>
<executions>
<execution>
<id>apply-patch</id>
<phase>process-resources</phase>
<goals><goal>apply</goal></goals>
<configuration>
<targetDirectory>${project.build.outputDirectory}</targetDirectory>
<patchDirectory>${project.basedir}/src/main/patches</patchDirectory>
<failOnFailedPatch>true</failOnFailedPatch>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
--- a/greeting.txt
+++ b/greeting.txt
@@ -1 +1 @@
-Hello, World!
+Hello, Elemental!
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Hello, World!
36 changes: 36 additions & 0 deletions src/it/apply-patch-existing-file/verify.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import java.nio.file.Files
import java.nio.file.Path

import static org.junit.jupiter.api.Assertions.assertTrue
import static org.junit.jupiter.api.Assertions.fail


/*
* Copyright [2024] [Lukas Mansour]
* Modifications: Copyright (C) 2026, Evolved Binary Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/



//open the file and check if the content(hello elemental) is truly there
final Path patchedFile = basedir.toPath().resolve("target/classes/greeting.txt")
if (!Files.exists(patchedFile)) {
fail("Patched file is missing: " + patchedFile)
}

final String content = new String(Files.readAllBytes(patchedFile))
assertTrue(content.contains("Hello, Elemental!"), "Expected content was not found in: " + patchedFile)
return true

49 changes: 49 additions & 0 deletions src/it/apply-patch-new-file/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<!--

Copyright [2024] [Lukas Mansour]
Modifications: Copyright (C) 2026, Evolved Binary Ltd

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

-->
<project xmlns="http://maven.apache.org/POM/4.0.0">
<modelVersion>4.0.0</modelVersion>
<groupId>com.evolvedbinary.maven.plugins.it.patch-maven-plugin</groupId>
<artifactId>apply-patch-new-file</artifactId>
<version>1.0.0</version>
<packaging>jar</packaging>

<name>Test Applying a Patch that Creates a New File</name>

<build>
<plugins>
<plugin>
<groupId>com.evolvedbinary.maven.plugins</groupId>
<artifactId>patch-maven-plugin</artifactId>
<version>@project.version@</version>
<executions>
<execution>
<id>apply-patch</id>
<phase>process-resources</phase>
<goals><goal>apply</goal></goals>
<configuration>
<targetDirectory>${project.build.outputDirectory}</targetDirectory>
<patchDirectory>${project.basedir}/src/main/patches</patchDirectory>
<failOnFailedPatch>true</failOnFailedPatch>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
--- /dev/null
+++ b/new-file.txt
@@ -0,0 +1,2 @@
+Hello, this is a
+brand new file!
Empty file.
33 changes: 33 additions & 0 deletions src/it/apply-patch-new-file/verify.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import java.nio.file.Files
import java.nio.file.Path

import static org.junit.jupiter.api.Assertions.assertTrue
import static org.junit.jupiter.api.Assertions.fail


/*
* Copyright [2024] [Lukas Mansour]
* Modifications: Copyright (C) 2026, Evolved Binary Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/


final Path createdFile = basedir.toPath().resolve("target/classes/new-file.txt")
if (!Files.exists(createdFile)) {
fail("New file was not created by the patch: " + createdFile)
}

final String content = new String(Files.readAllBytes(createdFile))
assertTrue(content.contains("brand new file"), "Expected content was not found in: " + createdFile)
return true
Loading