Skip to content

Commit 2c22da0

Browse files
andrzejj0slawekjaranowski
authored andcommitted
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
1 parent 19d03f3 commit 2c22da0

File tree

63 files changed

+1206
-882
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+1206
-882
lines changed
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
package org.codehaus.mojo.versions.api.change;
2+
3+
/*
4+
* Copyright MojoHaus and Contributors
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*
18+
*/
19+
20+
/**
21+
* Represents a change of an item's version.
22+
*
23+
* @author Slawomir Jaranowski
24+
* @since 2.14.0
25+
*/
26+
public interface DependencyVersionChange extends VersionChange {
27+
/**
28+
* @return a groupId of changed item
29+
* @since 2.14.0
30+
*/
31+
String getGroupId();
32+
33+
/**
34+
* @return an ArtifactId of change item
35+
* @since 2.14.0
36+
*/
37+
String getArtifactId();
38+
39+
/**
40+
* @return an old version of changed item
41+
* @since 2.14.0
42+
*/
43+
String getOldVersion();
44+
45+
/**
46+
* @return a new version of changed item
47+
* @since 2.14.0
48+
*/
49+
String getNewVersion();
50+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
package org.codehaus.mojo.versions.api.change;
2+
3+
/*
4+
* Copyright MojoHaus and Contributors
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*
18+
*/
19+
20+
/**
21+
* Represents a change of a property value.
22+
*
23+
* @author Andrzej Jarmoniuk
24+
* @since 2.15.0
25+
*/
26+
public interface PropertyVersionChange extends VersionChange {
27+
28+
/**
29+
* @return the property that has changed
30+
*/
31+
String getProperty();
32+
33+
/**
34+
* @return the old value of the property
35+
*/
36+
String getOldValue();
37+
38+
/**
39+
* @return the new value of the property
40+
*/
41+
String getNewValue();
42+
}

versions-api/src/main/java/org/codehaus/mojo/versions/api/change/VersionChange.java

Lines changed: 2 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -14,37 +14,9 @@
1414
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1515
* See the License for the specific language governing permissions and
1616
* limitations under the License.
17-
*
1817
*/
1918

2019
/**
21-
* Represents a change of an item's version.
22-
*
23-
* @author Slawomir Jaranowski
24-
* @since 2.14.0
20+
* Base class for version changes
2521
*/
26-
public interface VersionChange {
27-
/**
28-
* @return a groupId of changed item
29-
* @since 2.14.0
30-
*/
31-
String getGroupId();
32-
33-
/**
34-
* @return an ArtifactId of change item
35-
* @since 2.14.0
36-
*/
37-
String getArtifactId();
38-
39-
/**
40-
* @return an old version of changed item
41-
* @since 2.14.0
42-
*/
43-
String getOldVersion();
44-
45-
/**
46-
* @return a new version of changed item
47-
* @since 2.14.0
48-
*/
49-
String getNewVersion();
50-
}
22+
public interface VersionChange {}

versions-api/src/main/java/org/codehaus/mojo/versions/api/recording/ChangeRecord.java

Lines changed: 3 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -24,39 +24,12 @@
2424
*
2525
* @author Slawomir Jaranowski
2626
* @since 2.14.0
27+
* @param <T> concrete {@link VersionChange} sub-interface
2728
*/
28-
public interface ChangeRecord {
29-
/**
30-
* Describe where version item is updated.
31-
*/
32-
enum ChangeKind {
33-
DEPENDENCY("dependency-update"),
34-
DEPENDENCY_MANAGEMENT("dependency-management-update"),
35-
PARENT("parent-update"),
36-
PLUGIN("plugin-update"),
37-
PLUGIN_MANAGEMENT("plugin-management-update"),
38-
PROPERTY("property-update");
39-
40-
private final String label;
41-
42-
ChangeKind(String label) {
43-
this.label = label;
44-
}
45-
46-
public String getLabel() {
47-
return label;
48-
}
49-
}
50-
51-
/**
52-
* @return a version item change kind
53-
* @since 2.14.0
54-
*/
55-
ChangeKind getKind();
56-
29+
public interface ChangeRecord<T extends VersionChange> {
5730
/**
5831
* @return a details about changed item
5932
* @since 2.14.0
6033
*/
61-
VersionChange getVersionChange();
34+
T getVersionChange();
6235
}

versions-api/src/main/java/org/codehaus/mojo/versions/api/recording/ChangeRecorder.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,18 @@ public interface ChangeRecorder {
3030
/**
3131
* Record that a dependency was updated.
3232
*
33-
* @param changeRecord a record described change
33+
* @param changeRecord a dependency record described change
3434
* @since 2.14.0
3535
*/
36-
void recordChange(ChangeRecord changeRecord);
36+
void recordChange(DependencyChangeRecord changeRecord);
37+
38+
/**
39+
* Record that a property was updated.
40+
*
41+
* @param changeRecord a property record described change
42+
* @since 2.14.0
43+
*/
44+
void recordChange(PropertyChangeRecord changeRecord);
3745

3846
/**
3947
* Write the current set of changes to the given output path.
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
package org.codehaus.mojo.versions.api.recording;
2+
3+
/*
4+
* Copyright MojoHaus and Contributors
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*
18+
*/
19+
20+
import org.codehaus.mojo.versions.api.change.DependencyVersionChange;
21+
22+
/**
23+
* Represents a change record of an item's version.
24+
*
25+
* @author Slawomir Jaranowski
26+
* @since 2.14.0
27+
*/
28+
public interface DependencyChangeRecord extends ChangeRecord<DependencyVersionChange> {
29+
/**
30+
* Describe where version item is updated.
31+
*/
32+
enum ChangeKind {
33+
DEPENDENCY("dependency-update"),
34+
DEPENDENCY_MANAGEMENT("dependency-management-update"),
35+
PARENT("parent-update"),
36+
PLUGIN("plugin-update"),
37+
PLUGIN_MANAGEMENT("plugin-management-update"),
38+
PROPERTY("property-update");
39+
40+
private final String label;
41+
42+
ChangeKind(String label) {
43+
this.label = label;
44+
}
45+
46+
public String getLabel() {
47+
return label;
48+
}
49+
}
50+
51+
/**
52+
* @return a version item change kind
53+
* @since 2.14.0
54+
*/
55+
ChangeKind getKind();
56+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package org.codehaus.mojo.versions.api.recording;
2+
3+
/*
4+
* Copyright MojoHaus and Contributors
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*
18+
*/
19+
20+
import org.codehaus.mojo.versions.api.change.PropertyVersionChange;
21+
22+
/**
23+
* Represents a change record of an item's version.
24+
*
25+
* @author Slawomir Jaranowski
26+
* @since 2.14.0
27+
*/
28+
public interface PropertyChangeRecord extends ChangeRecord<PropertyVersionChange> {}

versions-api/src/site/markdown/change-recorder.md.vm

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,26 +11,31 @@ Write code
1111
----------
1212

1313
```java
14+
import java.io.IOException;
1415
import javax.inject.Named;
1516

1617
import java.nio.file.Path;
1718

18-
import org.codehaus.mojo.versions.api.recording.ChangeRecord;
19+
import org.codehaus.mojo.versions.api.recording.DependencyChangeRecord;
20+
import org.codehaus.mojo.versions.api.recording.PropertyChangeRecord;
1921
import org.codehaus.mojo.versions.api.recording.ChangeRecorder;
2022

21-
@Named( "my-recorder" )
22-
public class MyChangeRecorder implements ChangeRecorder
23-
{
23+
@Named("my-recorder")
24+
public class MyChangeRecorder implements ChangeRecorder {
25+
26+
@Override
27+
public final void recordChange(DependencyChangeRecord changeRecord) {
28+
// your code here
29+
}
30+
2431
@Override
25-
public final void recordChange( ChangeRecord changeRecord )
26-
{
27-
// your code
32+
public final void recordChange(PropertyChangeRecord changeRecord) {
33+
// your code here
2834
}
2935

3036
@Override
31-
public final void writeReport( Path outputPath )
32-
{
33-
// your code
37+
public final void writeReport(Path outputPath) throws IOException {
38+
// your code here
3439
}
3540
}
3641
```

versions-common/src/main/java/org/codehaus/mojo/versions/change/CompositeVersionChanger.java

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,18 @@
11
package org.codehaus.mojo.versions.change;
22

33
/*
4-
* Licensed to the Apache Software Foundation (ASF) under one
5-
* or more contributor license agreements. See the NOTICE file
6-
* distributed with this work for additional information
7-
* regarding copyright ownership. The ASF licenses this file
8-
* to you under the Apache License, Version 2.0 (the
9-
* "License"); you may not use this file except in compliance
10-
* with the License. You may obtain a copy of the License at
4+
* Copyright MojoHaus and Contributors
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
118
*
12-
* http://www.apache.org/licenses/LICENSE-2.0
9+
* http://www.apache.org/licenses/LICENSE-2.0
1310
*
14-
* Unless required by applicable law or agreed to in writing,
15-
* software distributed under the License is distributed on an
16-
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17-
* KIND, either express or implied. See the License for the
18-
* specific language governing permissions and limitations
19-
* under the License.
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
2016
*/
2117

2218
import javax.xml.stream.XMLStreamException;
@@ -25,7 +21,7 @@
2521
import java.util.Arrays;
2622
import java.util.List;
2723

28-
import org.codehaus.mojo.versions.api.change.VersionChange;
24+
import org.codehaus.mojo.versions.api.change.DependencyVersionChange;
2925

3026
/**
3127
* Created by IntelliJ IDEA.
@@ -44,7 +40,7 @@ public CompositeVersionChanger(List<VersionChanger> composites) {
4440
this.composites = new ArrayList<>(composites);
4541
}
4642

47-
public void apply(VersionChange versionChange) throws XMLStreamException {
43+
public void apply(DependencyVersionChange versionChange) throws XMLStreamException {
4844
for (VersionChanger delegate : composites) {
4945
delegate.apply(versionChange);
5046
}

0 commit comments

Comments
 (0)