From 81abb5870cdb1937a086deac37f626921bed0f15 Mon Sep 17 00:00:00 2001 From: Guillaume Nodet Date: Mon, 5 Jun 2023 16:24:36 +0200 Subject: [PATCH] [MNG-7740] Remove old temporary consumer*pom files from buildDir (#263) Co-authored-by: Giovanni van der Schelde Co-authored-by: Giovanni van der Schelde --- ...onsumerBuildShouldCleanUpOldFilesTest.java | 76 +++++++++++++++++++ .../apache/maven/it/TestSuiteOrdering.java | 1 + .../resources/mng-7740-consumer-files/pom.xml | 8 ++ 3 files changed, 85 insertions(+) create mode 100644 its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng7740ConsumerBuildShouldCleanUpOldFilesTest.java create mode 100644 its/core-it-suite/src/test/resources/mng-7740-consumer-files/pom.xml diff --git a/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng7740ConsumerBuildShouldCleanUpOldFilesTest.java b/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng7740ConsumerBuildShouldCleanUpOldFilesTest.java new file mode 100644 index 0000000000..b84c5c04ac --- /dev/null +++ b/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng7740ConsumerBuildShouldCleanUpOldFilesTest.java @@ -0,0 +1,76 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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. + */ +package org.apache.maven.it; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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.io.File; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.List; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +import org.apache.maven.shared.verifier.Verifier; +import org.apache.maven.shared.verifier.util.ResourceExtractor; +import org.junit.jupiter.api.Test; + +class MavenITmng7740ConsumerBuildShouldCleanUpOldFilesTest extends AbstractMavenIntegrationTestCase { + + protected MavenITmng7740ConsumerBuildShouldCleanUpOldFilesTest() { + super("[4.0.0-alpha-6,)"); + } + + @Test + void testConsumerBuildShouldCleanUpOldConsumerFiles() throws Exception { + File testDir = ResourceExtractor.simpleExtractResources(getClass(), "/mng-7740-consumer-files"); + + Verifier verifier = newVerifier(testDir.getAbsolutePath()); + verifier.addCliArgument("validate"); + + verifier.execute(); + + verifier.verifyErrorFreeLog(); + + try (Stream stream = Files.walk(testDir.toPath())) { + final List consumerFiles = stream.filter( + path -> path.getFileName().toString().contains("consumer") + && path.getFileName().toString().contains("pom")) + .collect(Collectors.toList()); + assertTrue("Expected no consumer pom file.", consumerFiles.size() == 0); + } + } +} diff --git a/its/core-it-suite/src/test/java/org/apache/maven/it/TestSuiteOrdering.java b/its/core-it-suite/src/test/java/org/apache/maven/it/TestSuiteOrdering.java index d6fddd654e..eb82334536 100644 --- a/its/core-it-suite/src/test/java/org/apache/maven/it/TestSuiteOrdering.java +++ b/its/core-it-suite/src/test/java/org/apache/maven/it/TestSuiteOrdering.java @@ -120,6 +120,7 @@ public class TestSuiteOrdering implements ClassOrderer { * the tests are to finishing. Newer tests are also more likely to fail, so this is * a fail fast technique as well. */ + suite.addTestSuite(MavenITmng7740ConsumerBuildShouldCleanUpOldFilesTest.class); suite.addTestSuite(MavenITmng7587Jsr330.class); suite.addTestSuite(MavenITmng7038RootdirTest.class); suite.addTestSuite(MavenITmng7697PomWithEmojiTest.class); diff --git a/its/core-it-suite/src/test/resources/mng-7740-consumer-files/pom.xml b/its/core-it-suite/src/test/resources/mng-7740-consumer-files/pom.xml new file mode 100644 index 0000000000..82a6abd72f --- /dev/null +++ b/its/core-it-suite/src/test/resources/mng-7740-consumer-files/pom.xml @@ -0,0 +1,8 @@ + + + 4.0.0 + + org.apache.maven.its.mng7740 + test + 1.0-SNAPSHOT +