-
Notifications
You must be signed in to change notification settings - Fork 134
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add IT to ensure the VersionPolicy enhancement works
- Loading branch information
1 parent
5a1cb3b
commit 903f4ff
Showing
5 changed files
with
314 additions
and
0 deletions.
There are no files selected for viewing
56 changes: 56 additions & 0 deletions
56
maven-release-plugin/src/it/projects/prepare/version-policy/pom.xml
This file contains 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,56 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
~ 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. | ||
--> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<groupId>org.apache.maven.plugin.release.it</groupId> | ||
<artifactId>version-policy</artifactId> | ||
<version>0.1.2-SNAPSHOT</version> | ||
<scm> | ||
<connection>scm:dummytags|nul</connection> | ||
<developerConnection>scm:dummytags|nul</developerConnection> | ||
</scm> | ||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-release-plugin</artifactId> | ||
<version>@project.version@</version> | ||
<configuration> | ||
<projectVersionPolicyId>DummyVersionPolicy</projectVersionPolicyId> | ||
<projectVersionPolicyConfig><DummyConfig>One</DummyConfig></projectVersionPolicyConfig> | ||
</configuration> | ||
<dependencies> | ||
<dependency> | ||
<groupId>org.apache.maven.its.release</groupId> | ||
<artifactId>maven-scm-provider-dummy</artifactId> | ||
<version>1.0</version> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.apache.maven.its.release</groupId> | ||
<artifactId>maven-version-policy-dummy</artifactId> | ||
<version>1.0</version> | ||
</dependency> | ||
</dependencies> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> |
56 changes: 56 additions & 0 deletions
56
maven-release-plugin/src/it/projects/prepare/version-policy/verify.groovy
This file contains 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,56 @@ | ||
/* | ||
* Conventional Commits Version Policy | ||
* Copyright (C) 2022-2023 Niels Basjes | ||
* | ||
* 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 | ||
* | ||
* https://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. | ||
*/ | ||
|
||
File buildLog = new File( basedir, 'build.log' ) | ||
assert buildLog.exists() | ||
|
||
assert 1 == buildLog.getText().count("[INPUT:Version] #0.1.2-SNAPSHOT#") | ||
|
||
assert 1 == buildLog.getText().count("[INPUT:Config] #<projectVersionPolicyConfig><DummyConfig>One</DummyConfig>") | ||
|
||
// Only check the last part to avoid path separator issues on Windows and such | ||
assert 1 == buildLog.getText().count("version-policy# [INPUT:WorkingDirectory]") | ||
|
||
// Do we get comments and tags? | ||
assert 1 == buildLog.getText().count("[INPUT:Changeset[0].comment] #Commit 19#") | ||
assert 1 == buildLog.getText().count("[INPUT:Changeset[0].tag] ##") | ||
|
||
assert 1 == buildLog.getText().count("[INPUT:Changeset[4].comment] #Commit 15#") | ||
assert 1 == buildLog.getText().count("[INPUT:Changeset[4].tag] #tag 1,tag 2#") | ||
assert 1 == buildLog.getText().count("[INPUT:Changeset[5].comment] #feat(it): This is a new feature.#") | ||
assert 1 == buildLog.getText().count("[INPUT:Changeset[5].tag] ##") | ||
|
||
assert 1 == buildLog.getText().count("[INPUT:Changeset[13].comment] #Commit 6#") | ||
assert 1 == buildLog.getText().count("[INPUT:Changeset[13].tag] #tag 4#") | ||
|
||
assert 1 == buildLog.getText().count("[INPUT:Changeset[17].comment] #Commit 2#") | ||
assert 1 == buildLog.getText().count("[INPUT:Changeset[17].tag] #v1.2.3#") | ||
|
||
// The pom based version is NOT related to what the actual version will be. | ||
File pomXml = new File( basedir, 'pom.xml' ) | ||
assert pomXml.exists() | ||
assert new XmlSlurper().parse( pomXml ).version.text() == "0.1.2-SNAPSHOT" | ||
|
||
// The actual version is hard coded | ||
File pomXmlTag = new File( basedir, 'pom.xml.tag' ) | ||
assert pomXmlTag.exists() | ||
assert new XmlSlurper().parse( pomXmlTag ).version.text() == "1.2.3" | ||
|
||
// The next development version is hard coded | ||
File pomXmlNext = new File( basedir, 'pom.xml.next' ) | ||
assert pomXmlNext.exists() | ||
assert new XmlSlurper().parse( pomXmlNext ).version.text() == "4.5.6-SNAPSHOT" |
18 changes: 18 additions & 0 deletions
18
maven-release-plugin/src/it/setup/maven-version-policy-dummy/invoker.properties
This file contains 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,18 @@ | ||
# 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. | ||
|
||
invoker.goals = install |
102 changes: 102 additions & 0 deletions
102
maven-release-plugin/src/it/setup/maven-version-policy-dummy/pom.xml
This file contains 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,102 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
~ 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. | ||
--> | ||
|
||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<groupId>org.apache.maven.its.release</groupId> | ||
<artifactId>maven-version-policy-dummy</artifactId> | ||
<version>1.0</version> | ||
|
||
<name>Maven Version Policy Dummy</name> | ||
<description> | ||
Provides a dummy version policy. It will ALWAYS output version 1.2.3 and log the provided settings. | ||
</description> | ||
|
||
<properties> | ||
<target.java.version>1.8</target.java.version> | ||
<target.java.release>8</target.java.release> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
<project.build.outputEncoding>UTF-8</project.build.outputEncoding> | ||
<maven.compiler.source>${target.java.version}</maven.compiler.source> | ||
<maven.compiler.target>${target.java.version}</maven.compiler.target> | ||
<maven.compiler.release>${target.java.release}</maven.compiler.release> | ||
</properties> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.apache.maven.release</groupId> | ||
<artifactId>maven-release-api</artifactId> | ||
<version>@project.version@</version> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.apache.maven.scm</groupId> | ||
<artifactId>maven-scm-api</artifactId> | ||
<version>@scmVersion@</version> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.eclipse.sisu</groupId> | ||
<artifactId>org.eclipse.sisu.inject</artifactId> | ||
<version>@sisuVersion@</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>javax.inject</groupId> | ||
<artifactId>javax.inject</artifactId> | ||
<version>1</version> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.slf4j</groupId> | ||
<artifactId>slf4j-simple</artifactId> | ||
<version>@slf4jVersion@</version> | ||
</dependency> | ||
|
||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<version>@mavenCompilerPluginVersion@</version> | ||
<configuration> | ||
<encoding>UTF-8</encoding> | ||
</configuration> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.eclipse.sisu</groupId> | ||
<artifactId>sisu-maven-plugin</artifactId> | ||
<version>@sisuVersion@</version> | ||
<executions> | ||
<execution> | ||
<id>index-project</id> | ||
<goals> | ||
<goal>main-index</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> |
82 changes: 82 additions & 0 deletions
82
...n-policy-dummy/src/main/java/org/apache/maven/its/release/version/DummyVersionPolicy.java
This file contains 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,82 @@ | ||
/* | ||
* 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.its.release.version; | ||
|
||
import org.apache.maven.scm.ChangeSet; | ||
import org.apache.maven.scm.ScmException; | ||
import org.apache.maven.scm.ScmFileSet; | ||
import org.apache.maven.scm.command.changelog.ChangeLogScmRequest; | ||
import org.apache.maven.scm.command.changelog.ChangeLogScmResult; | ||
import org.apache.maven.shared.release.policy.version.VersionPolicy; | ||
import org.apache.maven.shared.release.policy.version.VersionPolicyRequest; | ||
import org.apache.maven.shared.release.policy.version.VersionPolicyResult; | ||
import org.apache.maven.shared.release.versions.VersionParseException; | ||
import org.eclipse.sisu.Description; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
import javax.inject.Named; | ||
import javax.inject.Singleton; | ||
import java.io.File; | ||
|
||
@Singleton | ||
@Named( "DummyVersionPolicy" ) | ||
@Description( "A dummy VersionPolicy that always gives version 1.2.3. and only logs the provided input." ) | ||
public class DummyVersionPolicy implements VersionPolicy | ||
{ | ||
private static final Logger LOG = LoggerFactory.getLogger( DummyVersionPolicy.class ); | ||
|
||
public VersionPolicyResult getReleaseVersion( VersionPolicyRequest request ) | ||
{ | ||
LOG.info("[INPUT:Config] #{}# [INPUT:Config]", request.getConfig()); | ||
LOG.info("[INPUT:Version] #{}# [INPUT:Version]", request.getVersion()); | ||
LOG.info("[INPUT:WorkingDirectory] #{}# [INPUT:WorkingDirectory]", request.getWorkingDirectory()); | ||
|
||
ChangeLogScmRequest changeLogRequest = new ChangeLogScmRequest( | ||
request.getScmRepository(), | ||
new ScmFileSet(new File(request.getWorkingDirectory())) | ||
); | ||
|
||
ChangeLogScmResult changeLog; | ||
try { | ||
changeLog = request.getScmProvider().changeLog(changeLogRequest); | ||
} catch (ScmException e) { | ||
throw new RuntimeException(e); | ||
} | ||
|
||
int index=0 ; | ||
for (ChangeSet changeSet : changeLog.getChangeLog().getChangeSets()) { | ||
LOG.info("[INPUT:Changeset[{}].comment] #{}#", index, changeSet.getComment()); | ||
LOG.info("[INPUT:Changeset[{}].tag] #{}#", index, String.join(",", changeSet.getTags())); | ||
index++; | ||
} | ||
|
||
VersionPolicyResult result = new VersionPolicyResult(); | ||
result.setVersion("1.2.3"); | ||
return result; | ||
} | ||
|
||
public VersionPolicyResult getDevelopmentVersion(VersionPolicyRequest request) | ||
throws VersionParseException { | ||
VersionPolicyResult result = new VersionPolicyResult(); | ||
result.setVersion("4.5.6-SNAPSHOT"); | ||
return result; | ||
} | ||
} |