From f0b85a554b88aa3cc901c33d48b6a93f9e367b7f Mon Sep 17 00:00:00 2001
From: Andrzej Jarmoniuk
Date: Tue, 24 Jan 2023 21:16:44 +0100
Subject: [PATCH] Issue #74: Add display-extension-updates
---
pom.xml | 1 +
versions-common/pom.xml | 5 +
.../versions/api/DefaultVersionsHelper.java | 24 ++--
.../mojo/versions/api/VersionsHelper.java | 24 ++--
.../versions/filtering/DependencyFilter.java | 24 ++--
.../versions/utils/CoreExtensionUtils.java | 8 +-
.../versions/utils/DependencyBuilder.java | 28 ++---
.../utils/CoreExtensionUtilsTest.java | 4 +-
.../child/.mvn/extensions.xml | 8 ++
.../child/pom.xml | 27 ++++
.../invoker.properties | 5 +
.../it-display-extension-updates-004/pom.xml | 29 +++++
.../verify.groovy | 10 ++
.../versions/DisplayExtensionUpdatesMojo.java | 102 ++++++++++++---
versions-model-core-extensions/pom.xml | 63 ++++++++++
.../src/main/mdo/core-extensions.mdo | 118 ++++++++++++++++++
.../mojo/versions/utils/MockUtils.java | 28 ++---
17 files changed, 409 insertions(+), 99 deletions(-)
create mode 100644 versions-maven-plugin/src/it/it-display-extension-updates-004/child/.mvn/extensions.xml
create mode 100644 versions-maven-plugin/src/it/it-display-extension-updates-004/child/pom.xml
create mode 100644 versions-maven-plugin/src/it/it-display-extension-updates-004/invoker.properties
create mode 100644 versions-maven-plugin/src/it/it-display-extension-updates-004/pom.xml
create mode 100644 versions-maven-plugin/src/it/it-display-extension-updates-004/verify.groovy
create mode 100644 versions-model-core-extensions/pom.xml
create mode 100644 versions-model-core-extensions/src/main/mdo/core-extensions.mdo
diff --git a/pom.xml b/pom.xml
index d9a2750a02..b26e7bf063 100644
--- a/pom.xml
+++ b/pom.xml
@@ -101,6 +101,7 @@
versions-maven-plugin
versions-model-report
versions-model
+ versions-model-core-extensions
versions-test
diff --git a/versions-common/pom.xml b/versions-common/pom.xml
index a65e215b0e..f6e1188af0 100644
--- a/versions-common/pom.xml
+++ b/versions-common/pom.xml
@@ -23,6 +23,11 @@
versions-model
${project.version}
+
+ org.codehaus.mojo.versions
+ versions-model-core-extensions
+ ${project.version}
+
org.apache.maven
diff --git a/versions-common/src/main/java/org/codehaus/mojo/versions/api/DefaultVersionsHelper.java b/versions-common/src/main/java/org/codehaus/mojo/versions/api/DefaultVersionsHelper.java
index f94a1ca164..9a75757bf4 100644
--- a/versions-common/src/main/java/org/codehaus/mojo/versions/api/DefaultVersionsHelper.java
+++ b/versions-common/src/main/java/org/codehaus/mojo/versions/api/DefaultVersionsHelper.java
@@ -1,22 +1,18 @@
package org.codehaus.mojo.versions.api;
/*
- * 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
+ * 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
+ * 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.
+ * 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.BufferedInputStream;
diff --git a/versions-common/src/main/java/org/codehaus/mojo/versions/api/VersionsHelper.java b/versions-common/src/main/java/org/codehaus/mojo/versions/api/VersionsHelper.java
index 102f0a6b3a..0c3e2347e0 100644
--- a/versions-common/src/main/java/org/codehaus/mojo/versions/api/VersionsHelper.java
+++ b/versions-common/src/main/java/org/codehaus/mojo/versions/api/VersionsHelper.java
@@ -1,22 +1,18 @@
package org.codehaus.mojo.versions.api;
/*
- * 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
+ * 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
+ * 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.
+ * 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.util.Collection;
diff --git a/versions-common/src/main/java/org/codehaus/mojo/versions/filtering/DependencyFilter.java b/versions-common/src/main/java/org/codehaus/mojo/versions/filtering/DependencyFilter.java
index 6b6475dc5b..d2808a0a76 100644
--- a/versions-common/src/main/java/org/codehaus/mojo/versions/filtering/DependencyFilter.java
+++ b/versions-common/src/main/java/org/codehaus/mojo/versions/filtering/DependencyFilter.java
@@ -1,22 +1,18 @@
package org.codehaus.mojo.versions.filtering;
/*
- * 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
+ * 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
+ * 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.
+ * 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.util.Collection;
diff --git a/versions-common/src/main/java/org/codehaus/mojo/versions/utils/CoreExtensionUtils.java b/versions-common/src/main/java/org/codehaus/mojo/versions/utils/CoreExtensionUtils.java
index 62638fac85..94525b2277 100644
--- a/versions-common/src/main/java/org/codehaus/mojo/versions/utils/CoreExtensionUtils.java
+++ b/versions-common/src/main/java/org/codehaus/mojo/versions/utils/CoreExtensionUtils.java
@@ -25,8 +25,8 @@
import java.util.stream.Stream;
import org.apache.maven.cli.internal.extension.model.io.xpp3.CoreExtensionsXpp3Reader;
-import org.apache.maven.execution.MavenSession;
import org.apache.maven.model.Extension;
+import org.apache.maven.project.MavenProject;
import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
/**
@@ -40,14 +40,14 @@ public final class CoreExtensionUtils {
* Reads the core extensions (not build extensions) configured for the given project
* from the {@code ${project}/.mvn/extensions.xml} file.
*
- * @param session {@link MavenSession} instance
+ * @param project {@link MavenProject} instance
* @return stream of core extensions defined in the {@code ${project}/.mvn/extensions.xml} file
* @throws IOException thrown if a file I/O operation fails
* @throws XmlPullParserException thrown if the file cannot be parsed
* @since 2.15.0
*/
- public static Stream getCoreExtensions(MavenSession session) throws IOException, XmlPullParserException {
- Path extensionsFile = session.getCurrentProject().getBasedir().toPath().resolve(".mvn/extensions.xml");
+ public static Stream getCoreExtensions(MavenProject project) throws IOException, XmlPullParserException {
+ Path extensionsFile = project.getBasedir().toPath().resolve(".mvn/extensions.xml");
if (!Files.isRegularFile(extensionsFile)) {
return Stream.empty();
}
diff --git a/versions-common/src/main/java/org/codehaus/mojo/versions/utils/DependencyBuilder.java b/versions-common/src/main/java/org/codehaus/mojo/versions/utils/DependencyBuilder.java
index c5daba94c3..6574f4b557 100644
--- a/versions-common/src/main/java/org/codehaus/mojo/versions/utils/DependencyBuilder.java
+++ b/versions-common/src/main/java/org/codehaus/mojo/versions/utils/DependencyBuilder.java
@@ -1,24 +1,20 @@
+package org.codehaus.mojo.versions.utils;
+
/*
- * 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
+ * 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
+ * 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.
+ * 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.codehaus.mojo.versions.utils;
-
import java.util.Optional;
import org.apache.maven.model.Dependency;
diff --git a/versions-common/src/test/java/org/codehaus/mojo/versions/utils/CoreExtensionUtilsTest.java b/versions-common/src/test/java/org/codehaus/mojo/versions/utils/CoreExtensionUtilsTest.java
index f0500f15dc..90aaeec527 100644
--- a/versions-common/src/test/java/org/codehaus/mojo/versions/utils/CoreExtensionUtilsTest.java
+++ b/versions-common/src/test/java/org/codehaus/mojo/versions/utils/CoreExtensionUtilsTest.java
@@ -48,7 +48,7 @@ public void testNoExtensions() throws XmlPullParserException, IOException {
new File("src/test/resources/org/codehaus/mojo/versions/utils/core-extensions/no-extensions"));
MavenSession session = mock(MavenSession.class);
when(session.getCurrentProject()).thenReturn(project);
- assertThat(CoreExtensionUtils.getCoreExtensions(session).findAny(), is(Optional.empty()));
+ assertThat(CoreExtensionUtils.getCoreExtensions(project).findAny(), is(Optional.empty()));
}
@Test
@@ -59,7 +59,7 @@ public void testExtensionsFound() throws XmlPullParserException, IOException {
MavenSession session = mock(MavenSession.class);
when(session.getCurrentProject()).thenReturn(project);
Set extensions =
- CoreExtensionUtils.getCoreExtensions(session).collect(Collectors.toSet());
+ CoreExtensionUtils.getCoreExtensions(project).collect(Collectors.toSet());
assertThat(
extensions,
hasItems(
diff --git a/versions-maven-plugin/src/it/it-display-extension-updates-004/child/.mvn/extensions.xml b/versions-maven-plugin/src/it/it-display-extension-updates-004/child/.mvn/extensions.xml
new file mode 100644
index 0000000000..4a58d492bd
--- /dev/null
+++ b/versions-maven-plugin/src/it/it-display-extension-updates-004/child/.mvn/extensions.xml
@@ -0,0 +1,8 @@
+
+
+ localhost
+ dummy-impl
+ 1.0
+
+
\ No newline at end of file
diff --git a/versions-maven-plugin/src/it/it-display-extension-updates-004/child/pom.xml b/versions-maven-plugin/src/it/it-display-extension-updates-004/child/pom.xml
new file mode 100644
index 0000000000..fe5589160e
--- /dev/null
+++ b/versions-maven-plugin/src/it/it-display-extension-updates-004/child/pom.xml
@@ -0,0 +1,27 @@
+
+ 4.0.0
+
+
+ localhost
+ it-display-extension-updates-004
+ 1.0
+
+
+ child
+ 1.0
+
+ pom
+
+
+
+
+ localhost
+ dummy-maven-plugin
+ ${dummyMavenPluginVersion}
+
+
+
+
+
diff --git a/versions-maven-plugin/src/it/it-display-extension-updates-004/invoker.properties b/versions-maven-plugin/src/it/it-display-extension-updates-004/invoker.properties
new file mode 100644
index 0000000000..bb83305ac1
--- /dev/null
+++ b/versions-maven-plugin/src/it/it-display-extension-updates-004/invoker.properties
@@ -0,0 +1,5 @@
+invoker.goals.1 = ${project.groupId}:${project.artifactId}:${project.version}:display-extension-updates
+invoker.mavenOpts.1 = -Dversions.outputFile=./output1.txt -DoutputEncoding=UTF-8
+
+invoker.goals.2 = ${project.groupId}:${project.artifactId}:${project.version}:display-extension-updates
+invoker.mavenOpts.2 = -DinterpolateProperties=false -Dversions.outputFile=./output2.txt -DoutputEncoding=UTF-8
diff --git a/versions-maven-plugin/src/it/it-display-extension-updates-004/pom.xml b/versions-maven-plugin/src/it/it-display-extension-updates-004/pom.xml
new file mode 100644
index 0000000000..5419f56a67
--- /dev/null
+++ b/versions-maven-plugin/src/it/it-display-extension-updates-004/pom.xml
@@ -0,0 +1,29 @@
+
+ 4.0.0
+ localhost
+ it-display-extension-updates-004
+ 1.0
+ pom
+
+
+ child
+
+
+
+ 1.0
+ 1.0
+
+
+
+
+
+ localhost
+ dummy-api
+ ${dummyApiVersion}
+
+
+
+
+
diff --git a/versions-maven-plugin/src/it/it-display-extension-updates-004/verify.groovy b/versions-maven-plugin/src/it/it-display-extension-updates-004/verify.groovy
new file mode 100644
index 0000000000..1fcf0ac43a
--- /dev/null
+++ b/versions-maven-plugin/src/it/it-display-extension-updates-004/verify.groovy
@@ -0,0 +1,10 @@
+def parentOutput = new File( basedir, "output1.txt").text
+assert parentOutput =~ /\Qlocalhost:dummy-maven-plugin\E\s*\.*\s*\Q1.0\E\s+->\s+\Q3.1\E/
+assert parentOutput =~ /\Qlocalhost:dummy-api\E\s*\.*\s*\Q1.0\E\s+->\s+\Q3.0\E/
+
+def childOutput = new File( basedir, "child/output1.txt")
+assert !childOutput.exists()
+
+def parentOutput2 = new File( basedir, "output2.txt").text
+assert parentOutput2 =~ /\Qlocalhost:dummy-maven-plugin\E\s*\.*\s*\Q\u0024{dummyMavenPluginVersion}\E\s+->\s+\Q3.1\E/
+assert parentOutput2 =~ /\Qlocalhost:dummy-api\E\s*\.*\s*\Q\u0024{dummyApiVersion}\E\s+->\s+\Q3.0\E/
diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/DisplayExtensionUpdatesMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/DisplayExtensionUpdatesMojo.java
index c73f5d1ec0..bf9bf2b19a 100644
--- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/DisplayExtensionUpdatesMojo.java
+++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/DisplayExtensionUpdatesMojo.java
@@ -1,30 +1,30 @@
package org.codehaus.mojo.versions;
/*
- * 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
+ * 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
+ * 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.
+ * 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 javax.inject.Inject;
import java.io.IOException;
+import java.nio.file.Files;
import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.Objects;
import java.util.Optional;
import java.util.Set;
import java.util.stream.Collectors;
@@ -32,8 +32,10 @@
import org.apache.maven.artifact.ArtifactUtils;
import org.apache.maven.artifact.versioning.ArtifactVersion;
+import org.apache.maven.model.Build;
import org.apache.maven.model.Dependency;
import org.apache.maven.model.Extension;
+import org.apache.maven.model.Model;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.plugins.annotations.Mojo;
@@ -41,6 +43,7 @@
import org.apache.maven.repository.RepositorySystem;
import org.apache.maven.wagon.Wagon;
import org.codehaus.mojo.versions.api.ArtifactVersions;
+import org.codehaus.mojo.versions.api.PomHelper;
import org.codehaus.mojo.versions.api.Segment;
import org.codehaus.mojo.versions.api.VersionRetrievalException;
import org.codehaus.mojo.versions.api.recording.ChangeRecorder;
@@ -49,6 +52,8 @@
import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader;
import org.codehaus.mojo.versions.utils.CoreExtensionUtils;
import org.codehaus.mojo.versions.utils.DependencyBuilder;
+import org.codehaus.mojo.versions.utils.ExtensionBuilder;
+import org.codehaus.mojo.versions.utils.ModelNode;
import org.codehaus.mojo.versions.utils.SegmentUtils;
import org.codehaus.plexus.util.StringUtils;
import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
@@ -57,13 +62,12 @@
import static org.codehaus.mojo.versions.api.Segment.MAJOR;
/**
- * Displays all build extensions that have newer versions available.
- * Does not check the core extensions.
+ * Displays all build and core extensions that have newer versions available.
*
* @author Andrzej Jarmoniuk
* @since 2.15.0
*/
-@Mojo(name = "display-extension-updates", threadSafe = true)
+@Mojo(name = "display-extension-updates", aggregator = true, threadSafe = true)
public class DisplayExtensionUpdatesMojo extends AbstractVersionsDisplayMojo {
// ------------------------------ FIELDS ------------------------------
@@ -149,6 +153,15 @@ public class DisplayExtensionUpdatesMojo extends AbstractVersionsDisplayMojo {
@Parameter(property = "processBuildExtensions", defaultValue = "true")
private boolean processBuildExtensions = true;
+ /**
+ * If set to {@code false}, the plugin will not interpolate property values when looking for versions
+ * to be changed, but will instead operate on raw model.
+ *
+ * @since 2.15.0
+ */
+ @Parameter(property = "interpolateProperties", defaultValue = "true")
+ protected boolean interpolateProperties = true;
+
/**
* Whether to show additional information such as extensions that do not need updating. Defaults to false.
*
@@ -183,12 +196,48 @@ public void execute() throws MojoExecutionException, MojoFailureException {
try {
Stream extensions;
if (processCoreExtensions) {
- extensions = CoreExtensionUtils.getCoreExtensions(session);
+ extensions = CoreExtensionUtils.getCoreExtensions(project);
} else {
extensions = Stream.empty();
}
if (processBuildExtensions) {
- extensions = Stream.concat(extensions, session.getCurrentProject().getBuildExtensions().stream());
+ if (!interpolateProperties) {
+ extensions = Stream.concat(
+ extensions,
+ PomHelper.getChildModels(session.getCurrentProject(), getLog()).values().stream()
+ .map(Model::getBuild)
+ .filter(Objects::nonNull)
+ .map(Build::getExtensions)
+ .map(List::stream)
+ .reduce(Stream::concat)
+ .orElse(Stream.empty()));
+ } else {
+ List rawModels = getRawModels();
+ for (ModelNode node : rawModels) {
+ if (node.getModel() == null) {
+ // unlikely
+ continue;
+ }
+ Map properties = new HashMap<>();
+ for (ModelNode p = node; p != null; p = p.getParent().orElse(null)) {
+ p.getModel()
+ .getProperties()
+ .forEach(
+ (key, value) -> properties.put(String.valueOf(key), String.valueOf(value)));
+ }
+ extensions = Stream.concat(
+ extensions,
+ Optional.ofNullable(node.getModel().getBuild())
+ .map(Build::getExtensions)
+ .orElse(Collections.emptyList())
+ .stream()
+ .map(e -> ExtensionBuilder.newBuilder()
+ .withGroupId(PomHelper.evaluate(e.getGroupId(), properties))
+ .withArtifactId(PomHelper.evaluate(e.getArtifactId(), properties))
+ .withVersion(PomHelper.evaluate(e.getVersion(), properties))
+ .build()));
+ }
+ }
}
dependencies = extensions
@@ -215,6 +264,21 @@ public void execute() throws MojoExecutionException, MojoFailureException {
}
}
+ private List getRawModels() throws MojoFailureException {
+ List rawModels;
+ try {
+ ModifiedPomXMLEventReader pomReader = newModifiedPomXER(
+ new StringBuilder(
+ new String(Files.readAllBytes(getProject().getFile().toPath()))),
+ getProject().getFile().toPath().toString());
+ ModelNode rootNode = new ModelNode(PomHelper.getRawModel(pomReader), pomReader);
+ rawModels = PomHelper.getRawModelTree(rootNode, getLog());
+ } catch (IOException e) {
+ throw new MojoFailureException(e.getMessage(), e);
+ }
+ return rawModels;
+ }
+
private Optional calculateUpdateScope() {
return of(SegmentUtils.determineUnchangedSegment(
allowMajorUpdates, allowMinorUpdates, allowIncrementalUpdates, getLog())
diff --git a/versions-model-core-extensions/pom.xml b/versions-model-core-extensions/pom.xml
new file mode 100644
index 0000000000..3acd01a6f4
--- /dev/null
+++ b/versions-model-core-extensions/pom.xml
@@ -0,0 +1,63 @@
+
+
+ 4.0.0
+
+ org.codehaus.mojo.versions
+ versions
+ 2.15.0-SNAPSHOT
+
+
+ versions-model-core-extensions
+ Versions Model Core Extensions
+ Model classes and parser for Core Extensions
+
+
+
+ org.codehaus.plexus
+ plexus-utils
+
+
+
+
+
+
+ org.codehaus.modello
+ modello-maven-plugin
+
+
+ src/main/mdo/core-extensions.mdo
+
+ 1.1.0
+
+
+
+ generate-java-classes
+
+ xpp3-reader
+ java
+
+ generate-sources
+
+
+ generate-site-doc
+
+ xdoc
+
+ pre-site
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-checkstyle-plugin
+
+ true
+
+
+
+
+
+
+
+
diff --git a/versions-model-core-extensions/src/main/mdo/core-extensions.mdo b/versions-model-core-extensions/src/main/mdo/core-extensions.mdo
new file mode 100644
index 0000000000..32ee24e244
--- /dev/null
+++ b/versions-model-core-extensions/src/main/mdo/core-extensions.mdo
@@ -0,0 +1,118 @@
+
+
+
+
+
+
+ core-extensions
+ CoreExtensions
+ This is a reference for the Core Extensions descriptor.
+ The default location for the Core Extensions descriptor file is ${maven.projectBasedir}/.mvn/extensions.xml
+ ]]>
+
+
+
+ package
+ org.apache.maven.cli.internal.extension.model
+
+
+
+
+
+ CoreExtensions
+ Extensions to load.
+ 1.0.0+
+
+
+ extensions
+ A set of build extensions to use from this project.
+ 1.0.0+
+
+ CoreExtension
+ *
+
+
+
+
+
+ CoreExtension
+ Describes a build extension to utilise.
+ 1.0.0+
+
+
+ groupId
+ The group ID of the extension's artifact.
+ 1.0.0+
+ true
+ String
+
+
+ artifactId
+ The artifact ID of the extension.
+ 1.0.0+
+ true
+ String
+
+
+ version
+ The version of the extension.
+ 1.0.0+
+ true
+ String
+
+
+ classLoadingStrategy
+ The class loading strategy: 'self-first' (the default), 'parent-first' (loads classes from the parent, then from the extension) or 'plugin' (follows the rules from extensions defined as plugins).
+ 1.1.0+
+ self-first
+ false
+ String
+
+
+
+
+ 1.0.0+
+
+ ::}, never {@code null}.
+ */
+ public String getId()
+ {
+ StringBuilder id = new StringBuilder( 128 );
+
+ id.append( ( getGroupId() == null ) ? "[unknown-group-id]" : getGroupId() );
+ id.append( ":" );
+ id.append( ( getArtifactId() == null ) ? "[unknown-artifact-id]" : getArtifactId() );
+ id.append( ":" );
+ id.append( ( getVersion() == null ) ? "[unknown-version]" : getVersion() );
+
+ return id.toString();
+ }
+ ]]>
+
+
+
+
+
+
diff --git a/versions-test/src/main/java/org/codehaus/mojo/versions/utils/MockUtils.java b/versions-test/src/main/java/org/codehaus/mojo/versions/utils/MockUtils.java
index f604c6f903..e08b9322ab 100644
--- a/versions-test/src/main/java/org/codehaus/mojo/versions/utils/MockUtils.java
+++ b/versions-test/src/main/java/org/codehaus/mojo/versions/utils/MockUtils.java
@@ -1,24 +1,20 @@
+package org.codehaus.mojo.versions.utils;
+
/*
- * 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
+ * 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
+ * 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.
+ * 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.codehaus.mojo.versions.utils;
-
import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;