Skip to content

Commit

Permalink
Resolves mojohaus#899: Corrected the invocation of Resolver to retrie…
Browse files Browse the repository at this point in the history
…ve the timestamped snapshot version; added unit tests for LockSnapshotsMojo for the case when no timestamped versions are found
  • Loading branch information
andrzejj0 committed Jan 8, 2023
1 parent c997bb4 commit 17c17fa
Show file tree
Hide file tree
Showing 7 changed files with 54 additions and 23 deletions.
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
package org.codehaus.mojo.versions.api.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.
*/

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,12 @@
*
* @author Slawomir Jaranowski
* @since 2.14.0
* @param <T> concrete {@link VersionChange} sub-interface
*/
public interface ChangeRecord {
public interface ChangeRecord<T extends VersionChange> {
/**
* @return a details about changed item
* @since 2.14.0
*/
VersionChange getVersionChange();
T getVersionChange();
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
import java.io.IOException;
import java.nio.file.Path;

import org.codehaus.mojo.versions.api.change.VersionChange;

/**
* Interface for implement a recorder of version changes.
*
Expand All @@ -32,8 +34,9 @@ public interface ChangeRecorder {
*
* @param changeRecord a record described change
* @since 2.14.0
* @param <T> concrete {@link VersionChange} sub-interface
*/
void recordChange(ChangeRecord changeRecord);
<T extends VersionChange> void recordChange(ChangeRecord<T> changeRecord);

/**
* Write the current set of changes to the given output path.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,15 @@
*
*/

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 {
public interface DependencyChangeRecord extends ChangeRecord<DependencyVersionChange> {
/**
* Describe where version item is updated.
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -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<PropertyVersionChange> {}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import org.apache.maven.artifact.Artifact;
import org.apache.maven.model.Dependency;
import org.codehaus.mojo.versions.api.change.DependencyVersionChange;
import org.codehaus.mojo.versions.api.recording.ChangeRecord;
import org.codehaus.mojo.versions.api.recording.DependencyChangeRecord;
import org.codehaus.mojo.versions.change.DefaultDependencyVersionChange;

Expand Down Expand Up @@ -79,7 +78,7 @@ public Builder withArtifact(Artifact artifact) {
return this;
}

public ChangeRecord build() {
public DependencyChangeRecord build() {
return new DefaultDependencyChangeRecord(
kind, new DefaultDependencyVersionChange(groupId, artifactId, oldVersion, newVersion));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import java.util.Objects;

import org.codehaus.mojo.versions.api.change.PropertyVersionChange;
import org.codehaus.mojo.versions.api.recording.ChangeRecord;
import org.codehaus.mojo.versions.api.recording.PropertyChangeRecord;
import org.codehaus.mojo.versions.change.DefaultPropertyVersionChange;

/*
Expand All @@ -25,7 +25,7 @@
* under the License.
*/

public class DefaultPropertyChangeRecord implements ChangeRecord {
public class DefaultPropertyChangeRecord implements PropertyChangeRecord {
private final PropertyVersionChange versionChange;

private DefaultPropertyChangeRecord(PropertyVersionChange versionChange) {
Expand Down Expand Up @@ -61,7 +61,7 @@ public Builder withNewValue(String newValue) {
return this;
}

public ChangeRecord build() {
public PropertyChangeRecord build() {
return new DefaultPropertyChangeRecord(new DefaultPropertyVersionChange(property, oldValue, newValue));
}
}
Expand Down

0 comments on commit 17c17fa

Please sign in to comment.