Skip to content

Commit 2fd9c32

Browse files
Reading project model should throw exception
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
1 parent 2ac332d commit 2fd9c32

File tree

6 files changed

+30
-25
lines changed

6 files changed

+30
-25
lines changed

versions-common/src/main/java/org/codehaus/mojo/versions/api/PomHelper.java

+2-3
Original file line numberDiff line numberDiff line change
@@ -1416,9 +1416,8 @@ public static Map<File, Model> getChildModels(MavenProject project, Log logger)
14161416
* @param model The root model
14171417
* @param logger The logger for logging.
14181418
* @return A map of raw models keyed by path relative to the project's basedir.
1419-
* @throws IOException if things go wrong.
14201419
*/
1421-
private static Map<File, Model> getChildModels(Model model, Log logger) throws IOException {
1420+
private static Map<File, Model> getChildModels(Model model, Log logger) {
14221421
Map<File, Model> result = new LinkedHashMap<>();
14231422
Map<File, Model> childResults = new LinkedHashMap<>();
14241423

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

versions-maven-plugin/pom.xml

+1
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,7 @@
200200
<pomExclude>it-lock-snapshots-junit/*</pomExclude>
201201
</pomExcludes>
202202
<postBuildHookScript>verify</postBuildHookScript>
203+
<preBuildHookScript>setup</preBuildHookScript>
203204
<filterProperties>
204205
<repository.proxy.url>${repository.proxy.url}</repository.proxy.url>
205206
</filterProperties>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import java.nio.file.Files
2+
/*
3+
* Copyright MojoHaus and Contributors
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*
17+
*/
18+
19+
// rename file before run test
20+
def module2Path = basedir.toPath().resolve('module-a2')
21+
Files.move(module2Path.resolve('pom.invalid'), module2Path.resolve('pom.xml'))
22+
23+
return true

versions-maven-plugin/src/it/it-set-017-issue-321/verify.bsh

-22
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
2+
3+
def log = new File( basedir, "build.log" ).text
4+
assert log.contains(' Illegal processing instruction target ("xml"); xml (case insensitive) is reserved by the specs.')

0 commit comments

Comments
 (0)