-
Notifications
You must be signed in to change notification settings - Fork 138
[MRELEASE-1109] Snapshot detection and support for versions like ${revision}${sha1}${changelist}
#202
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
mkolesnikov
wants to merge
17
commits into
apache:master
from
mkolesnikov:MRELEASE-1109_snapshot_detection
Closed
[MRELEASE-1109] Snapshot detection and support for versions like ${revision}${sha1}${changelist}
#202
Changes from 8 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
21df8de
MRELEASE-1109 full support of CI Friendly expression
ab5c8d5
MRELEASE-1109 patch JDomModel
466383d
Merge branch 'bugfix/MRELEASE-1109_patch' into feature/MRELEASE-1109_…
0ad7bb6
MRELEASE-1109 Full support for revision sha1 and changelist properties.
mkolesnikov ef93eec
MRELEASE-1109 single revision property
mkolesnikov 27791ef
MRELEASE-1109 reverted redundant changes
mkolesnikov 66f51ce
MRELEASE-1109 fixed format
mkolesnikov dbcbb08
MRELEASE-1109 added asserts for pom.xml.tag files and removed mislead…
mkolesnikov 4032941
MRELEASE-1109 addressed review comments and replaced `replaceAll` wit…
mkolesnikov 6b4fc81
MRELEASE-1109 removed redundant comment
mkolesnikov e3682ab
Merge branch 'refs/heads/master' into MRELEASE-1109_snapshot_detection
mkolesnikov fbc3ac2
MRELEASE-1109 renamed SHA1 constant
mkolesnikov 0be8e5a
MRELEASE-1109 JDomModel should know about current MavenProject
mkolesnikov 56fe3ed
MRELEASE-1109 Using scmRevision as sha1 value if the property defined…
mkolesnikov 28ebea0
MRELEASE-1109 fixed integration test
mkolesnikov fe02232
MRELEASE-1109 clean up and format
mkolesnikov 491ee0d
MRELEASE-1109 More integration tests, map-version-phase should know a…
mkolesnikov File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
...n-release-manager/src/main/java/org/apache/maven/shared/release/util/MavenExpression.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* | ||
* 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 | ||
* | ||
* 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. | ||
*/ | ||
package org.apache.maven.shared.release.util; | ||
|
||
import java.util.Map; | ||
import java.util.regex.Matcher; | ||
import java.util.regex.Pattern; | ||
|
||
/** | ||
* @author <a href="mailto:[email protected]">Mikhail Kolesnikov</a> | ||
*/ | ||
public class MavenExpression { | ||
public static final Pattern EXPRESSION_PATTERN = Pattern.compile("\\$\\{(.+?)\\}"); | ||
|
||
private MavenExpression() {} | ||
|
||
public static String evaluate(String expression, Map<?, ?> properties) { | ||
StringBuilder result = new StringBuilder(expression); | ||
Matcher matcher = EXPRESSION_PATTERN.matcher(result); | ||
while (matcher.find()) { | ||
String propertyName = matcher.group(1); | ||
Object propertyValue = properties.get(propertyName); | ||
result.replace(matcher.start(), matcher.end(), String.valueOf(propertyValue)); | ||
matcher.reset(); | ||
} | ||
return result.toString(); | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
...lease-manager/src/test/java/org/apache/maven/shared/release/util/MavenExpressionTest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/* | ||
* 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 | ||
* | ||
* 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. | ||
*/ | ||
package org.apache.maven.shared.release.util; | ||
|
||
import java.util.Arrays; | ||
import java.util.Collection; | ||
import java.util.Properties; | ||
|
||
import junit.framework.TestCase; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
import org.junit.runners.Parameterized; | ||
import org.junit.runners.Parameterized.Parameters; | ||
|
||
/** | ||
* @author <a href="mailto:[email protected]">Mikhail Kolesnikov</a> | ||
*/ | ||
@RunWith(Parameterized.class) | ||
public class MavenExpressionTest extends TestCase { | ||
|
||
private final String expected; | ||
private final String expression; | ||
private final Properties properties = new Properties(); | ||
|
||
public MavenExpressionTest(String expected, String expression) { | ||
this.expected = expected; | ||
this.expression = expression; | ||
properties.setProperty("revision", "12"); | ||
properties.setProperty("sha1", "34"); | ||
properties.setProperty("changelist", "56"); | ||
} | ||
|
||
@Parameters(name = "expected result {0} for expression {1}") | ||
public static Collection<Object[]> parameters() { | ||
return Arrays.asList( | ||
new Object[] {"123456", "${revision}${sha1}${changelist}"}, | ||
new Object[] {"12-34-56", "${revision}-${sha1}-${changelist}"}, | ||
new Object[] {"12-null-56", "${revision}-${unknown}-${changelist}"}); | ||
} | ||
|
||
@Test | ||
public void testEvaluate() { | ||
assertEquals(expected, MavenExpression.evaluate(expression, properties)); | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
...jects/rewrite-for-development/pom-with-parent-and-cifriendly-expressions/expected-pom.xml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
|
||
<!-- | ||
~ Copyright 2005-2006 The Apache Software Foundation. | ||
~ | ||
~ 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. | ||
--> | ||
|
||
<project> | ||
<modelVersion>4.0.0</modelVersion> | ||
<groupId>groupId</groupId> | ||
<artifactId>artifactId</artifactId> | ||
<version>${revision}${sha1}${changelist}</version> | ||
<packaging>pom</packaging> | ||
|
||
<scm> | ||
<connection>scm:svn:file://localhost/tmp/scm-repo/trunk</connection> | ||
<developerConnection>scm:svn:file://localhost/tmp/scm-repo/trunk</developerConnection> | ||
<url>file://localhost/tmp/scm-repo/trunk</url> | ||
</scm> | ||
|
||
<properties> | ||
<revision>1.1</revision> | ||
<sha1>.123</sha1> | ||
<changelist>-SNAPSHOT</changelist> | ||
</properties> | ||
|
||
<modules> | ||
<module>subproject1</module> | ||
</modules> | ||
</project> |
41 changes: 41 additions & 0 deletions
41
...urces/projects/rewrite-for-development/pom-with-parent-and-cifriendly-expressions/pom.xml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
|
||
<!-- | ||
~ Copyright 2005-2006 The Apache Software Foundation. | ||
~ | ||
~ 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. | ||
--> | ||
|
||
<project> | ||
<modelVersion>4.0.0</modelVersion> | ||
<groupId>groupId</groupId> | ||
<artifactId>artifactId</artifactId> | ||
<version>${revision}${sha1}${changelist}</version> | ||
<packaging>pom</packaging> | ||
|
||
<scm> | ||
<connection>scm:svn:file://localhost/tmp/scm-repo/tags/release-label</connection> | ||
<developerConnection>scm:svn:file://localhost/tmp/scm-repo/tags/release-label</developerConnection> | ||
<url>file://localhost/tmp/scm-repo/tags/release-label</url> | ||
</scm> | ||
|
||
<properties> | ||
<revision>1.0</revision> | ||
<sha1>.123</sha1> | ||
<changelist>-SNAPSHOT</changelist> | ||
</properties> | ||
|
||
<modules> | ||
<module>subproject1</module> | ||
</modules> | ||
</project> |
28 changes: 28 additions & 0 deletions
28
...e-for-development/pom-with-parent-and-cifriendly-expressions/subproject1/expected-pom.xml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
|
||
<!-- | ||
~ Copyright 2005-2006 The Apache Software Foundation. | ||
~ | ||
~ 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. | ||
--> | ||
|
||
<project> | ||
<modelVersion>4.0.0</modelVersion> | ||
<parent> | ||
<groupId>groupId</groupId> | ||
<artifactId>artifactId</artifactId> | ||
<version>${revision}${sha1}${changelist}</version> | ||
</parent> | ||
|
||
<artifactId>subproject1</artifactId> | ||
</project> |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.