Skip to content

Commit b2de54a

Browse files
authored
fix(internal/librarian/java): keep pom.xml during clean (#4382)
Modified the Java clean process to bypass pom.xml files, ensuring they are not removed if they already exist in the output directory. This matches the hermetic_build behavior on re-generation, except for surgical changes when new major version added. For #4127
1 parent 4f58421 commit b2de54a

2 files changed

Lines changed: 4 additions & 2 deletions

File tree

internal/librarian/java/clean.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,8 @@ func cleanPath(targetPath, root string, keepSet map[string]bool) error {
8383
if keepSet[rel] || itTestRegexp.MatchString(filepath.ToSlash(rel)) {
8484
return nil
8585
}
86-
// Bypass clirr-ignored-differences.xml files as they are generated once and manually maintained.
87-
if d.Name() == "clirr-ignored-differences.xml" {
86+
// Bypass clirr-ignored-differences.xml and pom.xml files as they are generated once and manually maintained.
87+
if d.Name() == "clirr-ignored-differences.xml" || d.Name() == "pom.xml" {
8888
return nil
8989
}
9090
return os.Remove(path)

internal/librarian/java/clean_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ func TestClean(t *testing.T) {
4848
files := []string{
4949
filepath.Join(tmpDir, libraryName, "src", "Main.java"),
5050
filepath.Join(tmpDir, libraryName, "src", "test", "java", "com", "google", "cloud", "secretmanager", "v1", "it", "ITSecretManagerTest.java"),
51+
filepath.Join(tmpDir, libraryName, "pom.xml"),
5152
filepath.Join(tmpDir, "kept-file.txt"),
5253
filepath.Join(tmpDir, "kept-dir", "file.txt"),
5354
}
@@ -85,6 +86,7 @@ func TestClean(t *testing.T) {
8586
keptPaths := []string{
8687
filepath.Join(tmpDir, "kept-file.txt"),
8788
filepath.Join(tmpDir, "kept-dir", "file.txt"),
89+
filepath.Join(tmpDir, libraryName, "pom.xml"),
8890
filepath.Join(tmpDir, libraryName, "src", "test", "java", "com", "google", "cloud", "secretmanager", "v1", "it", "ITSecretManagerTest.java"),
8991
}
9092
for _, p := range keptPaths {

0 commit comments

Comments
 (0)