diff --git a/src/it/skip-release-jar/pom.xml b/src/it/skip-release-jar/pom.xml new file mode 100644 index 0000000..3e57a45 --- /dev/null +++ b/src/it/skip-release-jar/pom.xml @@ -0,0 +1,83 @@ + + + + + + 4.0.0 + + org.apache.maven.its.deploy.srj + test + 1.0 + jar + + + Tests the deployment of a simple release JAR has been skipped. + + + + true + + + + + it + file:///${basedir}/target/repo + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 2.0.2 + + + org.apache.maven.plugins + maven-deploy-plugin + @project.version@ + + releases + + + + org.apache.maven.plugins + maven-install-plugin + 2.2 + + + org.apache.maven.plugins + maven-jar-plugin + 2.1 + + + org.apache.maven.plugins + maven-resources-plugin + 2.2 + + + org.apache.maven.plugins + maven-surefire-plugin + 2.3.1 + + + + + diff --git a/src/it/skip-release-jar/setup.bsh b/src/it/skip-release-jar/setup.bsh new file mode 100644 index 0000000..bb1b4e8 --- /dev/null +++ b/src/it/skip-release-jar/setup.bsh @@ -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/srj" ); +System.out.println( "Deleting " + file ); +FileUtils.deleteDirectory( file ); + +file = new File( basedir, "target/repo" ); +System.out.println( "Deleting " + file ); +FileUtils.deleteDirectory( file ); + +return true; diff --git a/src/it/skip-release-jar/verify.bsh b/src/it/skip-release-jar/verify.bsh new file mode 100644 index 0000000..6fe5701 --- /dev/null +++ b/src/it/skip-release-jar/verify.bsh @@ -0,0 +1,40 @@ +/* + * 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.*; + +String[] paths = +{ + "org/apache/maven/its/deploy/srj/test/maven-metadata.xml", + "org/apache/maven/its/deploy/srj/test/1.0/test-1.0.pom", + "org/apache/maven/its/deploy/srj/test/1.0/test-1.0.jar", +}; + +for ( String path : paths ) +{ + File file = new File( new File( basedir, "target/repo" ), path ); + System.out.println( "Checking for existence of " + file ); + if ( file.isFile() ) + { + throw new FileNotFoundException( "File has been deployed: " + file.getAbsolutePath() ); + } +} + +return true; diff --git a/src/it/skip-snapshot-jar/pom.xml b/src/it/skip-snapshot-jar/pom.xml new file mode 100644 index 0000000..a58a66f --- /dev/null +++ b/src/it/skip-snapshot-jar/pom.xml @@ -0,0 +1,83 @@ + + + + + + 4.0.0 + + org.apache.maven.its.deploy.ssj + test + 1.0.0-SNAPSHOT + jar + + + Tests the deployment of a simple snapshot JAR has been skipped. + + + + true + + + + + it + file:///${basedir}/target/repo + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 2.0.2 + + + org.apache.maven.plugins + maven-deploy-plugin + @project.version@ + + snapshots + + + + org.apache.maven.plugins + maven-install-plugin + 2.2 + + + org.apache.maven.plugins + maven-jar-plugin + 2.1 + + + org.apache.maven.plugins + maven-resources-plugin + 2.2 + + + org.apache.maven.plugins + maven-surefire-plugin + 2.3.1 + + + + + diff --git a/src/it/skip-snapshot-jar/setup.bsh b/src/it/skip-snapshot-jar/setup.bsh new file mode 100644 index 0000000..f35751b --- /dev/null +++ b/src/it/skip-snapshot-jar/setup.bsh @@ -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/ssj" ); +System.out.println( "Deleting " + file ); +FileUtils.deleteDirectory( file ); + +file = new File( basedir, "target/repo" ); +System.out.println( "Deleting " + file ); +FileUtils.deleteDirectory( file ); + +return true; diff --git a/src/it/skip-snapshot-jar/verify.bsh b/src/it/skip-snapshot-jar/verify.bsh new file mode 100644 index 0000000..1c35d56 --- /dev/null +++ b/src/it/skip-snapshot-jar/verify.bsh @@ -0,0 +1,46 @@ +/* + * 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.*; + +String[] paths = +{ + "org/apache/maven/its/deploy/ssj/test/maven-metadata.xml", + "org/apache/maven/its/deploy/ssj/test/1.0.0-SNAPSHOT/test-1.0.0-SNAPSHOT.pom", + "org/apache/maven/its/deploy/ssj/test/1.0.0-SNAPSHOT/test-1.0.0-SNAPSHOT.jar", +}; + +for ( String path : paths ) +{ + File file = new File( new File( basedir, "target/repo" ), path ); + System.out.println( "Checking for existence of " + file ); + if ( file.isFile() ) + { + throw new IllegalStateException( "File has been deployed: " + file.getAbsolutePath() ); + } +} + +File directory = new File( new File( basedir, "target/repo" ), "org/apache/maven/its/deploy/ssj/test/1.0.0-SNAPSHOT/" ); +if ( directory.exists() ) +{ + throw new IllegalStateException( "directory exists: " + directory.getAbsolutePath() ); +} + +return true; diff --git a/src/main/java/org/apache/maven/plugins/deploy/DeployMojo.java b/src/main/java/org/apache/maven/plugins/deploy/DeployMojo.java index 0953ff6..5bc471d 100644 --- a/src/main/java/org/apache/maven/plugins/deploy/DeployMojo.java +++ b/src/main/java/org/apache/maven/plugins/deploy/DeployMojo.java @@ -124,11 +124,17 @@ public class DeployMojo /** * Set this to 'true' to bypass artifact deploy - * + * Since since 3.0.0-M2 it's not anymore a real boolean as it can have more than 2 values: + * * @since 2.4 */ @Parameter( property = "maven.deploy.skip", defaultValue = "false" ) - private boolean skip; + private String skip = Boolean.FALSE.toString(); /** * Component used to deploy project. @@ -140,7 +146,10 @@ public void execute() throws MojoExecutionException, MojoFailureException { boolean addedDeployRequest = false; - if ( skip ) + if ( Boolean.parseBoolean( skip ) + || ( "releases".equals( skip ) && !ArtifactUtils.isSnapshot( project.getVersion() ) ) + || ( "snapshots".equals( skip ) && ArtifactUtils.isSnapshot( project.getVersion() ) ) + ) { getLog().info( "Skipping artifact deployment" ); } diff --git a/src/test/java/org/apache/maven/plugins/deploy/DeployMojoTest.java b/src/test/java/org/apache/maven/plugins/deploy/DeployMojoTest.java index 6c6f938..ee762ef 100644 --- a/src/test/java/org/apache/maven/plugins/deploy/DeployMojoTest.java +++ b/src/test/java/org/apache/maven/plugins/deploy/DeployMojoTest.java @@ -271,7 +271,7 @@ public void testSkippingDeploy() assertEquals( "file", repo.getProtocol() ); assertEquals( "file://" + getBasedir() + "/target/remote-repo/basic-deploy-test", repo.getUrl() ); - setVariableValueToObject( mojo, "skip", Boolean.TRUE ); + setVariableValueToObject( mojo, "skip", Boolean.TRUE.toString() ); mojo.execute();