Skip to content

Commit

Permalink
Reading project model should throw exception
Browse files Browse the repository at this point in the history
In other case we can omit a module from list to process

In Maven 4 model reading is more strict,
when we have a bad file in project - ITs can not start because of strict parsing
  • Loading branch information
slawekjaranowski committed Nov 13, 2023
1 parent 2ac332d commit 2fd9c32
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1416,9 +1416,8 @@ public static Map<File, Model> getChildModels(MavenProject project, Log logger)
* @param model The root model
* @param logger The logger for logging.
* @return A map of raw models keyed by path relative to the project's basedir.
* @throws IOException if things go wrong.
*/
private static Map<File, Model> getChildModels(Model model, Log logger) throws IOException {
private static Map<File, Model> getChildModels(Model model, Log logger) {
Map<File, Model> result = new LinkedHashMap<>();
Map<File, Model> childResults = new LinkedHashMap<>();

Expand All @@ -1436,7 +1435,7 @@ private static Map<File, Model> getChildModels(Model model, Log logger) throws I
result.put(pomFile, moduleModel);
childResults.putAll(getChildModels(moduleModel, logger));
} catch (IOException e) {
logger.error("Could not parse " + pomFile.getPath(), e);
throw new UncheckedIOException(e);
}
});

Expand Down
1 change: 1 addition & 0 deletions versions-maven-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@
<pomExclude>it-lock-snapshots-junit/*</pomExclude>
</pomExcludes>
<postBuildHookScript>verify</postBuildHookScript>
<preBuildHookScript>setup</preBuildHookScript>
<filterProperties>
<repository.proxy.url>${repository.proxy.url}</repository.proxy.url>
</filterProperties>
Expand Down
23 changes: 23 additions & 0 deletions versions-maven-plugin/src/it/it-set-017-issue-321/setup.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import java.nio.file.Files
/*
* Copyright MojoHaus and Contributors
*
* 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.
*
*/

// rename file before run test
def module2Path = basedir.toPath().resolve('module-a2')
Files.move(module2Path.resolve('pom.invalid'), module2Path.resolve('pom.xml'))

return true
22 changes: 0 additions & 22 deletions versions-maven-plugin/src/it/it-set-017-issue-321/verify.bsh

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@


def log = new File( basedir, "build.log" ).text
assert log.contains(' Illegal processing instruction target ("xml"); xml (case insensitive) is reserved by the specs.')

0 comments on commit 2fd9c32

Please sign in to comment.