From 2c22da0b377e146a9e746c0ebe98be976d7f2b1d Mon Sep 17 00:00:00 2001 From: Andrzej Jarmoniuk Date: Sat, 24 Dec 2022 09:00:14 +0100 Subject: [PATCH] Resolves #880: add information on property updates to the change recorder Release notes: - new version and new namespace for the change recorder - change recorder also records property changes --- .../api/change/DependencyVersionChange.java | 50 ++++++++ .../api/change/PropertyVersionChange.java | 42 +++++++ .../versions/api/change/VersionChange.java | 32 +---- .../versions/api/recording/ChangeRecord.java | 33 +---- .../api/recording/ChangeRecorder.java | 12 +- .../api/recording/DependencyChangeRecord.java | 56 +++++++++ .../api/recording/PropertyChangeRecord.java | 28 +++++ .../src/site/markdown/change-recorder.md.vm | 25 ++-- .../change/CompositeVersionChanger.java | 28 ++--- ...va => DefaultDependencyVersionChange.java} | 35 +++--- .../change/DefaultPropertyVersionChange.java | 84 +++++++++++++ .../change/DependencyVersionChanger.java | 28 ++--- .../versions/change/ParentVersionChanger.java | 28 ++--- .../versions/change/PluginVersionChanger.java | 28 ++--- .../change/ProjectVersionChanger.java | 28 ++--- .../mojo/versions/change/VersionChanger.java | 28 ++--- .../recording/ChangeRecorderNull.java | 32 ++--- .../versions/recording/ChangeRecorderXML.java | 61 +++++---- ...ava => DefaultDependencyChangeRecord.java} | 34 +++-- .../DefaultPropertyChangeRecord.java | 65 ++++++++++ .../recording/ChangeRecorderXMLTest.java | 34 +++-- .../mojo/versions/recording/expectedFile.xml | 11 +- .../verify.bsh | 22 ---- .../verify.groovy | 6 + .../verify.bsh | 21 ---- .../verify.groovy | 9 ++ .../verify.bsh | 21 ---- .../verify.groovy | 6 + .../verify.bsh | 21 ---- .../verify.groovy | 6 + .../verify.bsh | 21 ---- .../verify.groovy | 6 + .../verify.bsh | 21 ---- .../verify.groovy | 6 + ...AbstractVersionsDependencyUpdaterMojo.java | 37 +++--- .../versions/CompareDependenciesMojo.java | 37 +++--- .../mojo/versions/ForceReleasesMojo.java | 38 +++--- .../org/codehaus/mojo/versions/SetMojo.java | 32 +++-- .../mojo/versions/UnlockSnapshotsMojo.java | 42 +++---- .../mojo/versions/UpdateParentMojo.java | 32 +++-- .../versions/UpdatePropertiesMojoBase.java | 41 +++--- .../mojo/versions/UseDepVersionMojo.java | 119 ++++++++++-------- .../mojo/versions/UseLatestReleasesMojo.java | 38 +++--- .../mojo/versions/UseLatestSnapshotsMojo.java | 38 +++--- .../mojo/versions/UseLatestVersionsMojo.java | 38 +++--- .../versions/UseLatestVersionsMojoBase.java | 28 ++--- .../mojo/versions/UseNextReleasesMojo.java | 40 +++--- .../mojo/versions/UseNextSnapshotsMojo.java | 38 +++--- .../mojo/versions/UseNextVersionsMojo.java | 40 +++--- .../mojo/versions/UseReleasesMojo.java | 38 +++--- .../mojo/versions/recording/schema-2.0.xsd | 58 +++++++++ .../markdown/examples/recording-changes.md | 17 +-- .../mojo/versions/ForceReleasesMojoTest.java | 34 +++-- .../mojo/versions/UpdateParentMojoTest.java | 29 ++++- .../versions/UpdatePropertiesMojoTest.java | 34 +++-- .../mojo/versions/UpdatePropertyMojoTest.java | 37 +++--- .../mojo/versions/UseDepVersionMojoTest.java | 52 +++++--- .../versions/UseLatestReleasesMojoTest.java | 19 ++- .../versions/UseLatestVersionsMojoTest.java | 37 ++++-- .../versions/UseNextReleasesMojoTest.java | 31 +++-- .../versions/UseNextVersionsMojoTest.java | 32 +++-- .../mojo/versions/UseReleasesMojoTest.java | 30 ++--- .../versions/utils/TestChangeRecorder.java | 34 ++--- 63 files changed, 1206 insertions(+), 882 deletions(-) create mode 100644 versions-api/src/main/java/org/codehaus/mojo/versions/api/change/DependencyVersionChange.java create mode 100644 versions-api/src/main/java/org/codehaus/mojo/versions/api/change/PropertyVersionChange.java create mode 100644 versions-api/src/main/java/org/codehaus/mojo/versions/api/recording/DependencyChangeRecord.java create mode 100644 versions-api/src/main/java/org/codehaus/mojo/versions/api/recording/PropertyChangeRecord.java rename versions-common/src/main/java/org/codehaus/mojo/versions/change/{DefaultVersionChange.java => DefaultDependencyVersionChange.java} (59%) create mode 100644 versions-common/src/main/java/org/codehaus/mojo/versions/change/DefaultPropertyVersionChange.java rename versions-common/src/main/java/org/codehaus/mojo/versions/recording/{DefaultChangeRecord.java => DefaultDependencyChangeRecord.java} (59%) create mode 100644 versions-common/src/main/java/org/codehaus/mojo/versions/recording/DefaultPropertyChangeRecord.java delete mode 100644 versions-maven-plugin/src/it/it-changerecord-update-parent-001/verify.bsh create mode 100644 versions-maven-plugin/src/it/it-changerecord-update-parent-001/verify.groovy delete mode 100644 versions-maven-plugin/src/it/it-changerecord-update-properties-001/verify.bsh create mode 100644 versions-maven-plugin/src/it/it-changerecord-update-properties-001/verify.groovy delete mode 100644 versions-maven-plugin/src/it/it-changerecord-use-latest-releases-001/verify.bsh create mode 100644 versions-maven-plugin/src/it/it-changerecord-use-latest-releases-001/verify.groovy delete mode 100644 versions-maven-plugin/src/it/it-changerecord-use-latest-snapshots-001/verify.bsh create mode 100644 versions-maven-plugin/src/it/it-changerecord-use-latest-snapshots-001/verify.groovy delete mode 100644 versions-maven-plugin/src/it/it-changerecord-use-latest-versions-001/verify.bsh create mode 100644 versions-maven-plugin/src/it/it-changerecord-use-latest-versions-001/verify.groovy delete mode 100644 versions-maven-plugin/src/it/it-changerecord-use-next-versions-001/verify.bsh create mode 100644 versions-maven-plugin/src/it/it-changerecord-use-next-versions-001/verify.groovy create mode 100644 versions-maven-plugin/src/main/resources/org/codehaus/mojo/versions/recording/schema-2.0.xsd diff --git a/versions-api/src/main/java/org/codehaus/mojo/versions/api/change/DependencyVersionChange.java b/versions-api/src/main/java/org/codehaus/mojo/versions/api/change/DependencyVersionChange.java new file mode 100644 index 0000000000..f1bc107c62 --- /dev/null +++ b/versions-api/src/main/java/org/codehaus/mojo/versions/api/change/DependencyVersionChange.java @@ -0,0 +1,50 @@ +package org.codehaus.mojo.versions.api.change; + +/* + * 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. + * + */ + +/** + * Represents a change of an item's version. + * + * @author Slawomir Jaranowski + * @since 2.14.0 + */ +public interface DependencyVersionChange extends VersionChange { + /** + * @return a groupId of changed item + * @since 2.14.0 + */ + String getGroupId(); + + /** + * @return an ArtifactId of change item + * @since 2.14.0 + */ + String getArtifactId(); + + /** + * @return an old version of changed item + * @since 2.14.0 + */ + String getOldVersion(); + + /** + * @return a new version of changed item + * @since 2.14.0 + */ + String getNewVersion(); +} diff --git a/versions-api/src/main/java/org/codehaus/mojo/versions/api/change/PropertyVersionChange.java b/versions-api/src/main/java/org/codehaus/mojo/versions/api/change/PropertyVersionChange.java new file mode 100644 index 0000000000..ebe60200c1 --- /dev/null +++ b/versions-api/src/main/java/org/codehaus/mojo/versions/api/change/PropertyVersionChange.java @@ -0,0 +1,42 @@ +package org.codehaus.mojo.versions.api.change; + +/* + * 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. + * + */ + +/** + * Represents a change of a property value. + * + * @author Andrzej Jarmoniuk + * @since 2.15.0 + */ +public interface PropertyVersionChange extends VersionChange { + + /** + * @return the property that has changed + */ + String getProperty(); + + /** + * @return the old value of the property + */ + String getOldValue(); + + /** + * @return the new value of the property + */ + String getNewValue(); +} diff --git a/versions-api/src/main/java/org/codehaus/mojo/versions/api/change/VersionChange.java b/versions-api/src/main/java/org/codehaus/mojo/versions/api/change/VersionChange.java index c8b6f63216..c0718509f7 100644 --- a/versions-api/src/main/java/org/codehaus/mojo/versions/api/change/VersionChange.java +++ b/versions-api/src/main/java/org/codehaus/mojo/versions/api/change/VersionChange.java @@ -14,37 +14,9 @@ * 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. - * */ /** - * Represents a change of an item's version. - * - * @author Slawomir Jaranowski - * @since 2.14.0 + * Base class for version changes */ -public interface VersionChange { - /** - * @return a groupId of changed item - * @since 2.14.0 - */ - String getGroupId(); - - /** - * @return an ArtifactId of change item - * @since 2.14.0 - */ - String getArtifactId(); - - /** - * @return an old version of changed item - * @since 2.14.0 - */ - String getOldVersion(); - - /** - * @return a new version of changed item - * @since 2.14.0 - */ - String getNewVersion(); -} +public interface VersionChange {} diff --git a/versions-api/src/main/java/org/codehaus/mojo/versions/api/recording/ChangeRecord.java b/versions-api/src/main/java/org/codehaus/mojo/versions/api/recording/ChangeRecord.java index 9328aac507..16c2620bc3 100644 --- a/versions-api/src/main/java/org/codehaus/mojo/versions/api/recording/ChangeRecord.java +++ b/versions-api/src/main/java/org/codehaus/mojo/versions/api/recording/ChangeRecord.java @@ -24,39 +24,12 @@ * * @author Slawomir Jaranowski * @since 2.14.0 + * @param concrete {@link VersionChange} sub-interface */ -public interface ChangeRecord { - /** - * Describe where version item is updated. - */ - enum ChangeKind { - DEPENDENCY("dependency-update"), - DEPENDENCY_MANAGEMENT("dependency-management-update"), - PARENT("parent-update"), - PLUGIN("plugin-update"), - PLUGIN_MANAGEMENT("plugin-management-update"), - PROPERTY("property-update"); - - private final String label; - - ChangeKind(String label) { - this.label = label; - } - - public String getLabel() { - return label; - } - } - - /** - * @return a version item change kind - * @since 2.14.0 - */ - ChangeKind getKind(); - +public interface ChangeRecord { /** * @return a details about changed item * @since 2.14.0 */ - VersionChange getVersionChange(); + T getVersionChange(); } diff --git a/versions-api/src/main/java/org/codehaus/mojo/versions/api/recording/ChangeRecorder.java b/versions-api/src/main/java/org/codehaus/mojo/versions/api/recording/ChangeRecorder.java index 4618818250..3b23d0298c 100644 --- a/versions-api/src/main/java/org/codehaus/mojo/versions/api/recording/ChangeRecorder.java +++ b/versions-api/src/main/java/org/codehaus/mojo/versions/api/recording/ChangeRecorder.java @@ -30,10 +30,18 @@ public interface ChangeRecorder { /** * Record that a dependency was updated. * - * @param changeRecord a record described change + * @param changeRecord a dependency record described change * @since 2.14.0 */ - void recordChange(ChangeRecord changeRecord); + void recordChange(DependencyChangeRecord changeRecord); + + /** + * Record that a property was updated. + * + * @param changeRecord a property record described change + * @since 2.14.0 + */ + void recordChange(PropertyChangeRecord changeRecord); /** * Write the current set of changes to the given output path. diff --git a/versions-api/src/main/java/org/codehaus/mojo/versions/api/recording/DependencyChangeRecord.java b/versions-api/src/main/java/org/codehaus/mojo/versions/api/recording/DependencyChangeRecord.java new file mode 100644 index 0000000000..ad89aa45d4 --- /dev/null +++ b/versions-api/src/main/java/org/codehaus/mojo/versions/api/recording/DependencyChangeRecord.java @@ -0,0 +1,56 @@ +package org.codehaus.mojo.versions.api.recording; + +/* + * 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. + * + */ + +import org.codehaus.mojo.versions.api.change.DependencyVersionChange; + +/** + * Represents a change record of an item's version. + * + * @author Slawomir Jaranowski + * @since 2.14.0 + */ +public interface DependencyChangeRecord extends ChangeRecord { + /** + * Describe where version item is updated. + */ + enum ChangeKind { + DEPENDENCY("dependency-update"), + DEPENDENCY_MANAGEMENT("dependency-management-update"), + PARENT("parent-update"), + PLUGIN("plugin-update"), + PLUGIN_MANAGEMENT("plugin-management-update"), + PROPERTY("property-update"); + + private final String label; + + ChangeKind(String label) { + this.label = label; + } + + public String getLabel() { + return label; + } + } + + /** + * @return a version item change kind + * @since 2.14.0 + */ + ChangeKind getKind(); +} diff --git a/versions-api/src/main/java/org/codehaus/mojo/versions/api/recording/PropertyChangeRecord.java b/versions-api/src/main/java/org/codehaus/mojo/versions/api/recording/PropertyChangeRecord.java new file mode 100644 index 0000000000..56d3627a6a --- /dev/null +++ b/versions-api/src/main/java/org/codehaus/mojo/versions/api/recording/PropertyChangeRecord.java @@ -0,0 +1,28 @@ +package org.codehaus.mojo.versions.api.recording; + +/* + * 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. + * + */ + +import org.codehaus.mojo.versions.api.change.PropertyVersionChange; + +/** + * Represents a change record of an item's version. + * + * @author Slawomir Jaranowski + * @since 2.14.0 + */ +public interface PropertyChangeRecord extends ChangeRecord {} diff --git a/versions-api/src/site/markdown/change-recorder.md.vm b/versions-api/src/site/markdown/change-recorder.md.vm index 2b6e0b37fc..003317e9e1 100644 --- a/versions-api/src/site/markdown/change-recorder.md.vm +++ b/versions-api/src/site/markdown/change-recorder.md.vm @@ -11,26 +11,31 @@ Write code ---------- ```java +import java.io.IOException; import javax.inject.Named; import java.nio.file.Path; -import org.codehaus.mojo.versions.api.recording.ChangeRecord; +import org.codehaus.mojo.versions.api.recording.DependencyChangeRecord; +import org.codehaus.mojo.versions.api.recording.PropertyChangeRecord; import org.codehaus.mojo.versions.api.recording.ChangeRecorder; -@Named( "my-recorder" ) -public class MyChangeRecorder implements ChangeRecorder -{ +@Named("my-recorder") +public class MyChangeRecorder implements ChangeRecorder { + + @Override + public final void recordChange(DependencyChangeRecord changeRecord) { + // your code here + } + @Override - public final void recordChange( ChangeRecord changeRecord ) - { - // your code + public final void recordChange(PropertyChangeRecord changeRecord) { + // your code here } @Override - public final void writeReport( Path outputPath ) - { - // your code + public final void writeReport(Path outputPath) throws IOException { + // your code here } } ``` diff --git a/versions-common/src/main/java/org/codehaus/mojo/versions/change/CompositeVersionChanger.java b/versions-common/src/main/java/org/codehaus/mojo/versions/change/CompositeVersionChanger.java index a3ad9c0b8a..df3da76ad2 100644 --- a/versions-common/src/main/java/org/codehaus/mojo/versions/change/CompositeVersionChanger.java +++ b/versions-common/src/main/java/org/codehaus/mojo/versions/change/CompositeVersionChanger.java @@ -1,22 +1,18 @@ package org.codehaus.mojo.versions.change; /* - * 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.xml.stream.XMLStreamException; @@ -25,7 +21,7 @@ import java.util.Arrays; import java.util.List; -import org.codehaus.mojo.versions.api.change.VersionChange; +import org.codehaus.mojo.versions.api.change.DependencyVersionChange; /** * Created by IntelliJ IDEA. @@ -44,7 +40,7 @@ public CompositeVersionChanger(List composites) { this.composites = new ArrayList<>(composites); } - public void apply(VersionChange versionChange) throws XMLStreamException { + public void apply(DependencyVersionChange versionChange) throws XMLStreamException { for (VersionChanger delegate : composites) { delegate.apply(versionChange); } diff --git a/versions-common/src/main/java/org/codehaus/mojo/versions/change/DefaultVersionChange.java b/versions-common/src/main/java/org/codehaus/mojo/versions/change/DefaultDependencyVersionChange.java similarity index 59% rename from versions-common/src/main/java/org/codehaus/mojo/versions/change/DefaultVersionChange.java rename to versions-common/src/main/java/org/codehaus/mojo/versions/change/DefaultDependencyVersionChange.java index 105f67f902..60b114dd5e 100644 --- a/versions-common/src/main/java/org/codehaus/mojo/versions/change/DefaultVersionChange.java +++ b/versions-common/src/main/java/org/codehaus/mojo/versions/change/DefaultDependencyVersionChange.java @@ -1,27 +1,23 @@ package org.codehaus.mojo.versions.change; /* - * 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.Objects; -import org.codehaus.mojo.versions.api.change.VersionChange; +import org.codehaus.mojo.versions.api.change.DependencyVersionChange; /** * Represents a change of an artifact's version. @@ -29,7 +25,7 @@ * @author Stephen Connolly * @since 15-Sep-2010 14:48:10 */ -public final class DefaultVersionChange implements VersionChange { +public final class DefaultDependencyVersionChange implements DependencyVersionChange { private final String groupId; private final String artifactId; @@ -38,7 +34,7 @@ public final class DefaultVersionChange implements VersionChange { private final String newVersion; - public DefaultVersionChange(String groupId, String artifactId, String oldVersion, String newVersion) { + public DefaultDependencyVersionChange(String groupId, String artifactId, String oldVersion, String newVersion) { this.groupId = groupId; this.artifactId = artifactId; this.oldVersion = oldVersion; @@ -69,7 +65,7 @@ public boolean equals(Object o) { return false; } - DefaultVersionChange versionChange = (DefaultVersionChange) o; + DefaultDependencyVersionChange versionChange = (DefaultDependencyVersionChange) o; if (!Objects.equals(artifactId, versionChange.artifactId)) { return false; @@ -92,6 +88,7 @@ public int hashCode() { } public String toString() { - return "DefaultVersionChange(" + groupId + ':' + artifactId + ":" + oldVersion + "-->" + newVersion + ')'; + return "DefaultDependencyVersionChange(" + groupId + ':' + artifactId + ":" + oldVersion + "-->" + newVersion + + ')'; } } diff --git a/versions-common/src/main/java/org/codehaus/mojo/versions/change/DefaultPropertyVersionChange.java b/versions-common/src/main/java/org/codehaus/mojo/versions/change/DefaultPropertyVersionChange.java new file mode 100644 index 0000000000..c206860c1a --- /dev/null +++ b/versions-common/src/main/java/org/codehaus/mojo/versions/change/DefaultPropertyVersionChange.java @@ -0,0 +1,84 @@ +package org.codehaus.mojo.versions.change; + +/* + * 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. + */ + +import java.util.Objects; + +import org.codehaus.mojo.versions.api.change.PropertyVersionChange; + +/** + * Represents a change of a property value + * + * @author Andrzej Jarmoniuk + */ +public final class DefaultPropertyVersionChange implements PropertyVersionChange { + + private final String property; + + private final String oldValue; + + private final String newValue; + + public DefaultPropertyVersionChange(String property, String oldValue, String newValue) { + this.property = property; + this.oldValue = oldValue; + this.newValue = newValue; + } + + public String getProperty() { + return property; + } + + public String getOldValue() { + return oldValue; + } + + public String getNewValue() { + return newValue; + } + + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + + DefaultPropertyVersionChange versionChange = (DefaultPropertyVersionChange) o; + + if (!Objects.equals(property, versionChange.property)) { + return false; + } + if (!Objects.equals(oldValue, versionChange.oldValue)) { + return false; + } + return Objects.equals(newValue, versionChange.newValue); + } + + @SuppressWarnings("checkstyle:MagicNumber") + public int hashCode() { + int result = property != null ? property.hashCode() : 0; + result = 7 * result + (oldValue != null ? oldValue.hashCode() : 0); + result = 31 * result + (newValue != null ? newValue.hashCode() : 0); + return result; + } + + public String toString() { + return "DefaultPropertyVersionChange(" + property + ':' + oldValue + "-->" + newValue + ')'; + } +} diff --git a/versions-common/src/main/java/org/codehaus/mojo/versions/change/DependencyVersionChanger.java b/versions-common/src/main/java/org/codehaus/mojo/versions/change/DependencyVersionChanger.java index 9995d47fce..5375de50b1 100644 --- a/versions-common/src/main/java/org/codehaus/mojo/versions/change/DependencyVersionChanger.java +++ b/versions-common/src/main/java/org/codehaus/mojo/versions/change/DependencyVersionChanger.java @@ -1,22 +1,18 @@ package org.codehaus.mojo.versions.change; /* - * 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.xml.stream.XMLStreamException; @@ -24,7 +20,7 @@ import org.apache.maven.model.Model; import org.apache.maven.plugin.logging.Log; import org.codehaus.mojo.versions.api.PomHelper; -import org.codehaus.mojo.versions.api.change.VersionChange; +import org.codehaus.mojo.versions.api.change.DependencyVersionChange; import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader; /** @@ -39,7 +35,7 @@ public DependencyVersionChanger(Model model, ModifiedPomXMLEventReader pom, Log super(model, pom, reporter); } - public void apply(VersionChange versionChange) throws XMLStreamException { + public void apply(DependencyVersionChange versionChange) throws XMLStreamException { if (PomHelper.setDependencyVersion( getPom(), versionChange.getGroupId(), diff --git a/versions-common/src/main/java/org/codehaus/mojo/versions/change/ParentVersionChanger.java b/versions-common/src/main/java/org/codehaus/mojo/versions/change/ParentVersionChanger.java index fea98f8649..a723ae62cd 100644 --- a/versions-common/src/main/java/org/codehaus/mojo/versions/change/ParentVersionChanger.java +++ b/versions-common/src/main/java/org/codehaus/mojo/versions/change/ParentVersionChanger.java @@ -1,22 +1,18 @@ package org.codehaus.mojo.versions.change; /* - * 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.xml.stream.XMLStreamException; @@ -24,7 +20,7 @@ import org.apache.maven.model.Model; import org.apache.maven.plugin.logging.Log; import org.codehaus.mojo.versions.api.PomHelper; -import org.codehaus.mojo.versions.api.change.VersionChange; +import org.codehaus.mojo.versions.api.change.DependencyVersionChange; import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader; /** @@ -36,7 +32,7 @@ public ParentVersionChanger(Model model, ModifiedPomXMLEventReader pom, Log repo super(model, pom, reporter); } - public void apply(VersionChange versionChange) throws XMLStreamException { + public void apply(DependencyVersionChange versionChange) throws XMLStreamException { if (getModel().getParent() != null && versionChange.getGroupId().equals(getModel().getParent().getGroupId()) && versionChange.getArtifactId().equals(getModel().getParent().getArtifactId())) { diff --git a/versions-common/src/main/java/org/codehaus/mojo/versions/change/PluginVersionChanger.java b/versions-common/src/main/java/org/codehaus/mojo/versions/change/PluginVersionChanger.java index 279fee78dd..ac3f1b60d0 100644 --- a/versions-common/src/main/java/org/codehaus/mojo/versions/change/PluginVersionChanger.java +++ b/versions-common/src/main/java/org/codehaus/mojo/versions/change/PluginVersionChanger.java @@ -1,22 +1,18 @@ package org.codehaus.mojo.versions.change; /* - * 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.xml.stream.XMLStreamException; @@ -24,7 +20,7 @@ import org.apache.maven.model.Model; import org.apache.maven.plugin.logging.Log; import org.codehaus.mojo.versions.api.PomHelper; -import org.codehaus.mojo.versions.api.change.VersionChange; +import org.codehaus.mojo.versions.api.change.DependencyVersionChange; import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader; /** @@ -39,7 +35,7 @@ public PluginVersionChanger(Model model, ModifiedPomXMLEventReader pom, Log repo super(model, pom, reporter); } - public void apply(VersionChange versionChange) throws XMLStreamException { + public void apply(DependencyVersionChange versionChange) throws XMLStreamException { if (PomHelper.setPluginVersion( getPom(), versionChange.getGroupId(), diff --git a/versions-common/src/main/java/org/codehaus/mojo/versions/change/ProjectVersionChanger.java b/versions-common/src/main/java/org/codehaus/mojo/versions/change/ProjectVersionChanger.java index f75013251e..e9e21b16a1 100644 --- a/versions-common/src/main/java/org/codehaus/mojo/versions/change/ProjectVersionChanger.java +++ b/versions-common/src/main/java/org/codehaus/mojo/versions/change/ProjectVersionChanger.java @@ -1,22 +1,18 @@ package org.codehaus.mojo.versions.change; /* - * 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.xml.stream.XMLStreamException; @@ -24,7 +20,7 @@ import org.apache.maven.model.Model; import org.apache.maven.plugin.logging.Log; import org.codehaus.mojo.versions.api.PomHelper; -import org.codehaus.mojo.versions.api.change.VersionChange; +import org.codehaus.mojo.versions.api.change.DependencyVersionChange; import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader; /** @@ -39,7 +35,7 @@ public ProjectVersionChanger(Model model, ModifiedPomXMLEventReader pom, Log rep super(model, pom, reporter); } - public void apply(VersionChange versionChange) throws XMLStreamException { + public void apply(DependencyVersionChange versionChange) throws XMLStreamException { if (versionChange.getGroupId().equals(PomHelper.getGroupId(getModel())) && versionChange.getArtifactId().equals(PomHelper.getArtifactId(getModel()))) { if (PomHelper.setProjectVersion(getPom(), versionChange.getNewVersion())) { diff --git a/versions-common/src/main/java/org/codehaus/mojo/versions/change/VersionChanger.java b/versions-common/src/main/java/org/codehaus/mojo/versions/change/VersionChanger.java index b2a91a68f1..5a5b87f1ca 100644 --- a/versions-common/src/main/java/org/codehaus/mojo/versions/change/VersionChanger.java +++ b/versions-common/src/main/java/org/codehaus/mojo/versions/change/VersionChanger.java @@ -1,27 +1,23 @@ package org.codehaus.mojo.versions.change; /* - * 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.xml.stream.XMLStreamException; -import org.codehaus.mojo.versions.api.change.VersionChange; +import org.codehaus.mojo.versions.api.change.DependencyVersionChange; /** * Created by IntelliJ IDEA. @@ -30,5 +26,5 @@ * @since 15-Sep-2010 15:59:00 */ public interface VersionChanger { - void apply(VersionChange versionChange) throws XMLStreamException; + void apply(DependencyVersionChange versionChange) throws XMLStreamException; } diff --git a/versions-common/src/main/java/org/codehaus/mojo/versions/recording/ChangeRecorderNull.java b/versions-common/src/main/java/org/codehaus/mojo/versions/recording/ChangeRecorderNull.java index d53025b4ef..f2c9b09281 100644 --- a/versions-common/src/main/java/org/codehaus/mojo/versions/recording/ChangeRecorderNull.java +++ b/versions-common/src/main/java/org/codehaus/mojo/versions/recording/ChangeRecorderNull.java @@ -1,30 +1,27 @@ package org.codehaus.mojo.versions.recording; /* - * 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.Named; import java.nio.file.Path; -import org.codehaus.mojo.versions.api.recording.ChangeRecord; import org.codehaus.mojo.versions.api.recording.ChangeRecorder; +import org.codehaus.mojo.versions.api.recording.DependencyChangeRecord; +import org.codehaus.mojo.versions.api.recording.PropertyChangeRecord; /** * A recorder that ignores updates. @@ -37,7 +34,10 @@ public class ChangeRecorderNull implements ChangeRecorder { public ChangeRecorderNull() {} @Override - public final void recordChange(ChangeRecord changeRecord) {} + public final void recordChange(PropertyChangeRecord changeRecord) {} + + @Override + public final void recordChange(DependencyChangeRecord changeRecord) {} @Override public final void writeReport(final Path outputPath) {} diff --git a/versions-common/src/main/java/org/codehaus/mojo/versions/recording/ChangeRecorderXML.java b/versions-common/src/main/java/org/codehaus/mojo/versions/recording/ChangeRecorderXML.java index b924a5dcbc..c01b50d097 100644 --- a/versions-common/src/main/java/org/codehaus/mojo/versions/recording/ChangeRecorderXML.java +++ b/versions-common/src/main/java/org/codehaus/mojo/versions/recording/ChangeRecorderXML.java @@ -1,22 +1,18 @@ package org.codehaus.mojo.versions.recording; /* - * 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.Named; @@ -36,8 +32,11 @@ import java.nio.file.Files; import java.nio.file.Path; -import org.codehaus.mojo.versions.api.recording.ChangeRecord; +import org.codehaus.mojo.versions.api.change.DependencyVersionChange; +import org.codehaus.mojo.versions.api.change.PropertyVersionChange; import org.codehaus.mojo.versions.api.recording.ChangeRecorder; +import org.codehaus.mojo.versions.api.recording.DependencyChangeRecord; +import org.codehaus.mojo.versions.api.recording.PropertyChangeRecord; import org.w3c.dom.DOMException; import org.w3c.dom.Document; import org.w3c.dom.Element; @@ -54,7 +53,7 @@ public class ChangeRecorderXML implements ChangeRecorder { /** * The XML namespace used for serialized changes. */ - public static final String CHANGES_NAMESPACE = "http://www.mojohaus.org/versions-maven-plugin/schema/updates/1.0"; + public static final String CHANGES_NAMESPACE = "http://www.mojohaus.org/versions-maven-plugin/schema/updates/2.0"; private final Document document; private final Element root; @@ -75,13 +74,29 @@ public ChangeRecorderXML() { } @Override - public final void recordChange(ChangeRecord changeRecord) { - final Element update = this.document.createElementNS(CHANGES_NAMESPACE, "update"); - update.setAttribute("kind", changeRecord.getKind().getLabel()); - update.setAttribute("groupId", changeRecord.getVersionChange().getGroupId()); - update.setAttribute("artifactId", changeRecord.getVersionChange().getArtifactId()); - update.setAttribute("oldVersion", changeRecord.getVersionChange().getOldVersion()); - update.setAttribute("newVersion", changeRecord.getVersionChange().getNewVersion()); + public final void recordChange(DependencyChangeRecord changeRecord) { + Element update; + update = this.document.createElementNS(CHANGES_NAMESPACE, "dependencyUpdate"); + update.setAttribute( + "kind", ((DependencyChangeRecord) changeRecord).getKind().getLabel()); + DependencyVersionChange change = (DependencyVersionChange) changeRecord.getVersionChange(); + update.setAttribute("groupId", change.getGroupId()); + update.setAttribute("artifactId", change.getArtifactId()); + update.setAttribute("oldVersion", change.getOldVersion()); + update.setAttribute("newVersion", change.getNewVersion()); + + this.root.appendChild(update); + } + + @Override + public final void recordChange(PropertyChangeRecord changeRecord) { + Element update; + update = this.document.createElementNS(CHANGES_NAMESPACE, "propertyUpdate"); + PropertyVersionChange change = (PropertyVersionChange) changeRecord.getVersionChange(); + update.setAttribute("property", change.getProperty()); + update.setAttribute("oldValue", change.getOldValue()); + update.setAttribute("newValue", change.getNewValue()); + this.root.appendChild(update); } diff --git a/versions-common/src/main/java/org/codehaus/mojo/versions/recording/DefaultChangeRecord.java b/versions-common/src/main/java/org/codehaus/mojo/versions/recording/DefaultDependencyChangeRecord.java similarity index 59% rename from versions-common/src/main/java/org/codehaus/mojo/versions/recording/DefaultChangeRecord.java rename to versions-common/src/main/java/org/codehaus/mojo/versions/recording/DefaultDependencyChangeRecord.java index 8334415fe7..330982c5a8 100644 --- a/versions-common/src/main/java/org/codehaus/mojo/versions/recording/DefaultChangeRecord.java +++ b/versions-common/src/main/java/org/codehaus/mojo/versions/recording/DefaultDependencyChangeRecord.java @@ -1,18 +1,33 @@ package org.codehaus.mojo.versions.recording; +/* + * 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. + */ + import java.util.Objects; import org.apache.maven.artifact.Artifact; import org.apache.maven.model.Dependency; -import org.codehaus.mojo.versions.api.change.VersionChange; -import org.codehaus.mojo.versions.api.recording.ChangeRecord; -import org.codehaus.mojo.versions.change.DefaultVersionChange; +import org.codehaus.mojo.versions.api.change.DependencyVersionChange; +import org.codehaus.mojo.versions.api.recording.DependencyChangeRecord; +import org.codehaus.mojo.versions.change.DefaultDependencyVersionChange; -public class DefaultChangeRecord implements ChangeRecord { +public class DefaultDependencyChangeRecord implements DependencyChangeRecord { private final ChangeKind kind; - private final VersionChange versionChange; + private final DependencyVersionChange versionChange; - private DefaultChangeRecord(ChangeKind kind, VersionChange versionChange) { + private DefaultDependencyChangeRecord(ChangeKind kind, DependencyVersionChange versionChange) { this.kind = Objects.requireNonNull(kind, "kind must not be null"); this.versionChange = Objects.requireNonNull(versionChange, "versionChange must not be null"); } @@ -23,7 +38,7 @@ public ChangeKind getKind() { } @Override - public VersionChange getVersionChange() { + public DependencyVersionChange getVersionChange() { return versionChange; } @@ -78,8 +93,9 @@ public Builder withArtifact(Artifact artifact) { return this; } - public ChangeRecord build() { - return new DefaultChangeRecord(kind, new DefaultVersionChange(groupId, artifactId, oldVersion, newVersion)); + public DependencyChangeRecord build() { + return new DefaultDependencyChangeRecord( + kind, new DefaultDependencyVersionChange(groupId, artifactId, oldVersion, newVersion)); } } } diff --git a/versions-common/src/main/java/org/codehaus/mojo/versions/recording/DefaultPropertyChangeRecord.java b/versions-common/src/main/java/org/codehaus/mojo/versions/recording/DefaultPropertyChangeRecord.java new file mode 100644 index 0000000000..4b8eae61f7 --- /dev/null +++ b/versions-common/src/main/java/org/codehaus/mojo/versions/recording/DefaultPropertyChangeRecord.java @@ -0,0 +1,65 @@ +package org.codehaus.mojo.versions.recording; + +/* + * 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. + */ + +import java.util.Objects; + +import org.codehaus.mojo.versions.api.change.PropertyVersionChange; +import org.codehaus.mojo.versions.api.recording.PropertyChangeRecord; +import org.codehaus.mojo.versions.change.DefaultPropertyVersionChange; + +public class DefaultPropertyChangeRecord implements PropertyChangeRecord { + private final PropertyVersionChange versionChange; + + private DefaultPropertyChangeRecord(PropertyVersionChange versionChange) { + this.versionChange = Objects.requireNonNull(versionChange, "versionChange must not be null"); + } + + @Override + public PropertyVersionChange getVersionChange() { + return versionChange; + } + + public static Builder builder() { + return new Builder(); + } + + public static class Builder { + private String property; + private String oldValue; + private String newValue; + + public Builder withProperty(String property) { + this.property = property; + return this; + } + + public Builder withOldValue(String oldValue) { + this.oldValue = oldValue; + return this; + } + + public Builder withNewValue(String newValue) { + this.newValue = newValue; + return this; + } + + public PropertyChangeRecord build() { + return new DefaultPropertyChangeRecord(new DefaultPropertyVersionChange(property, oldValue, newValue)); + } + } +} diff --git a/versions-common/src/test/java/org/codehaus/mojo/versions/recording/ChangeRecorderXMLTest.java b/versions-common/src/test/java/org/codehaus/mojo/versions/recording/ChangeRecorderXMLTest.java index 7d49e2bcd6..63df10c2a9 100644 --- a/versions-common/src/test/java/org/codehaus/mojo/versions/recording/ChangeRecorderXMLTest.java +++ b/versions-common/src/test/java/org/codehaus/mojo/versions/recording/ChangeRecorderXMLTest.java @@ -1,22 +1,18 @@ package org.codehaus.mojo.versions.recording; /* - * 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.xml.parsers.DocumentBuilder; @@ -29,8 +25,8 @@ import java.nio.file.Path; import java.nio.file.StandardCopyOption; -import org.codehaus.mojo.versions.api.recording.ChangeRecord; import org.codehaus.mojo.versions.api.recording.ChangeRecorder; +import org.codehaus.mojo.versions.api.recording.DependencyChangeRecord; import org.junit.Assert; import org.junit.Test; import org.w3c.dom.Document; @@ -61,16 +57,16 @@ public void testChanges() throws Exception { copyResource("expectedFile.xml", path0); final ChangeRecorder recorder = new ChangeRecorderXML(); - recorder.recordChange(DefaultChangeRecord.builder() - .withKind(ChangeRecord.ChangeKind.DEPENDENCY) + recorder.recordChange(DefaultDependencyChangeRecord.builder() + .withKind(DependencyChangeRecord.ChangeKind.DEPENDENCY) .withGroupId("org.codehaus") .withArtifactId("example0") .withOldVersion("0.0.1") .withNewVersion("0.0.2") .build()); - recorder.recordChange(DefaultChangeRecord.builder() - .withKind(ChangeRecord.ChangeKind.DEPENDENCY_MANAGEMENT) + recorder.recordChange(DefaultDependencyChangeRecord.builder() + .withKind(DependencyChangeRecord.ChangeKind.DEPENDENCY_MANAGEMENT) .withGroupId("org.codehaus") .withArtifactId("example1") .withOldVersion("1.0.0") diff --git a/versions-common/src/test/resources/org/codehaus/mojo/versions/recording/expectedFile.xml b/versions-common/src/test/resources/org/codehaus/mojo/versions/recording/expectedFile.xml index 868b406073..0522410e05 100644 --- a/versions-common/src/test/resources/org/codehaus/mojo/versions/recording/expectedFile.xml +++ b/versions-common/src/test/resources/org/codehaus/mojo/versions/recording/expectedFile.xml @@ -1,6 +1,5 @@ - - - - - - \ No newline at end of file + + + + + \ No newline at end of file diff --git a/versions-maven-plugin/src/it/it-changerecord-update-parent-001/verify.bsh b/versions-maven-plugin/src/it/it-changerecord-update-parent-001/verify.bsh deleted file mode 100644 index 296bf76ed6..0000000000 --- a/versions-maven-plugin/src/it/it-changerecord-update-parent-001/verify.bsh +++ /dev/null @@ -1,22 +0,0 @@ -import java.io.*; -import java.util.regex.*; -import org.codehaus.plexus.util.FileUtils; - -try -{ - File file = new File( basedir, "target/versions-changes.xml" ); - String buf = FileUtils.fileRead( file, "UTF-8" ); - - if ( buf.indexOf( "" ) < 0 ) - { - System.err.println( "Version change recorded" ); - return false; - } -} -catch( Throwable t ) -{ - t.printStackTrace(); - return false; -} - -return true; diff --git a/versions-maven-plugin/src/it/it-changerecord-update-parent-001/verify.groovy b/versions-maven-plugin/src/it/it-changerecord-update-parent-001/verify.groovy new file mode 100644 index 0000000000..abe5e2419c --- /dev/null +++ b/versions-maven-plugin/src/it/it-changerecord-update-parent-001/verify.groovy @@ -0,0 +1,6 @@ +def changes = new XmlSlurper().parse( new File( basedir, 'target/versions-changes.xml' ) ) +assert changes.dependencyUpdate.find { node -> node.@kind == 'parent-update' + && node.@groupId == 'localhost' + && node.@artifactId == 'dummy-parent' + && node.@oldVersion == '1.0' + && node.@newVersion == '3.0' } != null diff --git a/versions-maven-plugin/src/it/it-changerecord-update-properties-001/verify.bsh b/versions-maven-plugin/src/it/it-changerecord-update-properties-001/verify.bsh deleted file mode 100644 index d0cedff849..0000000000 --- a/versions-maven-plugin/src/it/it-changerecord-update-properties-001/verify.bsh +++ /dev/null @@ -1,21 +0,0 @@ -import java.io.*; -import org.codehaus.plexus.util.FileUtils; - -try -{ - File file = new File( basedir, "target/versions-changes.xml" ); - String buf = FileUtils.fileRead( file, "UTF-8" ); - - if ( buf.indexOf( "" ) < 0 ) - { - System.err.println( "Version change recorded" ); - return false; - } -} -catch( Throwable t ) -{ - t.printStackTrace(); - return false; -} - -return true; diff --git a/versions-maven-plugin/src/it/it-changerecord-update-properties-001/verify.groovy b/versions-maven-plugin/src/it/it-changerecord-update-properties-001/verify.groovy new file mode 100644 index 0000000000..3dc23878fc --- /dev/null +++ b/versions-maven-plugin/src/it/it-changerecord-update-properties-001/verify.groovy @@ -0,0 +1,9 @@ +def changes = new XmlSlurper().parse( new File( basedir, 'target/versions-changes.xml' ) ) +assert changes.dependencyUpdate.find { node -> node.@kind == 'property-update' + && node.@groupId == 'localhost' + && node.@artifactId == 'dummy-api' + && node.@oldVersion == '1.0' + && node.@newVersion == '3.0' } != null +assert changes.propertyUpdate.find { node -> node.@property == 'api' + && node.@oldValue == '1.0' + && node.@newValue == '3.0' } != null diff --git a/versions-maven-plugin/src/it/it-changerecord-use-latest-releases-001/verify.bsh b/versions-maven-plugin/src/it/it-changerecord-use-latest-releases-001/verify.bsh deleted file mode 100644 index 80f6400beb..0000000000 --- a/versions-maven-plugin/src/it/it-changerecord-use-latest-releases-001/verify.bsh +++ /dev/null @@ -1,21 +0,0 @@ -import java.io.*; -import org.codehaus.plexus.util.FileUtils; - -try -{ - File file = new File( basedir, "target/versions-changes.xml" ); - String buf = FileUtils.fileRead( file, "UTF-8" ); - - if ( buf.indexOf( "" ) < 0 ) - { - System.err.println( "Version change recorded" ); - return false; - } -} -catch( Throwable t ) -{ - t.printStackTrace(); - return false; -} - -return true; diff --git a/versions-maven-plugin/src/it/it-changerecord-use-latest-releases-001/verify.groovy b/versions-maven-plugin/src/it/it-changerecord-use-latest-releases-001/verify.groovy new file mode 100644 index 0000000000..01818e5e4f --- /dev/null +++ b/versions-maven-plugin/src/it/it-changerecord-use-latest-releases-001/verify.groovy @@ -0,0 +1,6 @@ +def changes = new XmlSlurper().parse( new File( basedir, 'target/versions-changes.xml' ) ) +assert changes.dependencyUpdate.find { node -> node.@kind == 'dependency-update' + && node.@groupId == 'localhost' + && node.@artifactId == 'dummy-api' + && node.@oldVersion == '1.1.1-2' + && node.@newVersion == '3.0' } != null diff --git a/versions-maven-plugin/src/it/it-changerecord-use-latest-snapshots-001/verify.bsh b/versions-maven-plugin/src/it/it-changerecord-use-latest-snapshots-001/verify.bsh deleted file mode 100644 index 6aa68bf4f7..0000000000 --- a/versions-maven-plugin/src/it/it-changerecord-use-latest-snapshots-001/verify.bsh +++ /dev/null @@ -1,21 +0,0 @@ -import java.io.*; -import org.codehaus.plexus.util.FileUtils; - -try -{ - File file = new File( basedir, "target/versions-changes.xml" ); - String buf = FileUtils.fileRead( file, "UTF-8" ); - - if ( buf.indexOf( "" ) < 0 ) - { - System.err.println( "Version change recorded" ); - return false; - } -} -catch( Throwable t ) -{ - t.printStackTrace(); - return false; -} - -return true; diff --git a/versions-maven-plugin/src/it/it-changerecord-use-latest-snapshots-001/verify.groovy b/versions-maven-plugin/src/it/it-changerecord-use-latest-snapshots-001/verify.groovy new file mode 100644 index 0000000000..4531595213 --- /dev/null +++ b/versions-maven-plugin/src/it/it-changerecord-use-latest-snapshots-001/verify.groovy @@ -0,0 +1,6 @@ +def changes = new XmlSlurper().parse( new File( basedir, 'target/versions-changes.xml' ) ) +assert changes.dependencyUpdate.find { node -> node.@kind == 'dependency-update' + && node.@groupId == 'localhost' + && node.@artifactId == 'dummy-api' + && node.@oldVersion == '1.0' + && node.@newVersion == '1.9.1-SNAPSHOT' } != null diff --git a/versions-maven-plugin/src/it/it-changerecord-use-latest-versions-001/verify.bsh b/versions-maven-plugin/src/it/it-changerecord-use-latest-versions-001/verify.bsh deleted file mode 100644 index 80f6400beb..0000000000 --- a/versions-maven-plugin/src/it/it-changerecord-use-latest-versions-001/verify.bsh +++ /dev/null @@ -1,21 +0,0 @@ -import java.io.*; -import org.codehaus.plexus.util.FileUtils; - -try -{ - File file = new File( basedir, "target/versions-changes.xml" ); - String buf = FileUtils.fileRead( file, "UTF-8" ); - - if ( buf.indexOf( "" ) < 0 ) - { - System.err.println( "Version change recorded" ); - return false; - } -} -catch( Throwable t ) -{ - t.printStackTrace(); - return false; -} - -return true; diff --git a/versions-maven-plugin/src/it/it-changerecord-use-latest-versions-001/verify.groovy b/versions-maven-plugin/src/it/it-changerecord-use-latest-versions-001/verify.groovy new file mode 100644 index 0000000000..01818e5e4f --- /dev/null +++ b/versions-maven-plugin/src/it/it-changerecord-use-latest-versions-001/verify.groovy @@ -0,0 +1,6 @@ +def changes = new XmlSlurper().parse( new File( basedir, 'target/versions-changes.xml' ) ) +assert changes.dependencyUpdate.find { node -> node.@kind == 'dependency-update' + && node.@groupId == 'localhost' + && node.@artifactId == 'dummy-api' + && node.@oldVersion == '1.1.1-2' + && node.@newVersion == '3.0' } != null diff --git a/versions-maven-plugin/src/it/it-changerecord-use-next-versions-001/verify.bsh b/versions-maven-plugin/src/it/it-changerecord-use-next-versions-001/verify.bsh deleted file mode 100644 index 3775f4ca4d..0000000000 --- a/versions-maven-plugin/src/it/it-changerecord-use-next-versions-001/verify.bsh +++ /dev/null @@ -1,21 +0,0 @@ -import java.io.*; -import org.codehaus.plexus.util.FileUtils; - -try -{ - File file = new File( basedir, "target/versions-changes.xml" ); - String buf = FileUtils.fileRead( file, "UTF-8" ); - - if ( buf.indexOf( "" ) < 0 ) - { - System.err.println( "Version change recorded" ); - return false; - } -} -catch( Throwable t ) -{ - t.printStackTrace(); - return false; -} - -return true; diff --git a/versions-maven-plugin/src/it/it-changerecord-use-next-versions-001/verify.groovy b/versions-maven-plugin/src/it/it-changerecord-use-next-versions-001/verify.groovy new file mode 100644 index 0000000000..a8c0893984 --- /dev/null +++ b/versions-maven-plugin/src/it/it-changerecord-use-next-versions-001/verify.groovy @@ -0,0 +1,6 @@ +def changes = new XmlSlurper().parse( new File( basedir, 'target/versions-changes.xml' ) ) +assert changes.dependencyUpdate.find { node -> node.@kind == 'dependency-update' + && node.@groupId == 'localhost' + && node.@artifactId == 'dummy-api' + && node.@oldVersion == '1.1.1-2' + && node.@newVersion == '1.1.2' } != null diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/AbstractVersionsDependencyUpdaterMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/AbstractVersionsDependencyUpdaterMojo.java index dd27032b9b..a04533900a 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/AbstractVersionsDependencyUpdaterMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/AbstractVersionsDependencyUpdaterMojo.java @@ -1,22 +1,18 @@ 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; @@ -42,9 +38,9 @@ import org.apache.maven.shared.artifact.filter.PatternIncludesArtifactFilter; import org.apache.maven.wagon.Wagon; import org.codehaus.mojo.versions.api.PomHelper; -import org.codehaus.mojo.versions.api.recording.ChangeRecord; import org.codehaus.mojo.versions.api.recording.ChangeRecorder; -import org.codehaus.mojo.versions.recording.DefaultChangeRecord; +import org.codehaus.mojo.versions.api.recording.DependencyChangeRecord; +import org.codehaus.mojo.versions.recording.DefaultDependencyChangeRecord; import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader; import org.codehaus.mojo.versions.utils.DependencyBuilder; import org.codehaus.mojo.versions.utils.DependencyComparator; @@ -483,7 +479,10 @@ private int findFirstChar(final String includeString, final String chars) { * @throws XMLStreamException thrown if updating the XML doesn't succeed */ protected boolean updateDependencyVersion( - ModifiedPomXMLEventReader pom, Dependency dep, String newVersion, ChangeRecord.ChangeKind changeKind) + ModifiedPomXMLEventReader pom, + Dependency dep, + String newVersion, + DependencyChangeRecord.ChangeKind changeKind) throws XMLStreamException, MojoExecutionException { boolean updated = false; if (isProcessingParent() @@ -504,7 +503,7 @@ && getProject().getParent() != null getLog().debug("Made parent update from " + dep.getVersion() + " to " + newVersion); } getChangeRecorder() - .recordChange(DefaultChangeRecord.builder() + .recordChange(DefaultDependencyChangeRecord.builder() .withKind(changeKind) .withDependency(dep) .withNewVersion(newVersion) @@ -523,7 +522,7 @@ && getProject().getParent() != null getLog().info("Updated " + toString(dep) + " to version " + newVersion); } getChangeRecorder() - .recordChange(DefaultChangeRecord.builder() + .recordChange(DefaultDependencyChangeRecord.builder() .withKind(changeKind) .withDependency(dep) .withNewVersion(newVersion) diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/CompareDependenciesMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/CompareDependenciesMojo.java index 13fb201ee2..53e92aa472 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/CompareDependenciesMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/CompareDependenciesMojo.java @@ -1,22 +1,18 @@ 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; @@ -49,8 +45,8 @@ import org.codehaus.mojo.versions.api.Property; import org.codehaus.mojo.versions.api.PropertyVersions; import org.codehaus.mojo.versions.api.VersionsHelper; -import org.codehaus.mojo.versions.api.recording.ChangeRecord; import org.codehaus.mojo.versions.api.recording.ChangeRecorder; +import org.codehaus.mojo.versions.api.recording.DependencyChangeRecord; import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader; import org.codehaus.mojo.versions.utils.DependencyBuilder; @@ -187,11 +183,11 @@ protected void update(ModifiedPomXMLEventReader pom) pom, getProject().getDependencyManagement().getDependencies(), remoteDepsMap, - ChangeRecord.ChangeKind.DEPENDENCY_MANAGEMENT)); + DependencyChangeRecord.ChangeKind.DEPENDENCY_MANAGEMENT)); } if (getProject().getDependencies() != null && isProcessingDependencies()) { totalDiffs.addAll(compareVersions( - pom, getProject().getDependencies(), remoteDepsMap, ChangeRecord.ChangeKind.DEPENDENCY)); + pom, getProject().getDependencies(), remoteDepsMap, DependencyChangeRecord.ChangeKind.DEPENDENCY)); } if (updatePropertyVersions) { Map versionProperties = this.getHelper() @@ -214,7 +210,10 @@ protected void update(ModifiedPomXMLEventReader pom) } remoteDepsMap.putIfAbsent(parent.getManagementKey(), parent); totalDiffs.addAll(compareVersions( - pom, singletonList(getParentDependency()), remoteDepsMap, ChangeRecord.ChangeKind.PARENT)); + pom, + singletonList(getParentDependency()), + remoteDepsMap, + DependencyChangeRecord.ChangeKind.PARENT)); } if (reportMode) { @@ -282,7 +281,7 @@ private List compareVersions( ModifiedPomXMLEventReader pom, List dependencies, Map remoteDependencies, - ChangeRecord.ChangeKind changeKind) + DependencyChangeRecord.ChangeKind changeKind) throws MojoExecutionException, XMLStreamException { List updates = new ArrayList<>(); for (Dependency dep : dependencies) { diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/ForceReleasesMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/ForceReleasesMojo.java index 2bdb0f298d..9586923a61 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/ForceReleasesMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/ForceReleasesMojo.java @@ -1,22 +1,18 @@ 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; @@ -41,8 +37,8 @@ import org.codehaus.mojo.versions.api.ArtifactVersions; import org.codehaus.mojo.versions.api.PomHelper; import org.codehaus.mojo.versions.api.VersionRetrievalException; -import org.codehaus.mojo.versions.api.recording.ChangeRecord; import org.codehaus.mojo.versions.api.recording.ChangeRecorder; +import org.codehaus.mojo.versions.api.recording.DependencyChangeRecord; import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader; import static java.util.Collections.singletonList; @@ -89,14 +85,16 @@ protected void update(ModifiedPomXMLEventReader pom) PomHelper.getRawModel(getProject()).getDependencyManagement(); if (dependencyManagement != null) { useReleases( - pom, dependencyManagement.getDependencies(), ChangeRecord.ChangeKind.DEPENDENCY_MANAGEMENT); + pom, + dependencyManagement.getDependencies(), + DependencyChangeRecord.ChangeKind.DEPENDENCY_MANAGEMENT); } } if (getProject().getDependencies() != null && isProcessingDependencies()) { - useReleases(pom, getProject().getDependencies(), ChangeRecord.ChangeKind.DEPENDENCY); + useReleases(pom, getProject().getDependencies(), DependencyChangeRecord.ChangeKind.DEPENDENCY); } if (getProject().getParent() != null && isProcessingParent()) { - useReleases(pom, singletonList(getParentDependency()), ChangeRecord.ChangeKind.PARENT); + useReleases(pom, singletonList(getParentDependency()), DependencyChangeRecord.ChangeKind.PARENT); } } catch (IOException e) { throw new MojoExecutionException(e.getMessage(), e); @@ -104,7 +102,9 @@ protected void update(ModifiedPomXMLEventReader pom) } private void useReleases( - ModifiedPomXMLEventReader pom, Collection dependencies, ChangeRecord.ChangeKind changeKind) + ModifiedPomXMLEventReader pom, + Collection dependencies, + DependencyChangeRecord.ChangeKind changeKind) throws XMLStreamException, MojoExecutionException, VersionRetrievalException { for (Dependency dep : dependencies) { if (isExcludeReactor() && isProducedByReactor(dep)) { diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/SetMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/SetMojo.java index c4bdc8eafb..4ae1df5267 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/SetMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/SetMojo.java @@ -1,22 +1,18 @@ 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; @@ -54,7 +50,7 @@ import org.apache.maven.wagon.Wagon; import org.codehaus.mojo.versions.api.PomHelper; import org.codehaus.mojo.versions.api.recording.ChangeRecorder; -import org.codehaus.mojo.versions.change.DefaultVersionChange; +import org.codehaus.mojo.versions.change.DefaultDependencyVersionChange; import org.codehaus.mojo.versions.change.VersionChanger; import org.codehaus.mojo.versions.change.VersionChangerFactory; import org.codehaus.mojo.versions.ordering.ReactorDepthComparator; @@ -242,7 +238,7 @@ public class SetMojo extends AbstractVersionsUpdaterMojo { /** * The changes to module coordinates. Guarded by this. */ - private final transient List sourceChanges = new ArrayList<>(); + private final transient List sourceChanges = new ArrayList<>(); /** * The (injected) instance of {@link ProjectBuilder} @@ -275,7 +271,7 @@ public SetMojo( private synchronized void addChange(String groupId, String artifactId, String oldVersion, String newVersion) { if (!newVersion.equals(oldVersion)) { - sourceChanges.add(new DefaultVersionChange(groupId, artifactId, oldVersion, newVersion)); + sourceChanges.add(new DefaultDependencyVersionChange(groupId, artifactId, oldVersion, newVersion)); } } @@ -558,7 +554,7 @@ protected synchronized void update(ModifiedPomXMLEventReader pom) VersionChanger changer = versionChangerFactory.newVersionChanger( processParent, processProject, processDependencies, processPlugins); - for (DefaultVersionChange versionChange : sourceChanges) { + for (DefaultDependencyVersionChange versionChange : sourceChanges) { changer.apply(versionChange); } diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UnlockSnapshotsMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UnlockSnapshotsMojo.java index 7276940a2c..2019ea23ca 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UnlockSnapshotsMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UnlockSnapshotsMojo.java @@ -1,22 +1,18 @@ 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; @@ -38,9 +34,9 @@ import org.apache.maven.repository.RepositorySystem; import org.apache.maven.wagon.Wagon; import org.codehaus.mojo.versions.api.PomHelper; -import org.codehaus.mojo.versions.api.recording.ChangeRecord; import org.codehaus.mojo.versions.api.recording.ChangeRecorder; -import org.codehaus.mojo.versions.recording.DefaultChangeRecord; +import org.codehaus.mojo.versions.api.recording.DependencyChangeRecord; +import org.codehaus.mojo.versions.recording.DefaultDependencyChangeRecord; import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader; /** @@ -88,11 +84,13 @@ protected void update(ModifiedPomXMLEventReader pom) PomHelper.getRawModel(getProject()).getDependencyManagement(); if (dependencyManagement != null) { unlockSnapshots( - pom, dependencyManagement.getDependencies(), ChangeRecord.ChangeKind.DEPENDENCY_MANAGEMENT); + pom, + dependencyManagement.getDependencies(), + DependencyChangeRecord.ChangeKind.DEPENDENCY_MANAGEMENT); } } if (getProject().getDependencies() != null && isProcessingDependencies()) { - unlockSnapshots(pom, getProject().getDependencies(), ChangeRecord.ChangeKind.DEPENDENCY); + unlockSnapshots(pom, getProject().getDependencies(), DependencyChangeRecord.ChangeKind.DEPENDENCY); } if (getProject().getParent() != null && isProcessingParent()) { unlockParentSnapshot(pom, getProject().getParent()); @@ -103,7 +101,7 @@ protected void update(ModifiedPomXMLEventReader pom) } private void unlockSnapshots( - ModifiedPomXMLEventReader pom, List dependencies, ChangeRecord.ChangeKind changeKind) + ModifiedPomXMLEventReader pom, List dependencies, DependencyChangeRecord.ChangeKind changeKind) throws XMLStreamException, MojoExecutionException { for (Dependency dep : dependencies) { if (isExcludeReactor() && isProducedByReactor(dep)) { @@ -133,7 +131,7 @@ private void unlockSnapshots( getProject().getModel())) { getChangeRecorder() - .recordChange(DefaultChangeRecord.builder() + .recordChange(DefaultDependencyChangeRecord.builder() .withKind(changeKind) .withDependency(dep) .withNewVersion(unlockedVersion) @@ -165,8 +163,8 @@ private void unlockParentSnapshot(ModifiedPomXMLEventReader pom, MavenProject pa if (PomHelper.setProjectParentVersion(pom, unlockedParentVersion)) { getLog().info("Unlocked parent " + parentArtifact + " to version " + unlockedParentVersion); getChangeRecorder() - .recordChange(DefaultChangeRecord.builder() - .withKind(ChangeRecord.ChangeKind.PARENT) + .recordChange(DefaultDependencyChangeRecord.builder() + .withKind(DependencyChangeRecord.ChangeKind.PARENT) .withArtifact(parentArtifact) .withNewVersion(unlockedParentVersion) .build()); diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UpdateParentMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UpdateParentMojo.java index 3b83b4cfb0..376c95b2d4 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UpdateParentMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UpdateParentMojo.java @@ -1,22 +1,18 @@ 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; @@ -42,10 +38,10 @@ 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.ChangeRecord; import org.codehaus.mojo.versions.api.recording.ChangeRecorder; +import org.codehaus.mojo.versions.api.recording.DependencyChangeRecord; import org.codehaus.mojo.versions.ordering.InvalidSegmentException; -import org.codehaus.mojo.versions.recording.DefaultChangeRecord; +import org.codehaus.mojo.versions.recording.DefaultDependencyChangeRecord; import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader; import org.codehaus.mojo.versions.utils.DefaultArtifactVersionCache; import org.codehaus.mojo.versions.utils.DependencyBuilder; @@ -182,8 +178,8 @@ protected void update(ModifiedPomXMLEventReader pom) + getProject().getParent().getVersion() + " to " + artifactVersion); } getChangeRecorder() - .recordChange(DefaultChangeRecord.builder() - .withKind(ChangeRecord.ChangeKind.PARENT) + .recordChange(DefaultDependencyChangeRecord.builder() + .withKind(DependencyChangeRecord.ChangeKind.PARENT) .withGroupId(getProject().getParent().getGroupId()) .withArtifactId(getProject().getParent().getArtifactId()) .withOldVersion(getProject().getParent().getVersion()) diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UpdatePropertiesMojoBase.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UpdatePropertiesMojoBase.java index 40f1d87aaf..3274bb2f4f 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UpdatePropertiesMojoBase.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UpdatePropertiesMojoBase.java @@ -1,21 +1,18 @@ 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.xml.stream.XMLStreamException; @@ -33,10 +30,11 @@ import org.codehaus.mojo.versions.api.Property; import org.codehaus.mojo.versions.api.PropertyVersions; import org.codehaus.mojo.versions.api.Segment; -import org.codehaus.mojo.versions.api.recording.ChangeRecord; import org.codehaus.mojo.versions.api.recording.ChangeRecorder; +import org.codehaus.mojo.versions.api.recording.DependencyChangeRecord; import org.codehaus.mojo.versions.ordering.InvalidSegmentException; -import org.codehaus.mojo.versions.recording.DefaultChangeRecord; +import org.codehaus.mojo.versions.recording.DefaultDependencyChangeRecord; +import org.codehaus.mojo.versions.recording.DefaultPropertyChangeRecord; import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader; import static org.codehaus.mojo.versions.utils.SegmentUtils.determineUnchangedSegment; @@ -142,11 +140,18 @@ protected void update(ModifiedPomXMLEventReader pom, Map getDependencies(Model model) { * @param node model tree node to process * @param dependencies collection of dependencies to process (can be taken from dependency management, * parent, or dependencies) - * @param changeKind {@link ChangeRecord.ChangeKind} instance for the change recorder + * @param changeKind {@link ChangeKind} instance for the change recorder * @param propertyBacklog a {@link Set} instance used to store dependencies to be updated, but which were not found * in the current subtree. These properties need to be carried over to the parent node for * processing. @@ -300,7 +308,7 @@ private static List getDependencies(Model model) { private void useDepVersion( ModelNode node, Collection dependencies, - ChangeRecord.ChangeKind changeKind, + ChangeKind changeKind, Set propertyBacklog, Map> propertyConflicts) throws MojoExecutionException, XMLStreamException, VersionRetrievalException { @@ -373,7 +381,8 @@ private void useDepVersion( } else { if (getLog().isDebugEnabled()) { getLog().debug(String.format( - "Updated the %s property value to %s.", dep.getVersion(), depVersion)); + "Updated the %s property value to %s.", + propertyName.get(), depVersion)); } } return true; @@ -394,34 +403,44 @@ private void useDepVersion( } private boolean updatePropertyValue(ModelNode node, String property) { - return ofNullable(node.getModel().getProperties()) - .filter(p -> p.containsKey(property)) - .map(ignored -> { + // concatenating properties from the main build section + // with properties from profiles + return Stream.concat( + Stream.of(node.getModel().getProperties().getProperty(property)) + .filter(Objects::nonNull) + .map(value -> new ImmutablePair(null, value)), + node.getModel().getProfiles().stream() + .map(profile -> new ImmutablePair<>(profile, profile.getProperties())) + .map(pair -> ofNullable(pair.getRight().getProperty(property)) + .map(value -> new ImmutablePair(pair.getLeft(), value)) + .orElse(null))) + // and processing them + .filter(Objects::nonNull) + .map(pair -> { + try { + boolean result = PomHelper.setPropertyVersion( + node.getModifiedPomXMLEventReader(), + ofNullable(pair.getLeft()).map(Profile::getId).orElse(null), + property, + depVersion); + if (result) { try { - return PomHelper.setPropertyVersion( - node.getModifiedPomXMLEventReader(), null, property, depVersion); - } catch (XMLStreamException e) { + getChangeRecorder() + .recordChange(DefaultPropertyChangeRecord.builder() + .withProperty(property) + .withOldValue(pair.getRight()) + .withNewValue(depVersion) + .build()); + } catch (MojoExecutionException e) { throw new RuntimeException(e); } - }) - .orElse(false) - | ofNullable(node.getModel().getProfiles()) - .flatMap(profiles -> profiles.stream() - .map(profile -> ofNullable(profile.getProperties()) - .filter(p -> p.containsKey(property)) - .map(ignored -> { - try { - return PomHelper.setPropertyVersion( - node.getModifiedPomXMLEventReader(), - profile.getId(), - property, - depVersion); - } catch (XMLStreamException e) { - throw new RuntimeException(e); - } - }) - .orElse(false)) - .reduce(Boolean::logicalOr)) - .orElse(false); + } + return result; + } catch (XMLStreamException e) { + throw new RuntimeException(e); + } + }) + .reduce(Boolean::logicalOr) + .orElse(false); } } diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseLatestReleasesMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseLatestReleasesMojo.java index 07b39fe2ed..ea316a38f6 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseLatestReleasesMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseLatestReleasesMojo.java @@ -1,22 +1,18 @@ 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; @@ -44,8 +40,8 @@ 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.ChangeRecord; import org.codehaus.mojo.versions.api.recording.ChangeRecorder; +import org.codehaus.mojo.versions.api.recording.DependencyChangeRecord; import org.codehaus.mojo.versions.ordering.InvalidSegmentException; import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader; import org.codehaus.mojo.versions.utils.SegmentUtils; @@ -132,14 +128,16 @@ protected void update(ModifiedPomXMLEventReader pom) PomHelper.getRawModel(getProject()).getDependencyManagement(); if (dependencyManagement != null) { useLatestReleases( - pom, dependencyManagement.getDependencies(), ChangeRecord.ChangeKind.DEPENDENCY_MANAGEMENT); + pom, + dependencyManagement.getDependencies(), + DependencyChangeRecord.ChangeKind.DEPENDENCY_MANAGEMENT); } } if (getProject().getDependencies() != null && isProcessingDependencies()) { - useLatestReleases(pom, getProject().getDependencies(), ChangeRecord.ChangeKind.DEPENDENCY); + useLatestReleases(pom, getProject().getDependencies(), DependencyChangeRecord.ChangeKind.DEPENDENCY); } if (getProject().getParent() != null && isProcessingParent()) { - useLatestReleases(pom, singletonList(getParentDependency()), ChangeRecord.ChangeKind.PARENT); + useLatestReleases(pom, singletonList(getParentDependency()), DependencyChangeRecord.ChangeKind.PARENT); } } catch (IOException e) { throw new MojoExecutionException(e.getMessage(), e); @@ -147,7 +145,9 @@ protected void update(ModifiedPomXMLEventReader pom) } private void useLatestReleases( - ModifiedPomXMLEventReader pom, Collection dependencies, ChangeRecord.ChangeKind changeKind) + ModifiedPomXMLEventReader pom, + Collection dependencies, + DependencyChangeRecord.ChangeKind changeKind) throws XMLStreamException, MojoExecutionException, VersionRetrievalException { Optional unchangedSegment = SegmentUtils.determineUnchangedSegment( allowMajorUpdates, allowMinorUpdates, allowIncrementalUpdates, getLog()); diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseLatestSnapshotsMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseLatestSnapshotsMojo.java index 4f7b38636c..7b00dac7f4 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseLatestSnapshotsMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseLatestSnapshotsMojo.java @@ -1,22 +1,18 @@ 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; @@ -40,8 +36,8 @@ 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.ChangeRecord; import org.codehaus.mojo.versions.api.recording.ChangeRecorder; +import org.codehaus.mojo.versions.api.recording.DependencyChangeRecord; import org.codehaus.mojo.versions.ordering.InvalidSegmentException; import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader; import org.codehaus.mojo.versions.utils.SegmentUtils; @@ -111,14 +107,16 @@ protected void update(ModifiedPomXMLEventReader pom) PomHelper.getRawModel(getProject()).getDependencyManagement(); if (dependencyManagement != null) { useLatestSnapshots( - pom, dependencyManagement.getDependencies(), ChangeRecord.ChangeKind.DEPENDENCY_MANAGEMENT); + pom, + dependencyManagement.getDependencies(), + DependencyChangeRecord.ChangeKind.DEPENDENCY_MANAGEMENT); } } if (getProject().getDependencies() != null && isProcessingDependencies()) { - useLatestSnapshots(pom, getProject().getDependencies(), ChangeRecord.ChangeKind.DEPENDENCY); + useLatestSnapshots(pom, getProject().getDependencies(), DependencyChangeRecord.ChangeKind.DEPENDENCY); } if (getProject().getParent() != null && isProcessingParent()) { - useLatestSnapshots(pom, singletonList(getParentDependency()), ChangeRecord.ChangeKind.PARENT); + useLatestSnapshots(pom, singletonList(getParentDependency()), DependencyChangeRecord.ChangeKind.PARENT); } } catch (IOException e) { throw new MojoExecutionException(e.getMessage(), e); @@ -126,7 +124,9 @@ protected void update(ModifiedPomXMLEventReader pom) } private void useLatestSnapshots( - ModifiedPomXMLEventReader pom, Collection dependencies, ChangeRecord.ChangeKind changeKind) + ModifiedPomXMLEventReader pom, + Collection dependencies, + DependencyChangeRecord.ChangeKind changeKind) throws XMLStreamException, MojoExecutionException, VersionRetrievalException { Optional unchangedSegment = SegmentUtils.determineUnchangedSegment( allowMajorUpdates, allowMinorUpdates, allowIncrementalUpdates, getLog()); diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseLatestVersionsMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseLatestVersionsMojo.java index a600a98ce7..1dc4615cc6 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseLatestVersionsMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseLatestVersionsMojo.java @@ -1,22 +1,18 @@ 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; @@ -38,8 +34,8 @@ 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.ChangeRecord; import org.codehaus.mojo.versions.api.recording.ChangeRecorder; +import org.codehaus.mojo.versions.api.recording.DependencyChangeRecord; import org.codehaus.mojo.versions.ordering.InvalidSegmentException; import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader; import org.codehaus.mojo.versions.utils.SegmentUtils; @@ -126,14 +122,16 @@ protected void update(ModifiedPomXMLEventReader pom) PomHelper.getRawModel(getProject()).getDependencyManagement(); if (dependencyManagement != null) { useLatestVersions( - pom, dependencyManagement.getDependencies(), ChangeRecord.ChangeKind.DEPENDENCY_MANAGEMENT); + pom, + dependencyManagement.getDependencies(), + DependencyChangeRecord.ChangeKind.DEPENDENCY_MANAGEMENT); } } if (getProject().getDependencies() != null && isProcessingDependencies()) { - useLatestVersions(pom, getProject().getDependencies(), ChangeRecord.ChangeKind.DEPENDENCY); + useLatestVersions(pom, getProject().getDependencies(), DependencyChangeRecord.ChangeKind.DEPENDENCY); } if (getProject().getParent() != null && isProcessingParent()) { - useLatestVersions(pom, singletonList(getParentDependency()), ChangeRecord.ChangeKind.PARENT); + useLatestVersions(pom, singletonList(getParentDependency()), DependencyChangeRecord.ChangeKind.PARENT); } } catch (IOException e) { throw new MojoExecutionException(e.getMessage(), e); @@ -141,7 +139,9 @@ protected void update(ModifiedPomXMLEventReader pom) } private void useLatestVersions( - ModifiedPomXMLEventReader pom, Collection dependencies, ChangeRecord.ChangeKind changeKind) + ModifiedPomXMLEventReader pom, + Collection dependencies, + DependencyChangeRecord.ChangeKind changeKind) throws XMLStreamException, MojoExecutionException, VersionRetrievalException { Optional unchangedSegment = SegmentUtils.determineUnchangedSegment( allowMajorUpdates, allowMinorUpdates, allowIncrementalUpdates, getLog()); diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseLatestVersionsMojoBase.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseLatestVersionsMojoBase.java index 3fde347f15..d9ee7f2d50 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseLatestVersionsMojoBase.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseLatestVersionsMojoBase.java @@ -1,22 +1,18 @@ 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.xml.stream.XMLStreamException; @@ -36,8 +32,8 @@ import org.apache.maven.wagon.Wagon; import org.codehaus.mojo.versions.api.ArtifactVersions; import org.codehaus.mojo.versions.api.VersionRetrievalException; -import org.codehaus.mojo.versions.api.recording.ChangeRecord; import org.codehaus.mojo.versions.api.recording.ChangeRecorder; +import org.codehaus.mojo.versions.api.recording.DependencyChangeRecord; import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader; import org.codehaus.mojo.versions.utils.DefaultArtifactVersionCache; @@ -73,7 +69,7 @@ protected final void useLatestVersions( ModifiedPomXMLEventReader pom, Collection dependencies, BiFunction> newestVersionProducer, - ChangeRecord.ChangeKind changeKind, + DependencyChangeRecord.ChangeKind changeKind, Predicate... filters) throws XMLStreamException, MojoExecutionException, VersionRetrievalException { for (Dependency dep : dependencies) { diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseNextReleasesMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseNextReleasesMojo.java index 8f614956c3..ed8bc8de3b 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseNextReleasesMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseNextReleasesMojo.java @@ -1,22 +1,18 @@ 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; @@ -38,12 +34,15 @@ import org.apache.maven.wagon.Wagon; import org.codehaus.mojo.versions.api.PomHelper; import org.codehaus.mojo.versions.api.VersionRetrievalException; -import org.codehaus.mojo.versions.api.recording.ChangeRecord; import org.codehaus.mojo.versions.api.recording.ChangeRecorder; +import org.codehaus.mojo.versions.api.recording.DependencyChangeRecord; import org.codehaus.mojo.versions.ordering.InvalidSegmentException; import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader; import static java.util.Collections.singletonList; +import static org.codehaus.mojo.versions.api.recording.DependencyChangeRecord.ChangeKind.DEPENDENCY; +import static org.codehaus.mojo.versions.api.recording.DependencyChangeRecord.ChangeKind.DEPENDENCY_MANAGEMENT; +import static org.codehaus.mojo.versions.api.recording.DependencyChangeRecord.ChangeKind.PARENT; /** * Replaces any release versions with the next release version (if it has been released). @@ -87,17 +86,16 @@ protected void update(ModifiedPomXMLEventReader pom) DependencyManagement dependencyManagement = PomHelper.getRawModel(getProject()).getDependencyManagement(); if (dependencyManagement != null) { - useNextReleases( - pom, dependencyManagement.getDependencies(), ChangeRecord.ChangeKind.DEPENDENCY_MANAGEMENT); + useNextReleases(pom, dependencyManagement.getDependencies(), DEPENDENCY_MANAGEMENT); } } if (getProject().getDependencies() != null && isProcessingDependencies()) { - useNextReleases(pom, getProject().getDependencies(), ChangeRecord.ChangeKind.DEPENDENCY); + useNextReleases(pom, getProject().getDependencies(), DEPENDENCY); } if (getProject().getParent() != null && isProcessingParent()) { - useNextReleases(pom, singletonList(getParentDependency()), ChangeRecord.ChangeKind.PARENT); + useNextReleases(pom, singletonList(getParentDependency()), PARENT); } } catch (IOException e) { throw new MojoExecutionException(e.getMessage(), e); @@ -105,7 +103,9 @@ protected void update(ModifiedPomXMLEventReader pom) } private void useNextReleases( - ModifiedPomXMLEventReader pom, Collection dependencies, ChangeRecord.ChangeKind changeKind) + ModifiedPomXMLEventReader pom, + Collection dependencies, + DependencyChangeRecord.ChangeKind changeKind) throws XMLStreamException, MojoExecutionException, VersionRetrievalException { useLatestVersions( pom, diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseNextSnapshotsMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseNextSnapshotsMojo.java index 12378ad8ca..802528c548 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseNextSnapshotsMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseNextSnapshotsMojo.java @@ -1,22 +1,18 @@ 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; @@ -39,8 +35,8 @@ 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.ChangeRecord; import org.codehaus.mojo.versions.api.recording.ChangeRecorder; +import org.codehaus.mojo.versions.api.recording.DependencyChangeRecord; import org.codehaus.mojo.versions.ordering.InvalidSegmentException; import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader; import org.codehaus.mojo.versions.utils.SegmentUtils; @@ -111,13 +107,15 @@ protected void update(ModifiedPomXMLEventReader pom) PomHelper.getRawModel(getProject()).getDependencyManagement(); if (dependencyManagement != null) { useNextSnapshots( - pom, dependencyManagement.getDependencies(), ChangeRecord.ChangeKind.DEPENDENCY_MANAGEMENT); + pom, + dependencyManagement.getDependencies(), + DependencyChangeRecord.ChangeKind.DEPENDENCY_MANAGEMENT); } if (getProject().getDependencies() != null && isProcessingDependencies()) { - useNextSnapshots(pom, getProject().getDependencies(), ChangeRecord.ChangeKind.DEPENDENCY); + useNextSnapshots(pom, getProject().getDependencies(), DependencyChangeRecord.ChangeKind.DEPENDENCY); } if (getProject().getParent() != null && isProcessingParent()) { - useNextSnapshots(pom, singletonList(getParentDependency()), ChangeRecord.ChangeKind.PARENT); + useNextSnapshots(pom, singletonList(getParentDependency()), DependencyChangeRecord.ChangeKind.PARENT); } } catch (IOException e) { throw new MojoExecutionException(e.getMessage(), e); @@ -125,7 +123,9 @@ protected void update(ModifiedPomXMLEventReader pom) } private void useNextSnapshots( - ModifiedPomXMLEventReader pom, Collection dependencies, ChangeRecord.ChangeKind changeKind) + ModifiedPomXMLEventReader pom, + Collection dependencies, + DependencyChangeRecord.ChangeKind changeKind) throws XMLStreamException, MojoExecutionException, VersionRetrievalException { Optional unchangedSegment = SegmentUtils.determineUnchangedSegment( allowMajorUpdates, allowMinorUpdates, allowIncrementalUpdates, getLog()); diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseNextVersionsMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseNextVersionsMojo.java index 319005a68e..0417071f18 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseNextVersionsMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseNextVersionsMojo.java @@ -1,22 +1,18 @@ 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; @@ -38,12 +34,15 @@ import org.apache.maven.wagon.Wagon; import org.codehaus.mojo.versions.api.PomHelper; import org.codehaus.mojo.versions.api.VersionRetrievalException; -import org.codehaus.mojo.versions.api.recording.ChangeRecord; import org.codehaus.mojo.versions.api.recording.ChangeRecorder; +import org.codehaus.mojo.versions.api.recording.DependencyChangeRecord; import org.codehaus.mojo.versions.ordering.InvalidSegmentException; import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader; import static java.util.Collections.singletonList; +import static org.codehaus.mojo.versions.api.recording.DependencyChangeRecord.ChangeKind.DEPENDENCY; +import static org.codehaus.mojo.versions.api.recording.DependencyChangeRecord.ChangeKind.DEPENDENCY_MANAGEMENT; +import static org.codehaus.mojo.versions.api.recording.DependencyChangeRecord.ChangeKind.PARENT; /** * Replaces any version with the latest version. @@ -89,15 +88,14 @@ protected void update(ModifiedPomXMLEventReader pom) DependencyManagement dependencyManagement = PomHelper.getRawModel(getProject()).getDependencyManagement(); if (dependencyManagement != null) { - useNextVersions( - pom, dependencyManagement.getDependencies(), ChangeRecord.ChangeKind.DEPENDENCY_MANAGEMENT); + useNextVersions(pom, dependencyManagement.getDependencies(), DEPENDENCY_MANAGEMENT); } } if (getProject().getDependencies() != null && isProcessingDependencies()) { - useNextVersions(pom, getProject().getDependencies(), ChangeRecord.ChangeKind.DEPENDENCY); + useNextVersions(pom, getProject().getDependencies(), DEPENDENCY); } if (getProject().getParent() != null && isProcessingParent()) { - useNextVersions(pom, singletonList(getParentDependency()), ChangeRecord.ChangeKind.PARENT); + useNextVersions(pom, singletonList(getParentDependency()), PARENT); } } catch (IOException e) { throw new MojoExecutionException(e.getMessage(), e); @@ -105,7 +103,9 @@ protected void update(ModifiedPomXMLEventReader pom) } private void useNextVersions( - ModifiedPomXMLEventReader pom, Collection dependencies, ChangeRecord.ChangeKind changeKind) + ModifiedPomXMLEventReader pom, + Collection dependencies, + DependencyChangeRecord.ChangeKind changeKind) throws XMLStreamException, MojoExecutionException, VersionRetrievalException { useLatestVersions( pom, diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseReleasesMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseReleasesMojo.java index 7bdda8be44..662628c750 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseReleasesMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseReleasesMojo.java @@ -1,22 +1,18 @@ 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; @@ -42,8 +38,8 @@ import org.codehaus.mojo.versions.api.ArtifactVersions; import org.codehaus.mojo.versions.api.PomHelper; import org.codehaus.mojo.versions.api.VersionRetrievalException; -import org.codehaus.mojo.versions.api.recording.ChangeRecord; import org.codehaus.mojo.versions.api.recording.ChangeRecorder; +import org.codehaus.mojo.versions.api.recording.DependencyChangeRecord; import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader; import static java.util.Collections.singletonList; @@ -103,14 +99,16 @@ protected void update(ModifiedPomXMLEventReader pom) PomHelper.getRawModel(getProject()).getDependencyManagement(); if (dependencyManagement != null) { useReleases( - pom, dependencyManagement.getDependencies(), ChangeRecord.ChangeKind.DEPENDENCY_MANAGEMENT); + pom, + dependencyManagement.getDependencies(), + DependencyChangeRecord.ChangeKind.DEPENDENCY_MANAGEMENT); } } if (getProject().getDependencies() != null && isProcessingDependencies()) { - useReleases(pom, getProject().getDependencies(), ChangeRecord.ChangeKind.DEPENDENCY); + useReleases(pom, getProject().getDependencies(), DependencyChangeRecord.ChangeKind.DEPENDENCY); } if (getProject().getParent() != null && isProcessingParent()) { - useReleases(pom, singletonList(getParentDependency()), ChangeRecord.ChangeKind.PARENT); + useReleases(pom, singletonList(getParentDependency()), DependencyChangeRecord.ChangeKind.PARENT); } } catch (IOException e) { throw new MojoExecutionException(e.getMessage(), e); @@ -118,7 +116,9 @@ protected void update(ModifiedPomXMLEventReader pom) } private void useReleases( - ModifiedPomXMLEventReader pom, Collection dependencies, ChangeRecord.ChangeKind changeKind) + ModifiedPomXMLEventReader pom, + Collection dependencies, + DependencyChangeRecord.ChangeKind changeKind) throws XMLStreamException, MojoExecutionException, VersionRetrievalException { for (Dependency dep : dependencies) { if (isExcludeReactor() && isProducedByReactor(dep)) { diff --git a/versions-maven-plugin/src/main/resources/org/codehaus/mojo/versions/recording/schema-2.0.xsd b/versions-maven-plugin/src/main/resources/org/codehaus/mojo/versions/recording/schema-2.0.xsd new file mode 100644 index 0000000000..897a833a11 --- /dev/null +++ b/versions-maven-plugin/src/main/resources/org/codehaus/mojo/versions/recording/schema-2.0.xsd @@ -0,0 +1,58 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/versions-maven-plugin/src/site/markdown/examples/recording-changes.md b/versions-maven-plugin/src/site/markdown/examples/recording-changes.md index 9497d8248b..fd5dac3ebe 100644 --- a/versions-maven-plugin/src/site/markdown/examples/recording-changes.md +++ b/versions-maven-plugin/src/site/markdown/examples/recording-changes.md @@ -31,14 +31,17 @@ Which writes a file to `target/versions-changes.xml` that looks something like: ```xml - - + + + ``` The contents of this file records the fact that `localhost:dummy-api:1.1.1-2` -was upgraded to `3.0`. +was upgraded to `3.0` and that the property `revision` changed its value from `3.0` to `3.1`. diff --git a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/ForceReleasesMojoTest.java b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/ForceReleasesMojoTest.java index 6dd54904aa..4e44888d72 100644 --- a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/ForceReleasesMojoTest.java +++ b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/ForceReleasesMojoTest.java @@ -10,7 +10,7 @@ import org.apache.maven.project.MavenProject; import org.codehaus.mojo.versions.api.PomHelper; import org.codehaus.mojo.versions.api.VersionRetrievalException; -import org.codehaus.mojo.versions.change.DefaultVersionChange; +import org.codehaus.mojo.versions.change.DefaultDependencyVersionChange; import org.codehaus.mojo.versions.utils.DependencyBuilder; import org.codehaus.mojo.versions.utils.TestChangeRecorder; import org.junit.Before; @@ -32,22 +32,18 @@ import static org.mockito.Mockito.mockStatic; /* - * 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. */ /** @@ -104,7 +100,7 @@ public void testProcessParent() } assertThat( changeRecorder.getChanges(), - hasItem(new DefaultVersionChange( + hasItem(new DefaultDependencyVersionChange( "default-group", "artifactA", "1.0.0-SNAPSHOT", "1.0.0"))); } @@ -131,7 +127,7 @@ public void testReplaceSnapshotWithRelease() } assertThat( changeRecorder.getChanges(), - hasItem(new DefaultVersionChange( + hasItem(new DefaultDependencyVersionChange( "default-group", "artifactA", "1.0.0-SNAPSHOT", "1.0.0"))); } @@ -158,7 +154,7 @@ public void testUpgrade() } assertThat( changeRecorder.getChanges(), - hasItem(new DefaultVersionChange( + hasItem(new DefaultDependencyVersionChange( "default-group", "artifactA", "1.1.0-SNAPSHOT", "2.0.0"))); } @@ -185,7 +181,7 @@ public void testDowngrade() } assertThat( changeRecorder.getChanges(), - hasItem(new DefaultVersionChange( + hasItem(new DefaultDependencyVersionChange( "default-group", "artifactA", "2.1.0-SNAPSHOT", "2.0.0"))); } diff --git a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/UpdateParentMojoTest.java b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/UpdateParentMojoTest.java index 56619688b3..498082542c 100644 --- a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/UpdateParentMojoTest.java +++ b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/UpdateParentMojoTest.java @@ -1,5 +1,20 @@ package org.codehaus.mojo.versions; +/* + * 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. + */ + import javax.xml.stream.XMLStreamException; import java.util.Collections; @@ -19,7 +34,7 @@ import org.apache.maven.repository.RepositorySystem; import org.codehaus.mojo.versions.api.PomHelper; import org.codehaus.mojo.versions.api.VersionRetrievalException; -import org.codehaus.mojo.versions.change.DefaultVersionChange; +import org.codehaus.mojo.versions.change.DefaultDependencyVersionChange; import org.codehaus.mojo.versions.ordering.InvalidSegmentException; import org.codehaus.mojo.versions.utils.TestChangeRecorder; import org.junit.Before; @@ -162,7 +177,8 @@ public void testParentDowngradeAllowed() } assertThat( changeRecorder.getChanges(), - hasItem(new DefaultVersionChange("default-group", "parent-artifact", "1.0.1-SNAPSHOT", "1.0.0"))); + hasItem(new DefaultDependencyVersionChange( + "default-group", "parent-artifact", "1.0.1-SNAPSHOT", "1.0.0"))); } @Test @@ -242,7 +258,7 @@ public void testAllowSnapshotsWithParentVersion() } assertThat( changeRecorder.getChanges(), - hasItem(new DefaultVersionChange( + hasItem(new DefaultDependencyVersionChange( "default-group", "issue-670-artifact", "0.0.1-1", "0.0.1-1-impl-SNAPSHOT"))); } @@ -297,7 +313,7 @@ private void testSkipResolution(String version) throws VersionRetrievalException assertThat( changeRecorder.getChanges(), - hasItem(new DefaultVersionChange("default-group", "parent-artifact", "1.0.0", version))); + hasItem(new DefaultDependencyVersionChange("default-group", "parent-artifact", "1.0.0", version))); } @Test @@ -320,7 +336,8 @@ public void testShouldUpgradeToSnapshot() } assertThat( changeRecorder.getChanges(), - hasItem(new DefaultVersionChange("default-group", "parent-artifact", "0.9.0", "1.0.1-SNAPSHOT"))); + hasItem(new DefaultDependencyVersionChange( + "default-group", "parent-artifact", "0.9.0", "1.0.1-SNAPSHOT"))); } @Test @@ -384,7 +401,7 @@ public void testParentVersionRange() } assertThat( changeRecorder.getChanges(), - hasItem(new DefaultVersionChange("default-group", "dummy-parent2", "1.0", "2.0"))); + hasItem(new DefaultDependencyVersionChange("default-group", "dummy-parent2", "1.0", "2.0"))); } @Test diff --git a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/UpdatePropertiesMojoTest.java b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/UpdatePropertiesMojoTest.java index af9be7435c..4c413fccdb 100644 --- a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/UpdatePropertiesMojoTest.java +++ b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/UpdatePropertiesMojoTest.java @@ -1,27 +1,24 @@ 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 java.nio.file.Files; import java.nio.file.Paths; -import org.codehaus.mojo.versions.change.DefaultVersionChange; +import org.codehaus.mojo.versions.change.DefaultDependencyVersionChange; import org.codehaus.mojo.versions.utils.TestChangeRecorder; import org.codehaus.mojo.versions.utils.TestUtils; import org.junit.Test; @@ -45,7 +42,7 @@ public void testAllowMajorUpdates() throws Exception { setUpMojo("update-properties").execute(); assertThat( changeRecorder.getChanges(), - hasItem(new DefaultVersionChange("default-group", "default-artifact", "1.0.0", "2.0.0-M1"))); + hasItem(new DefaultDependencyVersionChange("default-group", "default-artifact", "1.0.0", "2.0.0-M1"))); } @Test @@ -59,7 +56,8 @@ public void testAllowMinorUpdates() throws Exception { mojo.execute(); assertThat( changeRecorder.getChanges(), - hasItem(new DefaultVersionChange("default-group", "default-artifact", "1.0.0", "1.1.0-alpha"))); + hasItem(new DefaultDependencyVersionChange( + "default-group", "default-artifact", "1.0.0", "1.1.0-alpha"))); } @Test @@ -74,7 +72,7 @@ public void testAllowIncrementalUpdates() throws Exception { mojo.execute(); assertThat( changeRecorder.getChanges(), - hasItem(new DefaultVersionChange("default-group", "default-artifact", "1.0.0", "1.0.1-rc1"))); + hasItem(new DefaultDependencyVersionChange("default-group", "default-artifact", "1.0.0", "1.0.1-rc1"))); } @Test diff --git a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/UpdatePropertyMojoTest.java b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/UpdatePropertyMojoTest.java index 3005da328b..03bf68b64c 100644 --- a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/UpdatePropertyMojoTest.java +++ b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/UpdatePropertyMojoTest.java @@ -1,27 +1,24 @@ 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 java.nio.file.Files; import java.nio.file.Paths; -import org.codehaus.mojo.versions.change.DefaultVersionChange; +import org.codehaus.mojo.versions.change.DefaultDependencyVersionChange; import org.hamcrest.Matchers; import org.junit.Test; @@ -43,7 +40,8 @@ public void testAllowMajorUpdates() throws Exception { mojo.execute(); assertThat( changeRecorder.getChanges(), - Matchers.hasItem(new DefaultVersionChange("default-group", "default-artifact", "1.0.0", "2.0.0-M1"))); + Matchers.hasItem( + new DefaultDependencyVersionChange("default-group", "default-artifact", "1.0.0", "2.0.0-M1"))); } @Test @@ -58,8 +56,8 @@ public void testAllowMinorUpdates() throws Exception { mojo.execute(); assertThat( changeRecorder.getChanges(), - Matchers.hasItem( - new DefaultVersionChange("default-group", "default-artifact", "1.0.0", "1.1.0-alpha"))); + Matchers.hasItem(new DefaultDependencyVersionChange( + "default-group", "default-artifact", "1.0.0", "1.1.0-alpha"))); } @Test @@ -75,6 +73,7 @@ public void testAllowIncrementalUpdates() throws Exception { mojo.execute(); assertThat( changeRecorder.getChanges(), - Matchers.hasItem(new DefaultVersionChange("default-group", "default-artifact", "1.0.0", "1.0.1-rc1"))); + Matchers.hasItem( + new DefaultDependencyVersionChange("default-group", "default-artifact", "1.0.0", "1.0.1-rc1"))); } } diff --git a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/UseDepVersionMojoTest.java b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/UseDepVersionMojoTest.java index f1aaf8bf0d..a440b6351e 100644 --- a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/UseDepVersionMojoTest.java +++ b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/UseDepVersionMojoTest.java @@ -1,22 +1,18 @@ 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 java.nio.file.Files; @@ -28,6 +24,7 @@ import org.apache.maven.plugin.logging.SystemStreamLog; import org.apache.maven.plugin.testing.AbstractMojoTestCase; import org.apache.maven.plugin.testing.MojoRule; +import org.codehaus.mojo.versions.change.DefaultPropertyVersionChange; import org.codehaus.mojo.versions.utils.TestChangeRecorder; import org.codehaus.mojo.versions.utils.TestUtils; import org.junit.After; @@ -40,6 +37,7 @@ import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.containsString; import static org.hamcrest.Matchers.empty; +import static org.hamcrest.Matchers.hasItem; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.Mockito.doAnswer; import static org.mockito.Mockito.mock; @@ -54,6 +52,7 @@ public class UseDepVersionMojoTest extends AbstractMojoTestCase { public MojoRule mojoRule = new MojoRule(this); private Path tempDir; + private TestChangeRecorder changeRecorder = new TestChangeRecorder(); @Before public void setUp() throws Exception { @@ -65,6 +64,7 @@ public void setUp() throws Exception { public void tearDown() throws Exception { try { TestUtils.tearDownTempDir(tempDir); + changeRecorder.getChanges().clear(); } finally { super.tearDown(); } @@ -127,12 +127,16 @@ public boolean isDebugEnabled() { setVariableValueToObject(mojo, "repositorySystem", mockRepositorySystem()); setVariableValueToObject(mojo, "aetherRepositorySystem", mockAetherRepositorySystem()); setVariableValueToObject(mojo, "log", logger); + setVariableValueToObject(mojo, "changeRecorders", changeRecorder.asTestMap()); mojo.execute(); String pom = String.join("", Files.readAllLines(tempDir.resolve("pom.xml"))); assertThat(pom, containsString("${revision}")); assertThat(pom, containsString("2.0.0")); + assertThat( + changeRecorder.getChanges(), + hasItem(new DefaultPropertyVersionChange("revision", "1.0.0-SNAPSHOT", "2.0.0"))); } /** @@ -155,6 +159,7 @@ public void testPropertiesConflict() throws Exception { setVariableValueToObject(mojo, "aetherRepositorySystem", mockAetherRepositorySystem()); setVariableValueToObject(mojo, "changeRecorders", changeRecorder.asTestMap()); setVariableValueToObject(mojo, "log", logger); + setVariableValueToObject(mojo, "changeRecorders", changeRecorder.asTestMap()); mojo.execute(); @@ -162,6 +167,7 @@ public void testPropertiesConflict() throws Exception { assertThat( warnLog.toString(), containsString("Cannot update property ${revision}: controls more than one dependency: artifactB")); + assertThat(changeRecorder.getChanges(), empty()); } /** @@ -179,6 +185,7 @@ public void testPropertiesConflictRedefinition() throws Exception { setVariableValueToObject(mojo, "reactorProjects", Collections.singletonList(mojo.getProject())); setVariableValueToObject(mojo, "repositorySystem", mockRepositorySystem()); setVariableValueToObject(mojo, "aetherRepositorySystem", mockAetherRepositorySystem()); + setVariableValueToObject(mojo, "changeRecorders", changeRecorder.asTestMap()); mojo.execute(); @@ -188,6 +195,8 @@ public void testPropertiesConflictRedefinition() throws Exception { assertThat(parent, containsString("${revision}")); assertThat(child, containsString("2.0.0")); assertThat(parent, containsString("1.0.0-SNAPSHOT")); + assertThat( + changeRecorder.getChanges(), hasItem(new DefaultPropertyVersionChange("revision", "1.0.1", "2.0.0"))); } /** @@ -206,6 +215,7 @@ public void testPropertiesConflictCancellation() throws Exception { setVariableValueToObject(mojo, "reactorProjects", Collections.singletonList(mojo.getProject())); setVariableValueToObject(mojo, "repositorySystem", mockRepositorySystem()); setVariableValueToObject(mojo, "aetherRepositorySystem", mockAetherRepositorySystem()); + setVariableValueToObject(mojo, "changeRecorders", changeRecorder.asTestMap()); mojo.execute(); @@ -215,6 +225,9 @@ public void testPropertiesConflictCancellation() throws Exception { assertThat(parent, containsString("${revision}")); assertThat(parent, containsString("2.0.0")); assertThat(child, containsString("1.0.1")); + assertThat( + changeRecorder.getChanges(), + hasItem(new DefaultPropertyVersionChange("revision", "1.0.0-SNAPSHOT", "2.0.0"))); } /** @@ -231,6 +244,7 @@ public void testPropertiesConflictCancellationProfiles() throws Exception { setVariableValueToObject(mojo, "reactorProjects", Collections.singletonList(mojo.getProject())); setVariableValueToObject(mojo, "repositorySystem", mockRepositorySystem()); setVariableValueToObject(mojo, "aetherRepositorySystem", mockAetherRepositorySystem()); + setVariableValueToObject(mojo, "changeRecorders", changeRecorder.asTestMap()); mojo.execute(); @@ -240,6 +254,9 @@ public void testPropertiesConflictCancellationProfiles() throws Exception { assertThat(parent, containsString("${revision}")); assertThat(parent, containsString("2.0.0")); assertThat(child, containsString("1.0.1")); + assertThat( + changeRecorder.getChanges(), + hasItem(new DefaultPropertyVersionChange("revision", "1.0.0-SNAPSHOT", "2.0.0"))); } /** @@ -262,6 +279,7 @@ public boolean isDebugEnabled() { setVariableValueToObject(mojo, "repositorySystem", mockRepositorySystem()); setVariableValueToObject(mojo, "aetherRepositorySystem", mockAetherRepositorySystem()); setVariableValueToObject(mojo, "log", logger); + setVariableValueToObject(mojo, "changeRecorders", changeRecorder.asTestMap()); mojo.execute(); @@ -269,6 +287,8 @@ public boolean isDebugEnabled() { String parent = String.join("", Files.readAllLines(tempDir.resolve("pom.xml"))); assertThat(child, containsString("${revision}")); assertThat(parent, containsString("2.0.0")); + assertThat( + changeRecorder.getChanges(), hasItem(new DefaultPropertyVersionChange("revision", "1.0.0", "2.0.0"))); } /** @@ -285,6 +305,7 @@ public void testPropertiesChildParentRedefinition() throws Exception { setVariableValueToObject(mojo, "reactorProjects", Collections.singletonList(mojo.getProject())); setVariableValueToObject(mojo, "repositorySystem", mockRepositorySystem()); setVariableValueToObject(mojo, "aetherRepositorySystem", mockAetherRepositorySystem()); + setVariableValueToObject(mojo, "changeRecorders", changeRecorder.asTestMap()); mojo.execute(); @@ -293,6 +314,8 @@ public void testPropertiesChildParentRedefinition() throws Exception { assertThat(child, containsString("${revision}")); assertThat(parent, containsString("1.0.0-SNAPSHOT")); assertThat(child, containsString("2.0.0")); + assertThat( + changeRecorder.getChanges(), hasItem(new DefaultPropertyVersionChange("revision", "1.0.1", "2.0.0"))); } /** @@ -318,6 +341,7 @@ public void testPropertyFromParent() throws Exception { setVariableValueToObject(mojo, "aetherRepositorySystem", mockAetherRepositorySystem()); setVariableValueToObject(mojo, "changeRecorders", changeRecorder.asTestMap()); setVariableValueToObject(mojo, "log", logger); + setVariableValueToObject(mojo, "changeRecorders", changeRecorder.asTestMap()); mojo.execute(); diff --git a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/UseLatestReleasesMojoTest.java b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/UseLatestReleasesMojoTest.java index c8777c2b36..d094440037 100644 --- a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/UseLatestReleasesMojoTest.java +++ b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/UseLatestReleasesMojoTest.java @@ -1,5 +1,20 @@ package org.codehaus.mojo.versions; +/* + * 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. + */ + import javax.xml.stream.XMLStreamException; import java.util.HashMap; @@ -11,7 +26,7 @@ import org.apache.maven.repository.RepositorySystem; import org.codehaus.mojo.versions.api.PomHelper; import org.codehaus.mojo.versions.api.VersionRetrievalException; -import org.codehaus.mojo.versions.change.DefaultVersionChange; +import org.codehaus.mojo.versions.change.DefaultDependencyVersionChange; import org.codehaus.mojo.versions.utils.DependencyBuilder; import org.codehaus.mojo.versions.utils.TestChangeRecorder; import org.hamcrest.Matchers; @@ -131,7 +146,7 @@ public void testAllowDowngrade() } assertThat( changeRecorder.getChanges(), - hasItem(new DefaultVersionChange( + hasItem(new DefaultDependencyVersionChange( "default-group", "artifactA", "1.0.1-SNAPSHOT", "1.0.0"))); } diff --git a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/UseLatestVersionsMojoTest.java b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/UseLatestVersionsMojoTest.java index ea7a12b135..ab5f622bd7 100644 --- a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/UseLatestVersionsMojoTest.java +++ b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/UseLatestVersionsMojoTest.java @@ -1,5 +1,20 @@ package org.codehaus.mojo.versions; +/* + * 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. + */ + import javax.xml.stream.XMLStreamException; import java.util.Arrays; @@ -15,7 +30,7 @@ import org.apache.maven.repository.RepositorySystem; import org.codehaus.mojo.versions.api.PomHelper; import org.codehaus.mojo.versions.api.VersionRetrievalException; -import org.codehaus.mojo.versions.change.DefaultVersionChange; +import org.codehaus.mojo.versions.change.DefaultDependencyVersionChange; import org.codehaus.mojo.versions.utils.DependencyBuilder; import org.codehaus.mojo.versions.utils.TestChangeRecorder; import org.hamcrest.core.Is; @@ -122,7 +137,8 @@ public void testDependenciesDowngradeIncremental() } assertThat( changeRecorder.getChanges(), - hasItem(new DefaultVersionChange("default-group", "dependency-artifact", "1.1.1-SNAPSHOT", "1.1.0"))); + hasItem(new DefaultDependencyVersionChange( + "default-group", "dependency-artifact", "1.1.1-SNAPSHOT", "1.1.0"))); } @Test @@ -149,7 +165,7 @@ public void testDependenciesDowngradeMinor() } assertThat( changeRecorder.getChanges(), - hasItem(new DefaultVersionChange( + hasItem(new DefaultDependencyVersionChange( "default-group", "dependency-artifact", "1.1.0-SNAPSHOT", "1.1.0"))); } @@ -173,7 +189,7 @@ public void testDependenciesDowngradeMajor() } assertThat( changeRecorder.getChanges(), - hasItem(new DefaultVersionChange( + hasItem(new DefaultDependencyVersionChange( "default-group", "dependency-artifact", "1.1.1-SNAPSHOT", "1.1.0"))); } @@ -200,7 +216,8 @@ public void testDependencyManagementDowngrade() } assertThat( changeRecorder.getChanges(), - hasItem(new DefaultVersionChange("default-group", "dependency-artifact", "1.1.1-SNAPSHOT", "1.1.0"))); + hasItem(new DefaultDependencyVersionChange( + "default-group", "dependency-artifact", "1.1.1-SNAPSHOT", "1.1.0"))); } @Test @@ -233,7 +250,8 @@ public void testParentDowngrade() } assertThat( changeRecorder.getChanges(), - hasItem(new DefaultVersionChange("default-group", "dependency-artifact", "1.1.1-SNAPSHOT", "1.1.0"))); + hasItem(new DefaultDependencyVersionChange( + "default-group", "dependency-artifact", "1.1.1-SNAPSHOT", "1.1.0"))); } @Test @@ -275,7 +293,8 @@ public void testPoisonDependencyVersion() // being present in the dependency list assertThat( changeRecorder.getChanges(), - hasItem(new DefaultVersionChange("default-group", "dependency-artifact", "1.1.1-SNAPSHOT", "1.1.0"))); + hasItem(new DefaultDependencyVersionChange( + "default-group", "dependency-artifact", "1.1.1-SNAPSHOT", "1.1.0"))); } @Test @@ -317,7 +336,7 @@ public void testIncludeFilter() assertThat(changeRecorder.getChanges(), hasSize(1)); assertThat( changeRecorder.getChanges(), - hasItem(new DefaultVersionChange("default-group", "other-artifact", "1.0", "2.0"))); + hasItem(new DefaultDependencyVersionChange("default-group", "other-artifact", "1.0", "2.0"))); } @Test @@ -343,6 +362,6 @@ public void testExcludeFilter() assertThat(changeRecorder.getChanges(), hasSize(1)); assertThat( changeRecorder.getChanges(), - not(hasItem(new DefaultVersionChange("default-group", "other-artifact", "1.0", "2.0")))); + not(hasItem(new DefaultDependencyVersionChange("default-group", "other-artifact", "1.0", "2.0")))); } } diff --git a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/UseNextReleasesMojoTest.java b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/UseNextReleasesMojoTest.java index 8ff57dd70f..946367558c 100644 --- a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/UseNextReleasesMojoTest.java +++ b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/UseNextReleasesMojoTest.java @@ -1,21 +1,18 @@ 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.xml.stream.XMLStreamException; @@ -30,7 +27,7 @@ import org.apache.maven.repository.RepositorySystem; import org.codehaus.mojo.versions.api.PomHelper; import org.codehaus.mojo.versions.api.VersionRetrievalException; -import org.codehaus.mojo.versions.change.DefaultVersionChange; +import org.codehaus.mojo.versions.change.DefaultDependencyVersionChange; import org.codehaus.mojo.versions.utils.DependencyBuilder; import org.codehaus.mojo.versions.utils.TestChangeRecorder; import org.hamcrest.Matchers; @@ -129,7 +126,7 @@ public void testFindANewerRelease() throws IllegalAccessException { } assertThat( changeRecorder.getChanges(), - hasItem(new DefaultVersionChange("default-group", "dependency-artifact", "1.1.0", "1.1.1"))); + hasItem(new DefaultDependencyVersionChange("default-group", "dependency-artifact", "1.1.0", "1.1.1"))); } @Test @@ -160,7 +157,7 @@ public void testAllowDowngrade() } assertThat( changeRecorder.getChanges(), - hasItem(new DefaultVersionChange( + hasItem(new DefaultDependencyVersionChange( "default-group", "artifactA", "1.0.1-SNAPSHOT", "1.0.0"))); } diff --git a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/UseNextVersionsMojoTest.java b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/UseNextVersionsMojoTest.java index 7ab0d45cbb..7bed7f92ac 100644 --- a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/UseNextVersionsMojoTest.java +++ b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/UseNextVersionsMojoTest.java @@ -1,21 +1,18 @@ 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.xml.stream.XMLStreamException; @@ -30,7 +27,7 @@ import org.apache.maven.repository.RepositorySystem; import org.codehaus.mojo.versions.api.PomHelper; import org.codehaus.mojo.versions.api.VersionRetrievalException; -import org.codehaus.mojo.versions.change.DefaultVersionChange; +import org.codehaus.mojo.versions.change.DefaultDependencyVersionChange; import org.codehaus.mojo.versions.utils.DependencyBuilder; import org.codehaus.mojo.versions.utils.TestChangeRecorder; import org.hamcrest.Matchers; @@ -135,7 +132,8 @@ public void testFindANewerVersion() throws IllegalAccessException { } assertThat( changeRecorder.getChanges(), - hasItem(new DefaultVersionChange("default-group", "dependency-artifact", "1.1.0-SNAPSHOT", "1.1.1"))); + hasItem(new DefaultDependencyVersionChange( + "default-group", "dependency-artifact", "1.1.0-SNAPSHOT", "1.1.1"))); } @Test @@ -166,7 +164,7 @@ public void testAllowDowngrade() } assertThat( changeRecorder.getChanges(), - hasItem(new DefaultVersionChange( + hasItem(new DefaultDependencyVersionChange( "default-group", "artifactA", "1.0.1-SNAPSHOT", "1.0.0"))); } diff --git a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/UseReleasesMojoTest.java b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/UseReleasesMojoTest.java index cfac64c8c1..8580a04afd 100644 --- a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/UseReleasesMojoTest.java +++ b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/UseReleasesMojoTest.java @@ -10,7 +10,7 @@ import org.apache.maven.project.MavenProject; import org.codehaus.mojo.versions.api.PomHelper; import org.codehaus.mojo.versions.api.VersionRetrievalException; -import org.codehaus.mojo.versions.change.DefaultVersionChange; +import org.codehaus.mojo.versions.change.DefaultDependencyVersionChange; import org.codehaus.mojo.versions.utils.DependencyBuilder; import org.codehaus.mojo.versions.utils.TestChangeRecorder; import org.junit.Before; @@ -32,22 +32,18 @@ import static org.mockito.Mockito.mockStatic; /* - * 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. */ /** @@ -104,7 +100,7 @@ public void testProcessParent() } assertThat( changeRecorder.getChanges(), - hasItem(new DefaultVersionChange( + hasItem(new DefaultDependencyVersionChange( "default-group", "artifactA", "1.0.0-SNAPSHOT", "1.0.0"))); } @@ -131,7 +127,7 @@ public void testReplaceSnapshotWithRelease() } assertThat( changeRecorder.getChanges(), - hasItem(new DefaultVersionChange( + hasItem(new DefaultDependencyVersionChange( "default-group", "artifactA", "1.0.0-SNAPSHOT", "1.0.0"))); } diff --git a/versions-test/src/main/java/org/codehaus/mojo/versions/utils/TestChangeRecorder.java b/versions-test/src/main/java/org/codehaus/mojo/versions/utils/TestChangeRecorder.java index b591d600b6..6b3b7c0fc2 100644 --- a/versions-test/src/main/java/org/codehaus/mojo/versions/utils/TestChangeRecorder.java +++ b/versions-test/src/main/java/org/codehaus/mojo/versions/utils/TestChangeRecorder.java @@ -1,22 +1,18 @@ 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. */ import javax.inject.Named; @@ -28,15 +24,21 @@ import java.util.Map; import org.codehaus.mojo.versions.api.change.VersionChange; -import org.codehaus.mojo.versions.api.recording.ChangeRecord; import org.codehaus.mojo.versions.api.recording.ChangeRecorder; +import org.codehaus.mojo.versions.api.recording.DependencyChangeRecord; +import org.codehaus.mojo.versions.api.recording.PropertyChangeRecord; @Named("test") public class TestChangeRecorder implements ChangeRecorder { private final List changes = new LinkedList<>(); @Override - public void recordChange(ChangeRecord changeRecord) { + public void recordChange(DependencyChangeRecord changeRecord) { + changes.add(changeRecord.getVersionChange()); + } + + @Override + public void recordChange(PropertyChangeRecord changeRecord) { changes.add(changeRecord.getVersionChange()); }