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
13 changes: 13 additions & 0 deletions evolvedbinary-apache-20-license.template.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
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.
53 changes: 48 additions & 5 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 @@ -128,13 +128,29 @@
<licenseSets>
<licenseSet>
<!--
License Apache 2.0
License Apache 2.0 - for files originally from the Lukas Mansour project
-->
<header>apache-20-license.template.txt</header>
<excludes>
<exclude>apache-20-license.template.txt</exclude>
<exclude>apache-20-license.template.txt</exclude>
<exclude>evolvedbinary-apache-20-license.template.txt</exclude>
<exclude>src/it/apply-patch-existing-file/src/**</exclude>
<exclude>src/it/apply-patch-existing-file/pom.xml</exclude>
<exclude>src/it/apply-patch-existing-file/verify.groovy</exclude>
<exclude>src/it/apply-patch-new-file/**</exclude>
</excludes>
</licenseSet>

<licenseSet>
<!--
License Apache 2.0 - for new files created entirely by Evolved Binary
-->
<header>evolvedbinary-apache-20-license.template.txt</header>
<includes>
<include>src/it/apply-patch-existing-file/pom.xml</include>
<include>src/it/apply-patch-existing-file/verify.groovy</include>
</includes>
</licenseSet>
</licenseSets>
</configuration>
<executions>
Expand Down Expand Up @@ -291,6 +307,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
49 changes: 49 additions & 0 deletions src/it/apply-patch-existing-file/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<!--

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!
50 changes: 50 additions & 0 deletions src/it/apply-patch-existing-file/verify.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*
* 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.
*/
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


/*

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same for this license declaration

* 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.trim().equals("Hello, Elemental!"), "Expected content was not found in: " + patchedFile);
return true

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

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!

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need this file?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's an empty placeholder, without it, src/main/resources would be empty, which means Git won't track the folder, which then makes the patch step fail because its target directory doesn't exist yet.

Empty file.
32 changes: 32 additions & 0 deletions src/it/apply-patch-new-file/verify.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
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 (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.trim().equals("Hello, this is a\nbrand new file!"), "Expected content was not found in: " + createdFile)
return true
Loading