-
Notifications
You must be signed in to change notification settings - Fork 66
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
[MDEPLOY-118] - Enable deployment of attached release artifacts if POM is identical #28
Open
mdrie
wants to merge
5
commits into
apache:master
Choose a base branch
from
mdrie:MDEPLOY-118
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
32c4acd
MDEPLOY-118: Add parameter `comparePomWithDeployed` to `deploy` goal.
c5aca79
MDEPLOY-118: surefire test for `comparePomWithDeployed`.
2e2ae57
MDEPLOY-118: integration test for `comparePomWithDeployed`.
ef26770
MDEPLOY-118: fix path-handling in surefire tests for Windows.
e7600ce
MDEPLOY-118: integration test: add two SNAPSHOT runs, not affected by…
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 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,73 @@ | ||
<?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/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<groupId>org.apache.maven.its.deploy.comparepom</groupId> | ||
<artifactId>test</artifactId> | ||
<version>${revision}</version> | ||
<packaging>pom</packaging> | ||
|
||
<description> | ||
Tests deployment comparing with a deployed POM. Parameter comparePomWithDeployed. Modified POM! | ||
</description> | ||
|
||
<properties> | ||
<revision>1.0-SNAPSHOT</revision> | ||
<maven.test.skip>true</maven.test.skip> | ||
</properties> | ||
|
||
<distributionManagement> | ||
<repository> | ||
<id>it</id> | ||
<url>file:///${basedir}/repo</url> | ||
</repository> | ||
</distributionManagement> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-deploy-plugin</artifactId> | ||
<version>${m-deploy-p.version}</version> | ||
<configuration> | ||
<comparePomWithDeployed>true</comparePomWithDeployed> | ||
</configuration> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-jar-plugin</artifactId> | ||
<version>2.1</version> | ||
<executions> | ||
<execution> | ||
<goals> | ||
<goal>jar</goal> | ||
</goals> | ||
<configuration> | ||
<classifier>${classifier}</classifier> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> |
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,31 @@ | ||
# 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.debug = false | ||
|
||
invoker.goals.1 = -Dclassifier=first clean deploy | ||
|
||
invoker.project.2 = altered-pom.xml | ||
invoker.goals.2 = -Dclassifier=second -Dm-deploy-p.version=${project.version} clean deploy | ||
|
||
invoker.goals.3 = -Drevision=1.0 -Dclassifier=first clean deploy | ||
|
||
invoker.goals.4 = -Drevision=1.0 -Dclassifier=second clean deploy | ||
|
||
invoker.project.5 = altered-pom.xml | ||
invoker.goals.5 = -Drevision=1.0 -Dclassifier=third -Dm-deploy-p.version=${project.version} clean deploy | ||
invoker.buildResult.5 = failure |
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,73 @@ | ||
<?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/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<groupId>org.apache.maven.its.deploy.comparepom</groupId> | ||
<artifactId>test</artifactId> | ||
<version>${revision}</version> | ||
<packaging>pom</packaging> | ||
|
||
<description> | ||
Tests deployment comparing with a deployed POM. Parameter comparePomWithDeployed. | ||
</description> | ||
|
||
<properties> | ||
<revision>1.0-SNAPSHOT</revision> | ||
<maven.test.skip>true</maven.test.skip> | ||
</properties> | ||
|
||
<distributionManagement> | ||
<repository> | ||
<id>it</id> | ||
<url>file:///${basedir}/repo</url> | ||
</repository> | ||
</distributionManagement> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-deploy-plugin</artifactId> | ||
<version>@project.version@</version> | ||
<configuration> | ||
<comparePomWithDeployed>true</comparePomWithDeployed> | ||
</configuration> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-jar-plugin</artifactId> | ||
<version>2.1</version> | ||
<executions> | ||
<execution> | ||
<goals> | ||
<goal>jar</goal> | ||
</goals> | ||
<configuration> | ||
<classifier>${classifier}</classifier> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> |
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,33 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
import java.io.*; | ||
import java.util.*; | ||
|
||
import org.codehaus.plexus.util.*; | ||
|
||
File file = new File( localRepositoryPath, "org/apache/maven/its/deploy/comparepom" ); | ||
System.out.println( "Deleting " + file ); | ||
FileUtils.deleteDirectory( file ); | ||
|
||
file = new File( basedir, "repo" ); | ||
System.out.println( "Deleting " + file ); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. delete |
||
FileUtils.deleteDirectory( file ); | ||
|
||
return true; |
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,89 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
class LogInspector | ||
{ | ||
File log; | ||
int index; | ||
LogInspector( File log ) | ||
{ | ||
this.log = log; | ||
this.index = 0; | ||
} | ||
boolean containsAfter( CharSequence text ) | ||
{ | ||
int newIdx = log.text.indexOf( text, index + 1 ) | ||
if ( newIdx > index) | ||
{ | ||
index = newIdx | ||
return true | ||
} | ||
return false | ||
} | ||
String toString () | ||
{ | ||
return "Log file ${log} after index ${index}." | ||
} | ||
} | ||
|
||
|
||
assert new File( basedir, "repo/org/apache/maven/its/deploy/comparepom/test/maven-metadata.xml" ).exists() | ||
|
||
File snDir = new File( basedir, "repo/org/apache/maven/its/deploy/comparepom/test/1.0-SNAPSHOT/" ) | ||
assert snDir.list( {d, f -> f ==~ /test-1.0-.*-first.jar/} as FilenameFilter ).size() == 1 | ||
assert snDir.list( {d, f -> f ==~ /test-1.0-.*-second.jar/} as FilenameFilter ).size() == 1 | ||
assert snDir.list( {d, f -> f ==~ /test-1.0-.*.pom/} as FilenameFilter ).size() == 2 | ||
|
||
assert new File( basedir, "repo/org/apache/maven/its/deploy/comparepom/test/1.0/test-1.0-first.jar" ).exists() | ||
assert new File( basedir, "repo/org/apache/maven/its/deploy/comparepom/test/1.0/test-1.0-second.jar").exists() | ||
|
||
File deployedPom = new File( basedir, "repo/org/apache/maven/its/deploy/comparepom/test/1.0/test-1.0.pom" ) | ||
assert deployedPom.exists() | ||
assert ! deployedPom.text.contains("Modified POM!") | ||
|
||
File installedPom = new File( localRepositoryPath, "org/apache/maven/its/deploy/comparepom/test/1.0/test-1.0.pom" ) | ||
assert installedPom.exists() | ||
assert installedPom.text.contains("Modified POM!") | ||
|
||
File buildLog = new File( basedir, 'build.log' ) | ||
assert buildLog.exists() | ||
|
||
// Inspect log | ||
LogInspector li = new LogInspector( buildLog ) | ||
String groupUrl = "file:///${basedir}/repo/org/apache/maven/its/deploy/comparepom" | ||
|
||
// 1st and 2nd run: The POM tried to be downloaded and uploaded: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Log messages are not reliable over time. Tests should not use them to inspect behavior. |
||
assert li.containsAfter( "[INFO] Downloading from it: ${groupUrl}/test/1.0-SNAPSHOT/test-1.0-SNAPSHOT.pom" ) | ||
assert li.containsAfter( "[INFO] Downloading from it: ${groupUrl}/test/1.0-SNAPSHOT/test-1.0-SNAPSHOT.pom" ) | ||
|
||
// 3rd run: The POM tried to be downloaded and uploaded: | ||
assert li.containsAfter( "[INFO] Downloading from it: ${groupUrl}/test/1.0/test-1.0.pom" ) | ||
assert li.containsAfter( "[INFO] Uploaded to it: ${groupUrl}/test/1.0/test-1.0.pom" ) | ||
|
||
// After that, it is never tried to be uploaded: | ||
assert -1 == buildLog.text.indexOf( "[INFO] Uploading to it: ${groupUrl}/test/1.0/test-1.0.pom", li.index + 1 ) | ||
|
||
// 4th run: POM is downloaded and not uploaded: | ||
assert li.containsAfter( "[INFO] Downloaded from it: ${groupUrl}/test/1.0/test-1.0.pom" ) | ||
assert li.containsAfter( "[INFO] Not deploying POM, since deployed POM is equal to current POM." ) | ||
|
||
// 5th run: POM is downloaded, nothing is tried to be uploaded after that, and the build fails with error: | ||
assert li.containsAfter( "[INFO] Downloaded from it: ${groupUrl}/test/1.0/test-1.0.pom" ) | ||
assert -1 == buildLog.text.indexOf( "[INFO] Uploading to", li.index + 1 ) | ||
assert li.containsAfter( "[ERROR] Project version org.apache.maven.its.deploy.comparepom:test:1.0 already deployed with a differing POM." ) |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You shouldn't need to print debug messages in tests.