You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by rf...@apache.org on 2013/10/09 20:24:31 UTC
svn commit: r1530748 - in /maven/plugins/trunk/maven-install-plugin/src:
it/MINSTALL-99/ it/MINSTALL-99/module1/ it/MINSTALL-99/module2/
main/java/org/apache/maven/plugin/install/
test/java/org/apache/maven/plugin/install/
Author: rfscholte
Date: Wed Oct 9 18:24:31 2013
New Revision: 1530748
URL: http://svn.apache.org/r1530748
Log:
[MINSTALL-99] InstallAtEnd should respect plugin-configuration per project
Added:
maven/plugins/trunk/maven-install-plugin/src/it/MINSTALL-99/
maven/plugins/trunk/maven-install-plugin/src/it/MINSTALL-99/module1/
maven/plugins/trunk/maven-install-plugin/src/it/MINSTALL-99/module1/pom.xml
maven/plugins/trunk/maven-install-plugin/src/it/MINSTALL-99/module2/
maven/plugins/trunk/maven-install-plugin/src/it/MINSTALL-99/module2/pom.xml
maven/plugins/trunk/maven-install-plugin/src/it/MINSTALL-99/pom.xml
maven/plugins/trunk/maven-install-plugin/src/it/MINSTALL-99/verify.groovy
maven/plugins/trunk/maven-install-plugin/src/main/java/org/apache/maven/plugin/install/InstallRequest.java
Modified:
maven/plugins/trunk/maven-install-plugin/src/main/java/org/apache/maven/plugin/install/InstallMojo.java
maven/plugins/trunk/maven-install-plugin/src/test/java/org/apache/maven/plugin/install/InstallMojoTest.java
Added: maven/plugins/trunk/maven-install-plugin/src/it/MINSTALL-99/module1/pom.xml
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-install-plugin/src/it/MINSTALL-99/module1/pom.xml?rev=1530748&view=auto
==============================================================================
--- maven/plugins/trunk/maven-install-plugin/src/it/MINSTALL-99/module1/pom.xml (added)
+++ maven/plugins/trunk/maven-install-plugin/src/it/MINSTALL-99/module1/pom.xml Wed Oct 9 18:24:31 2013
@@ -0,0 +1,25 @@
+<?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>
+
+ <parent>
+ <groupId>org.apache.maven.its.minstall-99</groupId>
+ <artifactId>configperproject</artifactId>
+ <version>1.0</version>
+ </parent>
+ <artifactId>module1</artifactId>
+
+</project>
Added: maven/plugins/trunk/maven-install-plugin/src/it/MINSTALL-99/module2/pom.xml
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-install-plugin/src/it/MINSTALL-99/module2/pom.xml?rev=1530748&view=auto
==============================================================================
--- maven/plugins/trunk/maven-install-plugin/src/it/MINSTALL-99/module2/pom.xml (added)
+++ maven/plugins/trunk/maven-install-plugin/src/it/MINSTALL-99/module2/pom.xml Wed Oct 9 18:24:31 2013
@@ -0,0 +1,39 @@
+<?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>
+
+ <parent>
+ <groupId>org.apache.maven.its.minstall-99</groupId>
+ <artifactId>configperproject</artifactId>
+ <version>1.0</version>
+ </parent>
+ <artifactId>module2</artifactId>
+ <packaging>pom</packaging>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-install-plugin</artifactId>
+ <version>@project.version@</version>
+ <configuration>
+ <skip>true</skip>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
Added: maven/plugins/trunk/maven-install-plugin/src/it/MINSTALL-99/pom.xml
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-install-plugin/src/it/MINSTALL-99/pom.xml?rev=1530748&view=auto
==============================================================================
--- maven/plugins/trunk/maven-install-plugin/src/it/MINSTALL-99/pom.xml (added)
+++ maven/plugins/trunk/maven-install-plugin/src/it/MINSTALL-99/pom.xml Wed Oct 9 18:24:31 2013
@@ -0,0 +1,77 @@
+<?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.minstall-99</groupId>
+ <artifactId>configperproject</artifactId>
+ <version>1.0</version>
+ <packaging>pom</packaging>
+
+ <description>
+ Tests installation at end with different plugin configurations.
+ </description>
+
+ <properties>
+ <maven.test.skip>true</maven.test.skip>
+ </properties>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>2.0.2</version>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-install-plugin</artifactId>
+ <version>@project.version@</version>
+ <configuration>
+ <installAtEnd>true</installAtEnd>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jar-plugin</artifactId>
+ <version>2.1</version>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-resources-plugin</artifactId>
+ <version>2.2</version>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <version>2.12</version>
+ </plugin>
+ </plugins>
+ </build>
+
+ <modules>
+ <module>module1</module>
+ <module>module2</module>
+ </modules>
+
+</project>
Added: maven/plugins/trunk/maven-install-plugin/src/it/MINSTALL-99/verify.groovy
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-install-plugin/src/it/MINSTALL-99/verify.groovy?rev=1530748&view=auto
==============================================================================
--- maven/plugins/trunk/maven-install-plugin/src/it/MINSTALL-99/verify.groovy (added)
+++ maven/plugins/trunk/maven-install-plugin/src/it/MINSTALL-99/verify.groovy Wed Oct 9 18:24:31 2013
@@ -0,0 +1,22 @@
+/*
+ * 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.
+ */
+
+assert new File( basedir, "../../local-repo/org/apache/maven/its/minstall-99/configperproject/1.0/configperproject-1.0.pom" ).exists()
+assert new File( basedir, "../../local-repo/org/apache/maven/its/minstall-99/module1/1.0/module1-1.0.pom" ).exists()
+assert !( new File( basedir, "../../local-repo/org/apache/maven/its/minstall-99/module2/1.0/module2-1.0.pom" ).exists() )
Modified: maven/plugins/trunk/maven-install-plugin/src/main/java/org/apache/maven/plugin/install/InstallMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-install-plugin/src/main/java/org/apache/maven/plugin/install/InstallMojo.java?rev=1530748&r1=1530747&r2=1530748&view=diff
==============================================================================
--- maven/plugins/trunk/maven-install-plugin/src/main/java/org/apache/maven/plugin/install/InstallMojo.java (original)
+++ maven/plugins/trunk/maven-install-plugin/src/main/java/org/apache/maven/plugin/install/InstallMojo.java Wed Oct 9 18:24:31 2013
@@ -20,7 +20,9 @@ package org.apache.maven.plugin.install;
*/
import java.io.File;
+import java.util.ArrayList;
import java.util.Collection;
+import java.util.Collections;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;
@@ -37,9 +39,9 @@ import org.apache.maven.project.MavenPro
import org.apache.maven.project.artifact.ProjectArtifactMetadata;
/**
- * Installs the project's main artifact, and any other artifacts attached by other plugins in the lifecycle,
- * to the local repository.
- *
+ * Installs the project's main artifact, and any other artifacts attached by other plugins in the lifecycle, to the
+ * local repository.
+ *
* @author <a href="mailto:evenisse@apache.org">Emmanuel Venisse</a>
* @version $Id$
*/
@@ -49,9 +51,13 @@ public class InstallMojo
{
/**
- * When building with multiple threads, reaching the last project doesn't have to mean that all projects are ready to be installed
+ * When building with multiple threads, reaching the last project doesn't have to mean that all projects are ready
+ * to be installed
*/
- private static final AtomicInteger readyProjectsCounter = new AtomicInteger();
+ private static final AtomicInteger readyProjectsCounter = new AtomicInteger();
+
+ private static final List<InstallRequest> installRequests =
+ Collections.synchronizedList( new ArrayList<InstallRequest>() );
/**
*/
@@ -63,9 +69,9 @@ public class InstallMojo
private List<MavenProject> reactorProjects;
/**
- * Whether every project should be deployed during its own deploy-phase or at the end of the multimodule build.
- * If set to {@code true} and the build fails, none of the reactor projects is deployed
- *
+ * Whether every project should be deployed during its own deploy-phase or at the end of the multimodule build. If
+ * set to {@code true} and the build fails, none of the reactor projects is deployed
+ *
* @since 2.5
*/
@Parameter( defaultValue = "false", property = "installAtEnd" )
@@ -84,9 +90,9 @@ public class InstallMojo
private File pomFile;
/**
- * Set this to <code>true</code> to bypass artifact installation.
- * Use this for artifacts that does not need to be installed in the local repository.
- *
+ * Set this to <code>true</code> to bypass artifact installation. Use this for artifacts that does not need to be
+ * installed in the local repository.
+ *
* @since 2.4
*/
@Parameter( property = "maven.install.skip", defaultValue = "false" )
@@ -107,39 +113,58 @@ public class InstallMojo
public void execute()
throws MojoExecutionException
{
- int projectsReady = readyProjectsCounter.incrementAndGet();
+ boolean projectsReady = readyProjectsCounter.incrementAndGet() == reactorProjects.size();
if ( skip )
{
getLog().info( "Skipping artifact installation" );
- return;
- }
-
- if ( !installAtEnd )
- {
- installProject( project );
}
- else if ( projectsReady < reactorProjects.size() )
+ else
{
- getLog().info( "Installing " + project.getGroupId() + ":" + project.getArtifactId() + ":"
- + project.getVersion() + " at end" );
+ InstallRequest currentExecutionInstallRequest =
+ new InstallRequest().setProject( project ).setCreateChecksum( createChecksum ).setUpdateReleaseInfo( updateReleaseInfo );
+
+ if ( !installAtEnd )
+ {
+ installProject( currentExecutionInstallRequest );
+ }
+ else
+ {
+ installRequests.add( currentExecutionInstallRequest );
+
+ if ( !projectsReady )
+ {
+ getLog().info( "Installing " + project.getGroupId() + ":" + project.getArtifactId() + ":"
+ + project.getVersion() + " at end" );
+ }
+ }
+
}
- else
+
+ if ( projectsReady )
{
- for ( MavenProject reactorProject : reactorProjects )
+ synchronized ( installRequests )
{
- installProject( reactorProject );
+ while ( !installRequests.isEmpty() )
+ {
+ installProject( installRequests.remove( 0 ) );
+ }
}
}
}
- private void installProject( MavenProject project )
+ private void installProject( InstallRequest request )
throws MojoExecutionException
{
+ MavenProject project = request.getProject();
+ boolean createChecksum = request.isCreateChecksum();
+ boolean updateReleaseInfo = request.isUpdateReleaseInfo();
+
Artifact artifact = project.getArtifact();
String packaging = project.getPackaging();
File pomFile = project.getFile();
- @SuppressWarnings( "unchecked" ) List<Artifact> attachedArtifacts = project.getAttachedArtifacts();
+ @SuppressWarnings( "unchecked" )
+ List<Artifact> attachedArtifacts = project.getAttachedArtifacts();
// TODO: push into transformation
boolean isPomArtifact = "pom".equals( packaging );
@@ -196,7 +221,7 @@ public class InstallMojo
else
{
throw new MojoExecutionException(
- "The packaging for this project did not assign a file to the build artifact" );
+ "The packaging for this project did not assign a file to the build artifact" );
}
}
@@ -219,4 +244,5 @@ public class InstallMojo
{
this.skip = skip;
}
+
}
Added: maven/plugins/trunk/maven-install-plugin/src/main/java/org/apache/maven/plugin/install/InstallRequest.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-install-plugin/src/main/java/org/apache/maven/plugin/install/InstallRequest.java?rev=1530748&view=auto
==============================================================================
--- maven/plugins/trunk/maven-install-plugin/src/main/java/org/apache/maven/plugin/install/InstallRequest.java (added)
+++ maven/plugins/trunk/maven-install-plugin/src/main/java/org/apache/maven/plugin/install/InstallRequest.java Wed Oct 9 18:24:31 2013
@@ -0,0 +1,92 @@
+package org.apache.maven.plugin.install;
+
+/*
+ * 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 org.apache.maven.project.MavenProject;
+
+/**
+ *
+ * @author Robert Scholte
+ * @since 2.5.1
+ */
+public class InstallRequest
+{
+ // From AbstractInstallMojo
+
+ private boolean createChecksum;
+
+ private boolean updateReleaseInfo;
+
+ // From InstallMojo
+
+ private MavenProject project;
+
+ /**
+ * @return the createChecksum
+ */
+ public boolean isCreateChecksum()
+ {
+ return createChecksum;
+ }
+
+ /**
+ * @param createChecksum the createChecksum to set
+ */
+ public InstallRequest setCreateChecksum( boolean createChecksum )
+ {
+ this.createChecksum = createChecksum;
+ return this;
+ }
+
+ /**
+ * @return the updateReleaseInfo
+ */
+ public boolean isUpdateReleaseInfo()
+ {
+ return updateReleaseInfo;
+ }
+
+ /**
+ * @param updateReleaseInfo the updateReleaseInfo to set
+ */
+ public InstallRequest setUpdateReleaseInfo( boolean updateReleaseInfo )
+ {
+ this.updateReleaseInfo = updateReleaseInfo;
+ return this;
+ }
+
+ /**
+ * @return the project
+ */
+ public MavenProject getProject()
+ {
+ return project;
+ }
+
+ /**
+ * @param project the project to set
+ */
+ public InstallRequest setProject( MavenProject project )
+ {
+ this.project = project;
+ return this;
+ }
+
+}
Modified: maven/plugins/trunk/maven-install-plugin/src/test/java/org/apache/maven/plugin/install/InstallMojoTest.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-install-plugin/src/test/java/org/apache/maven/plugin/install/InstallMojoTest.java?rev=1530748&r1=1530747&r2=1530748&view=diff
==============================================================================
--- maven/plugins/trunk/maven-install-plugin/src/test/java/org/apache/maven/plugin/install/InstallMojoTest.java (original)
+++ maven/plugins/trunk/maven-install-plugin/src/test/java/org/apache/maven/plugin/install/InstallMojoTest.java Wed Oct 9 18:24:31 2013
@@ -29,6 +29,7 @@ import org.apache.maven.project.MavenPro
import org.apache.maven.shared.utils.io.FileUtils;
import java.io.File;
+import java.util.Collections;
import java.util.List;
/**
@@ -76,7 +77,9 @@ public class InstallMojoTest
+ "maven-install-test-1.0-SNAPSHOT.jar" );
MavenProject project = (MavenProject) getVariableValueFromObject( mojo, "project" );
-
+
+ setVariableValueToObject( mojo, "reactorProjects", Collections.singletonList( project ) );
+
artifact = (InstallArtifactStub) project.getArtifact();
artifact.setFile( file );
@@ -105,6 +108,8 @@ public class InstallMojoTest
MavenProject project = (MavenProject) getVariableValueFromObject( mojo, "project" );
+ setVariableValueToObject( mojo, "reactorProjects", Collections.singletonList( project ) );
+
List attachedArtifacts = project.getAttachedArtifacts();
mojo.execute();
@@ -140,6 +145,8 @@ public class InstallMojoTest
+ "maven-install-test-1.0-SNAPSHOT.jar" );
MavenProject project = (MavenProject) getVariableValueFromObject( mojo, "project" );
+
+ setVariableValueToObject( mojo, "reactorProjects", Collections.singletonList( project ) );
artifact = (InstallArtifactStub) project.getArtifact();
@@ -161,6 +168,8 @@ public class InstallMojoTest
MavenProject project = (MavenProject) getVariableValueFromObject( mojo, "project" );
+ setVariableValueToObject( mojo, "reactorProjects", Collections.singletonList( project ) );
+
artifact = (InstallArtifactStub) project.getArtifact();
artifact.setFile( null );
@@ -191,6 +200,8 @@ public class InstallMojoTest
MavenProject project = (MavenProject) getVariableValueFromObject( mojo, "project" );
+ setVariableValueToObject( mojo, "reactorProjects", Collections.singletonList( project ) );
+
String packaging = project.getPackaging();
assertEquals( "pom", packaging );
@@ -220,6 +231,8 @@ public class InstallMojoTest
MavenProject project = (MavenProject) getVariableValueFromObject( mojo, "project" );
+ setVariableValueToObject( mojo, "reactorProjects", Collections.singletonList( project ) );
+
artifact = (InstallArtifactStub) project.getArtifact();
boolean createChecksum = (Boolean) getVariableValueFromObject( mojo, "createChecksum" );
@@ -303,6 +316,8 @@ public class InstallMojoTest
MavenProject project = (MavenProject) getVariableValueFromObject( mojo, "project" );
+ setVariableValueToObject( mojo, "reactorProjects", Collections.singletonList( project ) );
+
artifact = (InstallArtifactStub) project.getArtifact();
artifact.setFile( file );