-
Notifications
You must be signed in to change notification settings - Fork 0
Switch patch application from java-diff-utils to JGit #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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. |
| 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! |
| 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 | ||
|
|
||
|
|
||
| /* | ||
| * 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 | ||
|
|
||
| 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! |
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do we need this file?
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's an empty placeholder, without it, |
| 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 |
There was a problem hiding this comment.
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