Skip to content

Commit 33d89b1

Browse files
[MDEPLOY-305] Improvement in DeployAtEnd
- Fix when module does not use m-deploy-p - Don't use metadata from main artifact to fetch pom.xml - Deploy all artifacts in one request
1 parent 6c2ce48 commit 33d89b1

File tree

12 files changed

+332
-76
lines changed

12 files changed

+332
-76
lines changed

pom.xml

+6
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,12 @@ under the License.
229229
<postBuildHookScript>verify</postBuildHookScript>
230230
<localRepositoryPath>${project.build.directory}/local-repo</localRepositoryPath>
231231
<settingsFile>src/it/settings.xml</settingsFile>
232+
<scriptVariables>
233+
<remoteRepo>${project.build.directory}/remote-repo</remoteRepo>
234+
</scriptVariables>
235+
<filterProperties>
236+
<remoteRepo>${project.build.directory}/remote-repo</remoteRepo>
237+
</filterProperties>
232238
<goals>
233239
<goal>deploy</goal>
234240
</goals>
+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<!-- Licensed to the Apache Software Foundation (ASF) under one or more contributor
4+
license agreements. See the NOTICE file distributed with this work for additional
5+
information regarding copyright ownership. The ASF licenses this file to
6+
you under the Apache License, Version 2.0 (the "License"); you may not use
7+
this file except in compliance with the License. You may obtain a copy of
8+
the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required
9+
by applicable law or agreed to in writing, software distributed under the
10+
License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
11+
OF ANY KIND, either express or implied. See the License for the specific
12+
language governing permissions and limitations under the License. -->
13+
14+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
15+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
16+
<modelVersion>4.0.0</modelVersion>
17+
18+
<parent>
19+
<groupId>org.apache.maven.its.deploy.dae.pass</groupId>
20+
<artifactId>dae</artifactId>
21+
<version>1.0</version>
22+
</parent>
23+
<artifactId>module2</artifactId>
24+
25+
<build>
26+
<plugins>
27+
<plugin>
28+
<groupId>org.apache.maven.plugins</groupId>
29+
<artifactId>maven-deploy-plugin</artifactId>
30+
<executions>
31+
<execution>
32+
<id>default-deploy</id>
33+
<phase>none</phase>
34+
</execution>
35+
</executions>
36+
</plugin>
37+
</plugins>
38+
</build>
39+
</project>
+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<!-- Licensed to the Apache Software Foundation (ASF) under one or more contributor
4+
license agreements. See the NOTICE file distributed with this work for additional
5+
information regarding copyright ownership. The ASF licenses this file to
6+
you under the Apache License, Version 2.0 (the "License"); you may not use
7+
this file except in compliance with the License. You may obtain a copy of
8+
the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required
9+
by applicable law or agreed to in writing, software distributed under the
10+
License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
11+
OF ANY KIND, either express or implied. See the License for the specific
12+
language governing permissions and limitations under the License. -->
13+
14+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
15+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
16+
<modelVersion>4.0.0</modelVersion>
17+
18+
<parent>
19+
<groupId>org.apache.maven.its.deploy.dae.pass</groupId>
20+
<artifactId>dae</artifactId>
21+
<version>1.0</version>
22+
</parent>
23+
<artifactId>module3</artifactId>
24+
25+
</project>
+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<!-- Licensed to the Apache Software Foundation (ASF) under one or more contributor
4+
license agreements. See the NOTICE file distributed with this work for additional
5+
information regarding copyright ownership. The ASF licenses this file to
6+
you under the Apache License, Version 2.0 (the "License"); you may not use
7+
this file except in compliance with the License. You may obtain a copy of
8+
the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required
9+
by applicable law or agreed to in writing, software distributed under the
10+
License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
11+
OF ANY KIND, either express or implied. See the License for the specific
12+
language governing permissions and limitations under the License. -->
13+
14+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
15+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
16+
<modelVersion>4.0.0</modelVersion>
17+
18+
<parent>
19+
<groupId>org.apache.maven.its.deploy.dae.pass</groupId>
20+
<artifactId>dae</artifactId>
21+
<version>1.0</version>
22+
</parent>
23+
<artifactId>module4</artifactId>
24+
25+
<!-- packaging without deploy plugin -->
26+
<packaging>without-deploy</packaging>
27+
28+
<build>
29+
<plugins>
30+
<plugin>
31+
<groupId>org.apache.maven.its.deploy.mock</groupId>
32+
<artifactId>mock-phase-maven-plugin</artifactId>
33+
<version>1.0</version>
34+
<extensions>true</extensions>
35+
</plugin>
36+
</plugins>
37+
</build>
38+
</project>

src/it/deploy-at-end-pass/pom.xml

+4-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ under the License.
3838
<distributionManagement>
3939
<repository>
4040
<id>it</id>
41-
<url>file:///${basedir}/target/repo</url>
41+
<url>file:///@remoteRepo@/deploy-at-end-pass</url>
4242
</repository>
4343
</distributionManagement>
4444

@@ -95,5 +95,8 @@ under the License.
9595

9696
<modules>
9797
<module>module1</module>
98+
<module>module2</module>
99+
<module>module3</module>
100+
<module>module4</module>
98101
</modules>
99102
</project>

src/it/deploy-at-end-pass/verify.groovy

+7-2
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,15 @@
1717
* under the License.
1818
*/
1919

20-
assert new File( basedir, "target/repo/org/apache/maven/its/deploy/dae/pass/dae/1.0/dae-1.0.pom" ).exists()
21-
assert new File( basedir, "module1/target/repo/org/apache/maven/its/deploy/dae/pass/module1/1.0/module1-1.0.pom" ).exists()
20+
assert new File( remoteRepo, "deploy-at-end-pass/org/apache/maven/its/deploy/dae/pass/dae/1.0/dae-1.0.pom" ).exists()
21+
assert new File( remoteRepo, "deploy-at-end-pass/org/apache/maven/its/deploy/dae/pass/module1/1.0/module1-1.0.pom" ).exists()
22+
assert new File( remoteRepo, "deploy-at-end-pass/org/apache/maven/its/deploy/dae/pass/module1/1.0/module1-1.0.jar" ).exists()
23+
assert new File( remoteRepo, "deploy-at-end-pass/org/apache/maven/its/deploy/dae/pass/module3/1.0/module3-1.0.pom" ).exists()
24+
assert new File( remoteRepo, "deploy-at-end-pass/org/apache/maven/its/deploy/dae/pass/module3/1.0/module3-1.0.jar" ).exists()
2225

2326
File buildLog = new File( basedir, 'build.log' )
2427
assert buildLog.exists()
2528
assert buildLog.text.contains( "[INFO] Deferring deploy for org.apache.maven.its.deploy.dae.pass:dae:1.0 at end" )
29+
assert buildLog.text.contains( "[INFO] Deferring deploy for org.apache.maven.its.deploy.dae.pass:module1:1.0 at end" )
30+
assert buildLog.text.contains( "[INFO] Deferring deploy for org.apache.maven.its.deploy.dae.pass:module3:1.0 at end" )
2631

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
18+
invoker.goals = install
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<!--
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
11+
12+
http://www.apache.org/licenses/LICENSE-2.0
13+
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.
20+
-->
21+
22+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
23+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
24+
<modelVersion>4.0.0</modelVersion>
25+
26+
<groupId>org.apache.maven.its.deploy.mock</groupId>
27+
<artifactId>mock-phase-maven-plugin</artifactId>
28+
<version>1.0</version>
29+
<packaging>maven-plugin</packaging>
30+
31+
<prerequisites>
32+
<maven>@mavenVersion@</maven>
33+
</prerequisites>
34+
35+
<description>plugin with Maven phase without m-deploy-p</description>
36+
37+
<build>
38+
<pluginManagement>
39+
<plugins>
40+
<plugin>
41+
<groupId>org.apache.maven.plugins</groupId>
42+
<artifactId>maven-install-plugin</artifactId>
43+
<version>@mavenInstallPluginVersion@</version>
44+
</plugin>
45+
<plugin>
46+
<groupId>org.apache.maven.plugins</groupId>
47+
<artifactId>maven-plugin-plugin</artifactId>
48+
<version>@mavenPluginToolsVersion@</version>
49+
<configuration>
50+
<skipErrorNoDescriptorsFound>true</skipErrorNoDescriptorsFound>
51+
</configuration>
52+
</plugin>
53+
</plugins>
54+
</pluginManagement>
55+
</build>
56+
57+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
3+
<!--
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
11+
12+
http://www.apache.org/licenses/LICENSE-2.0
13+
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.
20+
-->
21+
22+
<component-set>
23+
<components>
24+
<component>
25+
<role>org.apache.maven.lifecycle.mapping.LifecycleMapping</role>
26+
<role-hint>without-deploy</role-hint>
27+
<implementation>org.apache.maven.lifecycle.mapping.DefaultLifecycleMapping</implementation>
28+
<configuration>
29+
<lifecycles>
30+
<lifecycle>
31+
<id>default</id>
32+
<phases>
33+
<process-resources>org.apache.maven.plugins:maven-resources-plugin:resources</process-resources>
34+
</phases>
35+
</lifecycle>
36+
</lifecycles>
37+
</configuration>
38+
</component>
39+
</components>
40+
</component-set>

src/main/java/org/apache/maven/plugins/deploy/AbstractDeployMojo.java

+8-6
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
import org.apache.maven.plugins.annotations.Parameter;
2727
import org.apache.maven.rtinfo.RuntimeInformation;
2828
import org.eclipse.aether.RepositorySystem;
29-
import org.eclipse.aether.RepositorySystemSession;
3029
import org.eclipse.aether.deployment.DeployRequest;
3130
import org.eclipse.aether.deployment.DeploymentException;
3231
import org.eclipse.aether.repository.RemoteRepository;
@@ -122,10 +121,13 @@ protected RemoteRepository getRemoteRepository(final String repositoryId, final
122121
return result;
123122
}
124123

125-
/**
126-
* Handles high level retries (this was buried into MAT).
127-
*/
128-
protected void deploy(RepositorySystemSession session, DeployRequest deployRequest) throws MojoExecutionException {
124+
// I'm not sure if retries will work with deploying on client level ...
125+
// Most repository managers block a duplicate artifacts.
126+
127+
// Eg, when we have an artifact list, even simple pom and jar in one request with released version,
128+
// next try can fail due to duplicate.
129+
130+
protected void deploy(DeployRequest deployRequest) throws MojoExecutionException {
129131
int retryFailedDeploymentCounter = Math.max(1, Math.min(10, retryFailedDeploymentCount));
130132
DeploymentException exception = null;
131133
for (int count = 0; count < retryFailedDeploymentCounter; count++) {
@@ -134,7 +136,7 @@ protected void deploy(RepositorySystemSession session, DeployRequest deployReque
134136
getLog().info("Retrying deployment attempt " + (count + 1) + " of " + retryFailedDeploymentCounter);
135137
}
136138

137-
repositorySystem.deploy(session, deployRequest);
139+
repositorySystem.deploy(session.getRepositorySession(), deployRequest);
138140
exception = null;
139141
break;
140142
} catch (DeploymentException e) {

0 commit comments

Comments
 (0)