Skip to content

Commit

Permalink
Resolves #880: add information on property updates to the change reco…
Browse files Browse the repository at this point in the history
…rder

Release notes:
- new version and new namespace for the change recorder
- change recorder also records property changes
  • Loading branch information
andrzejj0 authored and slawekjaranowski committed Feb 12, 2023
1 parent 19d03f3 commit 2c22da0
Show file tree
Hide file tree
Showing 63 changed files with 1,206 additions and 882 deletions.
Original file line number Diff line number Diff line change
@@ -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();
}
Original file line number Diff line number Diff line change
@@ -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();
}
Original file line number Diff line number Diff line change
Expand Up @@ -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 {}
Original file line number Diff line number Diff line change
Expand Up @@ -24,39 +24,12 @@
*
* @author Slawomir Jaranowski
* @since 2.14.0
* @param <T> 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<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 @@ -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.
Expand Down
Original file line number Diff line number Diff line change
@@ -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<DependencyVersionChange> {
/**
* 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();
}
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> {}
25 changes: 15 additions & 10 deletions versions-api/src/site/markdown/change-recorder.md.vm
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
```
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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.
Expand All @@ -44,7 +40,7 @@ public CompositeVersionChanger(List<VersionChanger> 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);
}
Expand Down
Loading

0 comments on commit 2c22da0

Please sign in to comment.