Happy new year
Project: http://git-wip-us.apache.org/repos/asf/commons-release-plugin/repo Commit: http://git-wip-us.apache.org/repos/asf/commons-release-plugin/commit/bb999955 Tree: http://git-wip-us.apache.org/repos/asf/commons-release-plugin/tree/bb999955 Diff: http://git-wip-us.apache.org/repos/asf/commons-release-plugin/diff/bb999955 Branch: refs/heads/master Commit: bb999955f1ac5609d7a5c9ba5df93f883ffffa91 Parents: 977f9bb Author: Rob Tompkins <chtom...@apache.org> Authored: Sat Jan 6 20:32:30 2018 -0500 Committer: Rob Tompkins <chtom...@apache.org> Committed: Sat Jan 6 20:32:30 2018 -0500 ---------------------------------------------------------------------- NOTICE.txt | 2 +- pom.xml | 1 + .../mojos/CommonsSiteCompressionMojo.java | 11 +++-- .../mojos/CommonsSiteCompressionMojoTest.java | 20 +++++++- .../compress-site/compress-site-failure.xml | 51 ++++++++++++++++++++ .../mojos/compress-site/compress-site.xml | 1 - .../mojos/compress-site/example-site/index.html | 18 +++++++ 7 files changed, 95 insertions(+), 9 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/commons-release-plugin/blob/bb999955/NOTICE.txt ---------------------------------------------------------------------- diff --git a/NOTICE.txt b/NOTICE.txt index c6952f6..17bc4f0 100644 --- a/NOTICE.txt +++ b/NOTICE.txt @@ -1,5 +1,5 @@ Apache Commons Build Plugin -Copyright 2008-2017 The Apache Software Foundation +Copyright 2008-2018 The Apache Software Foundation This product includes software developed at The Apache Software Foundation (http://www.apache.org/). http://git-wip-us.apache.org/repos/asf/commons-release-plugin/blob/bb999955/pom.xml ---------------------------------------------------------------------- diff --git a/pom.xml b/pom.xml index 2061351..d0bc295 100644 --- a/pom.xml +++ b/pom.xml @@ -69,6 +69,7 @@ <maven.compiler.source>1.7</maven.compiler.source> <maven.compiler.target>1.7</maven.compiler.target> <maven.dependency.version>3.5.2</maven.dependency.version> + <commons.jacoco.version>0.7.9</commons.jacoco.version> <commons.manifestfile/> <commons.componentid>commons-release-plugin</commons.componentid> <commons.jira.id>COMMONSSITE</commons.jira.id> http://git-wip-us.apache.org/repos/asf/commons-release-plugin/blob/bb999955/src/main/java/org/apache/commons/release/plugin/mojos/CommonsSiteCompressionMojo.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/release/plugin/mojos/CommonsSiteCompressionMojo.java b/src/main/java/org/apache/commons/release/plugin/mojos/CommonsSiteCompressionMojo.java index b54e6af..c5d5af9 100644 --- a/src/main/java/org/apache/commons/release/plugin/mojos/CommonsSiteCompressionMojo.java +++ b/src/main/java/org/apache/commons/release/plugin/mojos/CommonsSiteCompressionMojo.java @@ -55,11 +55,6 @@ public class CommonsSiteCompressionMojo extends AbstractMojo { @Parameter(defaultValue = "${project.build.directory}/site", alias = "siteOutputDirectory") private File siteDirectory; - /** - */ - @Parameter(required = true) - private String distSvnStagingUrl; - private ScatterZipOutputStream dirs; private ParallelScatterZipCreator scatterZipCreator; @@ -68,6 +63,12 @@ public class CommonsSiteCompressionMojo extends AbstractMojo { @Override public void execute() throws MojoExecutionException, MojoFailureException { + if (!siteDirectory.exists()) { + getLog().error("\"mvn site\" was not run before this goal, or a siteDirectory did not exist."); + throw new MojoFailureException( + "\"mvn site\" was not run before this goal, or a siteDirectory did not exist." + ); + } if (!workingDirectory.exists()) { SharedFunctions.initDirectory(getLog(), workingDirectory); } http://git-wip-us.apache.org/repos/asf/commons-release-plugin/blob/bb999955/src/test/java/org/apache/commons/release/plugin/mojos/CommonsSiteCompressionMojoTest.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/release/plugin/mojos/CommonsSiteCompressionMojoTest.java b/src/test/java/org/apache/commons/release/plugin/mojos/CommonsSiteCompressionMojoTest.java index d594149..50313b3 100644 --- a/src/test/java/org/apache/commons/release/plugin/mojos/CommonsSiteCompressionMojoTest.java +++ b/src/test/java/org/apache/commons/release/plugin/mojos/CommonsSiteCompressionMojoTest.java @@ -16,7 +16,7 @@ */ package org.apache.commons.release.plugin.mojos; -import org.apache.maven.plugin.testing.AbstractMojoTestCase; +import org.apache.maven.plugin.MojoFailureException; import org.apache.maven.plugin.testing.MojoRule; import org.junit.Rule; import org.junit.Test; @@ -24,6 +24,7 @@ import org.junit.Test; import java.io.File; import static junit.framework.TestCase.assertTrue; +import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; /** @@ -48,7 +49,7 @@ public class CommonsSiteCompressionMojoTest { protected CommonsSiteCompressionMojo mojo; @Test - public void testCompressSite() throws Exception { + public void testCompressSiteSuccess() throws Exception { File testFile = new File("src/test/resources/mojos/compress-site/compress-site.xml"); assertNotNull(testFile); assertTrue(testFile.exists()); @@ -57,4 +58,19 @@ public class CommonsSiteCompressionMojoTest { File siteZip = new File("target/commons-release-plugin/site.zip"); assertTrue(siteZip.exists()); } + + @Test + public void testCompressSiteDirNonExistentFailure() throws Exception { + File testFile = new File("src/test/resources/mojos/compress-site/compress-site-failure.xml"); + assertNotNull(testFile); + assertTrue(testFile.exists()); + mojo = (CommonsSiteCompressionMojo) rule.lookupMojo("compress-site", testFile); + try { + mojo.execute(); + } catch (MojoFailureException e) { + assertEquals( + "\"mvn site\" was not run before this goal, or a siteDirectory did not exist.", e.getMessage() + ); + } + } } http://git-wip-us.apache.org/repos/asf/commons-release-plugin/blob/bb999955/src/test/resources/mojos/compress-site/compress-site-failure.xml ---------------------------------------------------------------------- diff --git a/src/test/resources/mojos/compress-site/compress-site-failure.xml b/src/test/resources/mojos/compress-site/compress-site-failure.xml new file mode 100644 index 0000000..1c3042d --- /dev/null +++ b/src/test/resources/mojos/compress-site/compress-site-failure.xml @@ -0,0 +1,51 @@ +<?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.commons.plugin.my.unit</groupId> + <artifactId>compress-site-test-failure</artifactId> + <version>1.0-SNAPSHOT</version> + <packaging>jar</packaging> + <name>Test MyMojo</name> + + <dependencies> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <version>3.8.1</version> + <scope>test</scope> + </dependency> + </dependencies> + <build> + <plugins> + <plugin> + <groupId>org.apache.commons</groupId> + <artifactId>commons-release-plugin</artifactId> + <configuration> + <workingDirectory>target/commons-release-plugin</workingDirectory> + <siteDirectory>${basedir}/target/test-classes/mojos/junk</siteDirectory> + </configuration> + </plugin> + </plugins> + </build> +</project> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/commons-release-plugin/blob/bb999955/src/test/resources/mojos/compress-site/compress-site.xml ---------------------------------------------------------------------- diff --git a/src/test/resources/mojos/compress-site/compress-site.xml b/src/test/resources/mojos/compress-site/compress-site.xml index 40db1ac..c7e399b 100644 --- a/src/test/resources/mojos/compress-site/compress-site.xml +++ b/src/test/resources/mojos/compress-site/compress-site.xml @@ -43,7 +43,6 @@ <artifactId>commons-release-plugin</artifactId> <configuration> <workingDirectory>target/commons-release-plugin</workingDirectory> - <distSvnStagingUrl>aBadUrl</distSvnStagingUrl> <siteDirectory>${basedir}/target/test-classes/mojos/compress-site/example-site</siteDirectory> </configuration> </plugin> http://git-wip-us.apache.org/repos/asf/commons-release-plugin/blob/bb999955/src/test/resources/mojos/compress-site/example-site/index.html ---------------------------------------------------------------------- diff --git a/src/test/resources/mojos/compress-site/example-site/index.html b/src/test/resources/mojos/compress-site/example-site/index.html index 515cdbe..c9a72dd 100644 --- a/src/test/resources/mojos/compress-site/example-site/index.html +++ b/src/test/resources/mojos/compress-site/example-site/index.html @@ -1,4 +1,22 @@ <html> +<!-- + ~ 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. + --> <header><title>Mock maven site</title></header> <body> mock body