branch develop updated (5b75d40 -> 3e93d17)
This is an automated email from the git hooks/post-receive script. New change to branch develop in repository maven-helper-plugin. See http://git.nuiton.org/maven-helper-plugin.git from 5b75d40 fixes #3555: Migrates to git new 940d9a6 use Maven 3.0 Api (refs #3702) + introduce Test Api module (refs #3703) new d9af559 use Parameter instead of deprecated Component annotation for MavenProject and Settings (refs #3703) new 22b9ef3 use jdk 7 api (refs #3702) new 20eb087 make javadoc jdk8 compat (refs #3702) new 3e93d17 fixes #3702: Use maven 3 API fixes #3703: Split mojo Api in two modules (one with Api and one with test Api) Merge branch 'feature/3702' into develop The 5 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "adds" were already present in the repository and have only been added to this reference. Detailed log of new commits: commit 3e93d173dffec25358f52a802efd0133b82a80db Merge: 5b75d40 20eb087 Author: Tony CHEMIT <chemit@codelutin.com> Date: Mon May 25 15:48:53 2015 +0200 fixes #3702: Use maven 3 API fixes #3703: Split mojo Api in two modules (one with Api and one with test Api) Merge branch 'feature/3702' into develop commit 20eb087a770db3410d4a7f7357f896b0363c3716 Author: Tony CHEMIT <chemit@codelutin.com> Date: Mon May 25 15:41:33 2015 +0200 make javadoc jdk8 compat (refs #3702) commit 22b9ef3718ef42770452c303a7abe8fa5f0fff8d Author: Tony CHEMIT <chemit@codelutin.com> Date: Mon May 25 15:23:31 2015 +0200 use jdk 7 api (refs #3702) commit d9af5591259d2c7c8f3601078072e68cd0f01338 Author: Tony CHEMIT <chemit@codelutin.com> Date: Mon May 25 12:42:55 2015 +0200 use Parameter instead of deprecated Component annotation for MavenProject and Settings (refs #3703) commit 940d9a622f756b46d2e4cf65b985609c57db50f2 Author: Tony CHEMIT <chemit@codelutin.com> Date: Mon May 25 12:34:11 2015 +0200 use Maven 3.0 Api (refs #3702) + introduce Test Api module (refs #3703) Summary of changes: helper-maven-plugin-api/pom.xml | 112 +----- .../src/main/java/org/nuiton/io/FileUpdater.java | 6 +- .../main/java/org/nuiton/io/FileUpdaterHelper.java | 6 +- .../java/org/nuiton/io/MirroredFileUpdater.java | 4 +- .../io/PropertiesDateRemoveFilterStream.java | 3 +- .../main/java/org/nuiton/io/SortedProperties.java | 25 +- .../nuiton/plugin/AbstractAvailableDataMojo.java | 5 +- .../java/org/nuiton/plugin/AbstractPlugin.java | 183 ++++------ .../java/org/nuiton/plugin/DependencyUtil.java | 33 +- .../src/main/java/org/nuiton/plugin/Plugin.java | 4 +- .../main/java/org/nuiton/plugin/PluginHelper.java | 40 +-- .../java/org/nuiton/plugin/PluginIOContext.java | 6 +- .../java/org/nuiton/plugin/PluginWithEncoding.java | 5 +- .../nuiton/plugin/VelocityTemplateGenerator.java | 23 +- .../java/org/nuiton/plugin/AbstractMojoTest.java | 387 --------------------- .../java/org/nuiton/plugin/PluginHelperTest.java | 2 +- .../test/java/org/nuiton/plugin/TestHelper.java | 121 ------- .../test/resources/org/nuiton/io/JaxxDummy.java | 2 +- .../LICENSE.txt | 0 .../README.txt | 0 .../changelog.txt | 0 .../pom.xml | 130 ++----- .../src/license/THIRD-PARTY.properties | 0 .../main/java/org/nuiton/plugin/MojoTestRule.java | 243 +++++++++++++ .../main/java/org/nuiton/plugin/TestHelper.java | 117 +++++++ .../src/site/apt/index.apt | 17 + .../src/site/apt/mojo-testFramework.apt | 22 +- helper-maven-plugin-test-api/src/site/site.xml | 31 ++ helper-maven-plugin/pom.xml | 27 +- .../java/org/nuiton/helper/io/mail/MailSender.java | 5 +- .../helper/io/mail/ProjectJavamailMailSender.java | 7 +- .../helper/plugin/CheckAutoContainerPlugin.java | 249 +++++++------ .../org/nuiton/helper/plugin/CollectFilesMojo.java | 98 ++---- .../helper/plugin/ExecuteRemoteCommandMojo.java | 45 ++- .../org/nuiton/helper/plugin/SendEmailMojo.java | 30 +- .../helper/plugin/ShareServerSecretPlugin.java | 57 ++- .../helper/plugin/TransformProjectVersionMojo.java | 38 +- .../plugin/CheckAutoContainerPluginTest.java | 42 +++ .../nuiton/helper/plugin/SendEmailMojoTest.java | 76 ++-- .../plugin/TransformProjectVersionMojoTest.java | 60 ++-- .../src/test/resources/log4j.properties | 0 .../checkAutoContainerPluginTest/central.xml} | 34 +- pom.xml | 48 ++- 43 files changed, 982 insertions(+), 1361 deletions(-) delete mode 100644 helper-maven-plugin-api/src/test/java/org/nuiton/plugin/AbstractMojoTest.java delete mode 100644 helper-maven-plugin-api/src/test/java/org/nuiton/plugin/TestHelper.java copy LICENSE.txt => helper-maven-plugin-test-api/LICENSE.txt (100%) copy {helper-maven-plugin-api => helper-maven-plugin-test-api}/README.txt (100%) copy {helper-maven-plugin-api => helper-maven-plugin-test-api}/changelog.txt (100%) copy {helper-maven-plugin-api => helper-maven-plugin-test-api}/pom.xml (71%) copy {helper-maven-plugin-api => helper-maven-plugin-test-api}/src/license/THIRD-PARTY.properties (100%) create mode 100644 helper-maven-plugin-test-api/src/main/java/org/nuiton/plugin/MojoTestRule.java create mode 100644 helper-maven-plugin-test-api/src/main/java/org/nuiton/plugin/TestHelper.java create mode 100644 helper-maven-plugin-test-api/src/site/apt/index.apt rename {helper-maven-plugin-api => helper-maven-plugin-test-api}/src/site/apt/mojo-testFramework.apt (86%) create mode 100644 helper-maven-plugin-test-api/src/site/site.xml create mode 100644 helper-maven-plugin/src/test/java/org/nuiton/helper/plugin/CheckAutoContainerPluginTest.java copy {helper-maven-plugin-api => helper-maven-plugin}/src/test/resources/log4j.properties (100%) copy helper-maven-plugin/src/{it/check-auto-container/central/pom.xml => test/resources/org/nuiton/helper/plugin/checkAutoContainerPluginTest/central.xml} (77%) -- To stop receiving notification emails like this one, please contact nuiton.org SCM administrator <admin+scm@nuiton.org>.
This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository maven-helper-plugin. See http://git.nuiton.org/maven-helper-plugin.git commit 940d9a622f756b46d2e4cf65b985609c57db50f2 Author: Tony CHEMIT <chemit@codelutin.com> Date: Mon May 25 12:34:11 2015 +0200 use Maven 3.0 Api (refs #3702) + introduce Test Api module (refs #3703) --- helper-maven-plugin-api/pom.xml | 112 +----- .../java/org/nuiton/plugin/AbstractMojoTest.java | 387 --------------------- .../test/java/org/nuiton/plugin/TestHelper.java | 121 ------- helper-maven-plugin-test-api/LICENSE.txt | 165 +++++++++ helper-maven-plugin-test-api/README.txt | 0 helper-maven-plugin-test-api/changelog.txt | 0 .../pom.xml | 130 ++----- .../src/license/THIRD-PARTY.properties | 32 ++ .../main/java/org/nuiton/plugin/MojoTestRule.java | 222 ++++++++++++ .../main/java/org/nuiton/plugin/TestHelper.java | 117 +++++++ .../src/site/apt/index.apt | 17 + .../src/site/apt/mojo-testFramework.apt | 22 +- helper-maven-plugin-test-api/src/site/site.xml | 31 ++ helper-maven-plugin/pom.xml | 27 +- .../nuiton/helper/plugin/SendEmailMojoTest.java | 79 +++-- .../plugin/TransformProjectVersionMojoTest.java | 58 +-- .../src/test/resources/log4j.properties | 32 ++ pom.xml | 48 ++- 18 files changed, 784 insertions(+), 816 deletions(-) diff --git a/helper-maven-plugin-api/pom.xml b/helper-maven-plugin-api/pom.xml index 49482e6..e6544b6 100644 --- a/helper-maven-plugin-api/pom.xml +++ b/helper-maven-plugin-api/pom.xml @@ -69,75 +69,41 @@ <!-- provided dependencies --> - <dependency> + <!--dependency> <groupId>org.codehaus.plexus</groupId> <artifactId>plexus-container-default</artifactId> + </dependency--> + + <dependency> + <groupId>org.apache.maven</groupId> + <artifactId>maven-core</artifactId> + <scope>provided</scope> </dependency> <dependency> <groupId>org.apache.maven</groupId> - <artifactId>maven-project</artifactId> - <version>${mavenVersion}</version> + <artifactId>maven-compat</artifactId> <scope>provided</scope> </dependency> <dependency> <groupId>org.apache.maven</groupId> <artifactId>maven-model</artifactId> - <version>${mavenVersion}</version> <scope>provided</scope> </dependency> <dependency> <groupId>org.apache.maven</groupId> <artifactId>maven-artifact</artifactId> - <version>${mavenVersion}</version> <scope>provided</scope> </dependency> <dependency> <groupId>org.apache.maven</groupId> <artifactId>maven-plugin-api</artifactId> - <version>${mavenVersion}</version> <scope>provided</scope> </dependency> - <!-- tests dependencies --> - - <dependency> - <groupId>org.apache.maven.plugin-testing</groupId> - <artifactId>maven-plugin-testing-harness</artifactId> - <scope>test</scope> - <exclusions> - - <exclusion> - <groupId>org.codehaus.plexus</groupId> - <artifactId>plexus-archiver</artifactId> - </exclusion> - - <exclusion> - <groupId>org.apache.maven.wagon</groupId> - <artifactId>wagon-http-lightweight</artifactId> - </exclusion> - - <exclusion> - <groupId>org.apache.maven.wagon</groupId> - <artifactId>wagon-file</artifactId> - </exclusion> - - <exclusion> - <groupId>org.apache.maven.wagon</groupId> - <artifactId>wagon-ssh</artifactId> - </exclusion> - - <exclusion> - <groupId>org.apache.maven.reporting</groupId> - <artifactId>maven-reporting-api</artifactId> - </exclusion> - - </exclusions> - </dependency> - <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> @@ -166,21 +132,6 @@ </testResource> </testResources> - <plugins> - - <plugin> - <artifactId>maven-jar-plugin</artifactId> - <executions> - <execution> - <id>attach-test</id> - <goals> - <goal>test-jar</goal> - </goals> - </execution> - </executions> - </plugin> - </plugins> - </build> <profiles> @@ -234,52 +185,6 @@ </reporting> </profile> - <!-- to deploy snapshot or release without anything else --> - <profile> - <id>release-profile</id> - <activation> - <property> - <name>performRelease</name> - <value>true</value> - </property> - </activation> - - <build> - <plugins> - - <!-- always compute source jar --> - <plugin> - <artifactId>maven-source-plugin</artifactId> - <executions> - <execution> - <id>attach-sources</id> - <goals> - <goal>jar</goal> - <goal>test-jar</goal> - </goals> - </execution> - </executions> - </plugin> - - <!-- always compute javadoc jar --> - <plugin> - <artifactId>maven-javadoc-plugin</artifactId> - <executions> - <execution> - <id>attach-javadocs</id> - <goals> - <goal>jar</goal> - <goal>test-jar</goal> - </goals> - </execution> - </executions> - </plugin> - - </plugins> - </build> - - </profile> - <!-- prepare the assembly at release time --> <profile> <id>release-assembly-profile</id> @@ -320,7 +225,6 @@ </profile> - </profiles> </project> diff --git a/helper-maven-plugin-api/src/test/java/org/nuiton/plugin/AbstractMojoTest.java b/helper-maven-plugin-api/src/test/java/org/nuiton/plugin/AbstractMojoTest.java deleted file mode 100644 index a528633..0000000 --- a/helper-maven-plugin-api/src/test/java/org/nuiton/plugin/AbstractMojoTest.java +++ /dev/null @@ -1,387 +0,0 @@ -package org.nuiton.plugin; - -/* - * #%L - * Helper Maven Plugin :: API - * %% - * Copyright (C) 2009 - 2012 Codelutin, Tony Chemit - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/lgpl-3.0.html>. - * #L% - */ - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.apache.maven.plugin.Mojo; -import org.apache.maven.project.DefaultProjectBuilderConfiguration; -import org.apache.maven.project.MavenProject; -import org.apache.maven.project.MavenProjectBuilder; -import org.apache.maven.project.ProjectBuilderConfiguration; -import org.junit.Assert; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.TestName; -import org.junit.runner.Description; - -import java.beans.Introspector; -import java.io.File; -import java.io.IOException; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -/** - * Base test class for a mojo. - * <p/> - * <b>Note:</b> replace the previous class {@code org.nuiton.util.BasePluginTestCase}. - * <p/> - * Inside each test method, we can use the following objects : - * <p/> - * <ul> <li>{@link #getTestDir()} : location of mojo resources (where the pom - * file for example)</li> <li>{@link #getPomFile()} : location of the pom - * file</li> <li>{@link #getMojo()} : the instanciated and ready to execute - * mojo</li> </ul> - * <p/> - * To change the behaviour of initialization of mojo, you can override the - * following methods : <ul> <li>{@link #getBasedir()} </li> <li>{@link - * #getTestBasedir()} </li> <li>{@link #getTestDir(String, String)}</li> - * <li>{@link #getPomFile(File, String, String)}</li> <li>{@link - * #createMojo(File, String)}</li> <li>{@link #setUpMojo(Plugin, File)}</li> - * </ul> - * - * @param <P> type of goal to test - * @author tchemit <chemit@codelutin.com> - * @since 1.0.3 - */ -public abstract class AbstractMojoTest<P extends Plugin> { - - /** Logger. */ - private static final Log log = LogFactory.getLog(AbstractMojoTest.class); - - /** the basedir of the project */ - protected static File basedir; - - /** the basedir of all tests (by convention {@code getBasedir()/target/test-classes}). */ - protected static File testBasedir; - - /** - * Your test rule which offers methodName, testDir, pomFile and mojo inside - * test methods. - */ - @Rule - public MojoTestRule name = new MojoTestRule(); - - public File getBasedir() { - if (basedir == null) { - basedir = TestHelper.getBasedir(); - if (log.isDebugEnabled()) { - log.debug("basedir = " + basedir); - } - } - return basedir; - } - - public File getTestBasedir() { - if (testBasedir == null) { - testBasedir = TestHelper.getFile(getBasedir(), - "target", - "test-classes" - ); - if (log.isDebugEnabled()) { - log.debug("testBasedir = " + testBasedir); - } - } - return testBasedir; - } - - public String getRelativePathFromBasedir(File f) { - return TestHelper.getRelativePath(getBasedir(), f); - } - - public String getRelativePathFromTestBasedir(File f) { - return TestHelper.getRelativePath(getTestBasedir(), f); - } - - /** - * Obtain the name of the goal according to the methodName. - * <p/> - * By convention, we should consider that a test class use always the same - * goal's name. - * - * @param methodName the name of the next test to execute. - * @return the name of the goal to test for the given method test name. - */ - protected abstract String getGoalName(String methodName); - - /** - * Obtain the location of the directory where to find resources for the next - * test. - * <p/> - * By convention, will be the package named by the test class name from the - * {@link #getTestBasedir()}. - * - * @param methodName the method of the next test to execute - * @param goalName the common goal name to use - * @return the directory where to find resources for the test - */ - protected File getTestDir(String methodName, String goalName) { - - //TC-20091101 use a decipatilize simple name to avoid conflict of - // package with existing class name. - String rep = getClass().getPackage().getName() + "." + - Introspector.decapitalize(getClass().getSimpleName()); - String[] paths = rep.split("\\."); - File testDir = TestHelper.getFile(getTestBasedir(), paths); - if (isVerbose()) { - log.info("test dir = " + getRelativePathFromBasedir(testDir)); - } else if (log.isDebugEnabled()) { - log.debug("test dir = " + getRelativePathFromBasedir(testDir)); - } - - return testDir; - } - - /** - * Obtain the location of the pom file to use for next mojo test. - * <p/> - * By default, the pom file is the file with name {@code methodName+".xml"} - * in the {@code testDir}. - * - * @param testDir the location of resources for the next test (is the - * result of the method {@link #getTestDir(String, - * String)}. - * @param methodName the name of the next test - * @param goalName the name of the common goal - * @return the location of the pom file for the next mojo test. - */ - protected File getPomFile(File testDir, String methodName, String goalName) { - File pom = new File(testDir, methodName + ".xml"); - - if (isVerbose()) { - log.info("pom file = " + getRelativePathFromBasedir(pom)); - } else if (log.isDebugEnabled()) { - log.debug("pom file = " + getRelativePathFromBasedir(pom)); - } - - return pom; - } - - /** - * Create the mojo base on the given {@code pomFile} for the given {@code - * goalName}. - * - * @param pomFile the location of the pom file - * @param goalName the name of the goal to lookup - * @return the instanciated mojo - * @throws Exception if any problem while creating the mojo - */ - @SuppressWarnings("unchecked") - protected P createMojo(File pomFile, String goalName) throws Exception { - Mojo lookupMojo = TestHelper.lookupMojo(goalName, pomFile); - P result = (P) lookupMojo; - return result; - } - - /** - * Initialize the given mojo. - * - * @param mojo the instanciate mojo - * @param pomFile the pom file used to instanciate the mojo - * @throws Exception if any pb - */ - protected void setUpMojo(P mojo, File pomFile) throws Exception { - - MavenProject project = mojo.getProject(); - if (project == null) { - - log.debug("init maven project"); - MavenProjectBuilder projectBuilder = (MavenProjectBuilder) - TestHelper.getDelegateMojoTest().getContainer().lookup( - MavenProjectBuilder.ROLE - ); - ProjectBuilderConfiguration projectBuilderConfiguration = - new DefaultProjectBuilderConfiguration(); - project = projectBuilder.build(pomFile, projectBuilderConfiguration); - -// project = new MavenProject(); - - mojo.setProject(project); - } - - mojo.getProject().setFile(pomFile); - } - - protected P getMojo() { - return name.getMojo(); - } - - protected String getMethodName() { - return name.getMethodName(); - } - - protected File getPomFile() { - return name.getPomFile(); - } - - protected File getTestDir() { - return name.getTestDir(); - } - - protected boolean isVerbose() { - return TestHelper.isVerbose(); - } - - protected void clearMojo(P mojo) { - - // by default do nothing - } - - /** - * Checks on the given {@code file} that : - * <ul> - * <li>file exists</li> - * <li>the given {@code pattern} exists {@code required = true} - * (or not {@code required = false}) in the content of the file.</li> - * </ul> - * - * @param file the file to test - * @param pattern the pattern to search - * @param encoding encoding of the file to read - * @param required flag to says if pattern should (or not) be found in - * file's content - * @throws IOException if could not read file - */ - public void checkExistsPattern(File file, - String pattern, - String encoding, - boolean required) throws IOException { - - // checks file exists - assertTrue("File '" + file + "' does not exist, but should...", - file.exists() - ); - - //obtain file content as a string - String content = PluginHelper.readAsString(file, encoding); - - checkPattern(file, content, pattern, required); - } - - public void checkPattern(File file, - String content, - String pattern, - boolean required) throws IOException { - - String errorMessage = required ? "could not find the pattern : " : - "should not have found pattern :"; - - // checks pattern found (or not) in file's content - assertEquals(errorMessage + pattern + " in '" + file + "'", - required, - content.contains(pattern) - ); - } - - /** - * To offer inside each test method (annotated by a {@link Test}) the - * following properties : - * <p/> - * <ul> <li>{@link #testDir} : location where to find resources for the - * test</li> <li>{@link #pomFile} : location of the pom file to use to build - * the mojo</li> <li>{@link #mojo} : the instanciated and initialized - * mojo</li> </ul> - */ - public class MojoTestRule extends TestName { - - /** location of the pom to use */ - private File pomFile; - - /** the mojo to used in the test method (based on the {@link #pomFile}). */ - private P mojo; - - /** the directory where the resources of the test are */ - private File testDir; - - public MojoTestRule() { - if (log.isDebugEnabled()) { - log.debug("NEW MojoTest instance for " + getTestClass()); - } - } - - @Override - public void starting(Description method) { - super.starting(method); - - if (isVerbose()) { - log.info("=============================================================================================="); - } - String methodName = name.getMethodName(); - - log.info("NEW Mojo test starting : " + getTestClass().getName() + - "#" + methodName); - - String goalName = getGoalName(methodName); - - testDir = getTest().getTestDir(methodName, goalName); - - pomFile = getTest().getPomFile(testDir, methodName, goalName); - - try { - Assert.assertTrue("could not find pom " + - pomFile.getAbsoluteFile(), pomFile.exists()); - - mojo = createMojo(pomFile, goalName); - - getTest().setUpMojo(mojo, pomFile); - - } catch (Exception ex) { - throw new IllegalStateException( - "could not init test " + getClass() + " - " + - methodName + " for reason " + ex.getMessage(), ex); - } - } - - @Override - public void finished(Description method) { - super.finished(method); - if (mojo != null) { - clearMojo(mojo); - } - pomFile = null; - mojo = null; - testDir = null; - } - - public P getMojo() { - return mojo; - } - - public File getPomFile() { - return pomFile; - } - - public File getTestDir() { - return testDir; - } - - public AbstractMojoTest<P> getTest() { - return AbstractMojoTest.this; - } - - public Class<?> getTestClass() { - return getTest().getClass(); - } - } -} diff --git a/helper-maven-plugin-api/src/test/java/org/nuiton/plugin/TestHelper.java b/helper-maven-plugin-api/src/test/java/org/nuiton/plugin/TestHelper.java deleted file mode 100644 index 7e7d482..0000000 --- a/helper-maven-plugin-api/src/test/java/org/nuiton/plugin/TestHelper.java +++ /dev/null @@ -1,121 +0,0 @@ -package org.nuiton.plugin; - -/* - * #%L - * Helper Maven Plugin :: API - * %% - * Copyright (C) 2009 - 2012 Codelutin, Tony Chemit - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/lgpl-3.0.html>. - * #L% - */ - -import org.apache.maven.plugin.Mojo; -import org.apache.maven.plugin.testing.AbstractMojoTestCase; -import org.codehaus.plexus.PlexusContainer; -import org.codehaus.plexus.PlexusTestCase; -import org.junit.Assert; -import org.junit.Ignore; - -import java.io.File; - -/** - * @author tchemit <chemit@codelutin.com> - * @since 1.0.3 - */ -public abstract class TestHelper extends PluginHelper { - - protected static boolean verbose; - protected static File basedir; - protected static DelegateMojoTestCase delegateMojoTest; - - /** - * @return the basedir for all tests - * @see PlexusTestCase#getBasedir() - */ - public static File getBasedir() { - if (basedir == null) { - String path = PlexusTestCase.getBasedir(); - basedir = new File(path); - if (verbose) { - System.out.println("basedir = " + basedir.getAbsolutePath()); - } - } - return basedir; - } - - public static void setBasedir(File basedir) { - TestHelper.basedir = basedir; - } - - public static boolean isVerbose() { - return verbose; - } - - public static void setVerbose(boolean verbose) { - TestHelper.verbose = verbose; - } - - public static File getTestDir(Class<?> type, String prefix) { - File f = new File(getBasedir(), prefix); - String rep = type.getName(); - String[] paths = rep.split("\\."); - File testDir = getFile(f, paths); - return testDir; - } - - public static Mojo lookupMojo(String goalName, File pomFile) throws Exception { - Mojo lookupMojo = getDelegateMojoTest().lookupMojo(goalName, pomFile); - Assert.assertNotNull(lookupMojo); - return lookupMojo; - - } - - public static DelegateMojoTestCase getDelegateMojoTest() throws Exception { - if (delegateMojoTest == null) { - delegateMojoTest = new DelegateMojoTestCase(); - TestHelper.delegateMojoTest.setUp(); - } - return delegateMojoTest; - } - - public static void setDelegateMojoTest(DelegateMojoTestCase delegateMojoTest) { - TestHelper.delegateMojoTest = delegateMojoTest; - } - - @Ignore - public static class DelegateMojoTestCase extends AbstractMojoTestCase { - - @Override - public Mojo lookupMojo(String goal, File pom) throws Exception { - return super.lookupMojo(goal, pom); - } - - @Override - public void setUp() throws Exception { - super.setUp(); - } - - @Override - public void tearDown() throws Exception { - super.tearDown(); - } - - @Override - public PlexusContainer getContainer() { - return super.getContainer(); - } - } -} diff --git a/helper-maven-plugin-test-api/LICENSE.txt b/helper-maven-plugin-test-api/LICENSE.txt new file mode 100644 index 0000000..cca7fc2 --- /dev/null +++ b/helper-maven-plugin-test-api/LICENSE.txt @@ -0,0 +1,165 @@ + GNU LESSER GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/> + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + + This version of the GNU Lesser General Public License incorporates +the terms and conditions of version 3 of the GNU General Public +License, supplemented by the additional permissions listed below. + + 0. Additional Definitions. + + As used herein, "this License" refers to version 3 of the GNU Lesser +General Public License, and the "GNU GPL" refers to version 3 of the GNU +General Public License. + + "The Library" refers to a covered work governed by this License, +other than an Application or a Combined Work as defined below. + + An "Application" is any work that makes use of an interface provided +by the Library, but which is not otherwise based on the Library. +Defining a subclass of a class defined by the Library is deemed a mode +of using an interface provided by the Library. + + A "Combined Work" is a work produced by combining or linking an +Application with the Library. The particular version of the Library +with which the Combined Work was made is also called the "Linked +Version". + + The "Minimal Corresponding Source" for a Combined Work means the +Corresponding Source for the Combined Work, excluding any source code +for portions of the Combined Work that, considered in isolation, are +based on the Application, and not on the Linked Version. + + The "Corresponding Application Code" for a Combined Work means the +object code and/or source code for the Application, including any data +and utility programs needed for reproducing the Combined Work from the +Application, but excluding the System Libraries of the Combined Work. + + 1. Exception to Section 3 of the GNU GPL. + + You may convey a covered work under sections 3 and 4 of this License +without being bound by section 3 of the GNU GPL. + + 2. Conveying Modified Versions. + + If you modify a copy of the Library, and, in your modifications, a +facility refers to a function or data to be supplied by an Application +that uses the facility (other than as an argument passed when the +facility is invoked), then you may convey a copy of the modified +version: + + a) under this License, provided that you make a good faith effort to + ensure that, in the event an Application does not supply the + function or data, the facility still operates, and performs + whatever part of its purpose remains meaningful, or + + b) under the GNU GPL, with none of the additional permissions of + this License applicable to that copy. + + 3. Object Code Incorporating Material from Library Header Files. + + The object code form of an Application may incorporate material from +a header file that is part of the Library. You may convey such object +code under terms of your choice, provided that, if the incorporated +material is not limited to numerical parameters, data structure +layouts and accessors, or small macros, inline functions and templates +(ten or fewer lines in length), you do both of the following: + + a) Give prominent notice with each copy of the object code that the + Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the object code with a copy of the GNU GPL and this license + document. + + 4. Combined Works. + + You may convey a Combined Work under terms of your choice that, +taken together, effectively do not restrict modification of the +portions of the Library contained in the Combined Work and reverse +engineering for debugging such modifications, if you also do each of +the following: + + a) Give prominent notice with each copy of the Combined Work that + the Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the Combined Work with a copy of the GNU GPL and this license + document. + + c) For a Combined Work that displays copyright notices during + execution, include the copyright notice for the Library among + these notices, as well as a reference directing the user to the + copies of the GNU GPL and this license document. + + d) Do one of the following: + + 0) Convey the Minimal Corresponding Source under the terms of this + License, and the Corresponding Application Code in a form + suitable for, and under terms that permit, the user to + recombine or relink the Application with a modified version of + the Linked Version to produce a modified Combined Work, in the + manner specified by section 6 of the GNU GPL for conveying + Corresponding Source. + + 1) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (a) uses at run time + a copy of the Library already present on the user's computer + system, and (b) will operate properly with a modified version + of the Library that is interface-compatible with the Linked + Version. + + e) Provide Installation Information, but only if you would otherwise + be required to provide such information under section 6 of the + GNU GPL, and only to the extent that such information is + necessary to install and execute a modified version of the + Combined Work produced by recombining or relinking the + Application with a modified version of the Linked Version. (If + you use option 4d0, the Installation Information must accompany + the Minimal Corresponding Source and Corresponding Application + Code. If you use option 4d1, you must provide the Installation + Information in the manner specified by section 6 of the GNU GPL + for conveying Corresponding Source.) + + 5. Combined Libraries. + + You may place library facilities that are a work based on the +Library side by side in a single library together with other library +facilities that are not Applications and are not covered by this +License, and convey such a combined library under terms of your +choice, if you do both of the following: + + a) Accompany the combined library with a copy of the same work based + on the Library, uncombined with any other library facilities, + conveyed under the terms of this License. + + b) Give prominent notice with the combined library that part of it + is a work based on the Library, and explaining where to find the + accompanying uncombined form of the same work. + + 6. Revised Versions of the GNU Lesser General Public License. + + The Free Software Foundation may publish revised and/or new versions +of the GNU Lesser General Public License from time to time. Such new +versions will be similar in spirit to the present version, but may +differ in detail to address new problems or concerns. + + Each version is given a distinguishing version number. If the +Library as you received it specifies that a certain numbered version +of the GNU Lesser General Public License "or any later version" +applies to it, you have the option of following the terms and +conditions either of that published version or of any later version +published by the Free Software Foundation. If the Library as you +received it does not specify a version number of the GNU Lesser +General Public License, you may choose any version of the GNU Lesser +General Public License ever published by the Free Software Foundation. + + If the Library as you received it specifies that a proxy can decide +whether future versions of the GNU Lesser General Public License shall +apply, that proxy's public statement of acceptance of any version is +permanent authorization for you to choose that version for the +Library. diff --git a/helper-maven-plugin-test-api/README.txt b/helper-maven-plugin-test-api/README.txt new file mode 100644 index 0000000..e69de29 diff --git a/helper-maven-plugin-test-api/changelog.txt b/helper-maven-plugin-test-api/changelog.txt new file mode 100644 index 0000000..e69de29 diff --git a/helper-maven-plugin-api/pom.xml b/helper-maven-plugin-test-api/pom.xml similarity index 71% copy from helper-maven-plugin-api/pom.xml copy to helper-maven-plugin-test-api/pom.xml index 49482e6..e6228e2 100644 --- a/helper-maven-plugin-api/pom.xml +++ b/helper-maven-plugin-test-api/pom.xml @@ -30,9 +30,9 @@ <version>2.2-SNAPSHOT</version> </parent> - <artifactId>helper-maven-plugin-api</artifactId> - <name>Helper Maven Plugin :: API</name> - <description>Simple maven mojo api for our projects</description> + <artifactId>helper-maven-plugin-test-api</artifactId> + <name>Helper Maven Plugin :: Test Api</name> + <description>Simple maven mojo test api for our projects</description> <properties> @@ -48,57 +48,62 @@ <!-- compile dependencies --> <dependency> - <groupId>commons-logging</groupId> - <artifactId>commons-logging</artifactId> + <groupId>${project.groupId}</groupId> + <artifactId>helper-maven-plugin-api</artifactId> + <version>${project.version}</version> </dependency> <dependency> - <groupId>org.apache.maven.shared</groupId> - <artifactId>maven-dependency-tree</artifactId> + <groupId>commons-logging</groupId> + <artifactId>commons-logging</artifactId> </dependency> - <dependency> - <groupId>velocity</groupId> - <artifactId>velocity</artifactId> - </dependency> + <!-- provided dependencies --> <dependency> <groupId>org.codehaus.plexus</groupId> - <artifactId>plexus-utils</artifactId> + <artifactId>plexus-container-default</artifactId> </dependency> - <!-- provided dependencies --> - <dependency> - <groupId>org.codehaus.plexus</groupId> - <artifactId>plexus-container-default</artifactId> + <groupId>org.apache.maven</groupId> + <artifactId>maven-core</artifactId> + <scope>provided</scope> </dependency> <dependency> <groupId>org.apache.maven</groupId> - <artifactId>maven-project</artifactId> - <version>${mavenVersion}</version> + <artifactId>maven-compat</artifactId> <scope>provided</scope> </dependency> <dependency> <groupId>org.apache.maven</groupId> <artifactId>maven-model</artifactId> - <version>${mavenVersion}</version> <scope>provided</scope> </dependency> <dependency> <groupId>org.apache.maven</groupId> <artifactId>maven-artifact</artifactId> - <version>${mavenVersion}</version> <scope>provided</scope> </dependency> <dependency> <groupId>org.apache.maven</groupId> <artifactId>maven-plugin-api</artifactId> - <version>${mavenVersion}</version> + <scope>provided</scope> + </dependency> + + <dependency> + <groupId>org.eclipse.aether</groupId> + <artifactId>aether-api</artifactId> + <scope>provided</scope> + </dependency> + + <dependency> + <groupId>org.apache.maven</groupId> + <artifactId>maven-aether-provider</artifactId> <scope>provided</scope> </dependency> @@ -107,7 +112,7 @@ <dependency> <groupId>org.apache.maven.plugin-testing</groupId> <artifactId>maven-plugin-testing-harness</artifactId> - <scope>test</scope> + <scope>compile</scope> <exclusions> <exclusion> @@ -141,46 +146,13 @@ <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> + <scope>compile</scope> </dependency> - <dependency> - <groupId>log4j</groupId> - <artifactId>log4j</artifactId> - <scope>test</scope> - </dependency> - - </dependencies> <build> - <testResources> - <testResource> - <directory>${project.basedir}/src/test/resources</directory> - <includes> - <include>**/*</include> - </includes> - <excludes> - <exclude>**/*~</exclude> - </excludes> - </testResource> - </testResources> - - <plugins> - - <plugin> - <artifactId>maven-jar-plugin</artifactId> - <executions> - <execution> - <id>attach-test</id> - <goals> - <goal>test-jar</goal> - </goals> - </execution> - </executions> - </plugin> - </plugins> - </build> <profiles> @@ -234,52 +206,6 @@ </reporting> </profile> - <!-- to deploy snapshot or release without anything else --> - <profile> - <id>release-profile</id> - <activation> - <property> - <name>performRelease</name> - <value>true</value> - </property> - </activation> - - <build> - <plugins> - - <!-- always compute source jar --> - <plugin> - <artifactId>maven-source-plugin</artifactId> - <executions> - <execution> - <id>attach-sources</id> - <goals> - <goal>jar</goal> - <goal>test-jar</goal> - </goals> - </execution> - </executions> - </plugin> - - <!-- always compute javadoc jar --> - <plugin> - <artifactId>maven-javadoc-plugin</artifactId> - <executions> - <execution> - <id>attach-javadocs</id> - <goals> - <goal>jar</goal> - <goal>test-jar</goal> - </goals> - </execution> - </executions> - </plugin> - - </plugins> - </build> - - </profile> - <!-- prepare the assembly at release time --> <profile> <id>release-assembly-profile</id> diff --git a/helper-maven-plugin-test-api/src/license/THIRD-PARTY.properties b/helper-maven-plugin-test-api/src/license/THIRD-PARTY.properties new file mode 100644 index 0000000..2e0940b --- /dev/null +++ b/helper-maven-plugin-test-api/src/license/THIRD-PARTY.properties @@ -0,0 +1,32 @@ +# Generated by org.codehaus.mojo.license.AddThirdPartyMojo +#------------------------------------------------------------------------------- +# Already used licenses in project : +# - Apache License +# - BSD License +# - COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0 +# - Common Public License Version 1.0 +# - Eclipse Public License, Version 1.0 +# - Indiana University Extreme! Lab Software License, vesion 1.1.1 +# - Lesser General Public License (LPGL) +# - Lesser General Public License (LPGL) v 2.1 +# - MIT License +# - New BSD License +# - Public Domain +# - The Apache Software License, Version 2.0 +# - http://classworlds.codehaus.org/license.html +#------------------------------------------------------------------------------- +# Please fill the missing licenses for dependencies : +# +# +#Sun Oct 26 13:40:44 CET 2014 +classworlds--classworlds--1.1-alpha-2=http\://classworlds.codehaus.org/license.html +commons-codec--commons-codec--1.2=The Apache Software License, Version 2.0 +commons-collections--commons-collections--3.1=The Apache Software License, Version 2.0 +nekohtml--xercesMinimal--1.9.6.2=The Apache Software License, Version 2.0 +org.codehaus.plexus--plexus-container-default--1.0-alpha-9-stable-1=The Apache Software License, Version 2.0 +org.codehaus.plexus--plexus-interactivity-api--1.0-alpha-4=The Apache Software License, Version 2.0 +org.slf4j--jcl-over-slf4j--1.5.6=The Apache Software License, Version 2.0 +org.slf4j--slf4j-api--1.5.6=The Apache Software License, Version 2.0 +org.slf4j--slf4j-jdk14--1.5.6=The Apache Software License, Version 2.0 +org.slf4j--slf4j-nop--1.5.3=The Apache Software License, Version 2.0 +oro--oro--2.0.8=The Apache Software License, Version 2.0 diff --git a/helper-maven-plugin-test-api/src/main/java/org/nuiton/plugin/MojoTestRule.java b/helper-maven-plugin-test-api/src/main/java/org/nuiton/plugin/MojoTestRule.java new file mode 100644 index 0000000..a014b09 --- /dev/null +++ b/helper-maven-plugin-test-api/src/main/java/org/nuiton/plugin/MojoTestRule.java @@ -0,0 +1,222 @@ +package org.nuiton.plugin; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.maven.plugin.testing.MojoRule; +import org.apache.maven.project.DefaultProjectBuildingRequest; +import org.apache.maven.project.MavenProject; +import org.apache.maven.project.ProjectBuilder; +import org.apache.maven.project.ProjectBuildingRequest; +import org.apache.maven.project.ProjectBuildingResult; +import org.eclipse.aether.DefaultRepositorySystemSession; +import org.junit.Assert; +import org.junit.Test; +import org.junit.runner.Description; +import org.junit.runners.model.Statement; + +import java.beans.Introspector; +import java.io.File; + +/** + * To offer inside each test method (annotated by a {@link Test}) the + * following properties : + * <p/> + * <ul> <li>{@link #testDirectory} : location where to find resources for the + * test</li> <li>{@link #pomFile} : location of the pom file to use to build + * the mojo</li> <li>{@link #mojo} : the instanciated and initialized + * mojo</li> </ul> + */ +public abstract class MojoTestRule<P extends Plugin> extends MojoRule { + + /** Logger. */ + private static final Log log = LogFactory.getLog(MojoTestRule.class); + + /** + * Directory where the resources for the current test. + */ + private File testDirectory; + + /** + * Method name of the current test. + */ + private String testMethodName; + + /** + * Pom file of the current test. + */ + private File pomFile; + + /** + * Mojo to used in the current test method. + */ + private P mojo; + + /** + * Class of the test. + */ + private final Class<?> testClass; + + protected MojoTestRule(Class<?> testClass) { + this.testClass = testClass; + } + + protected abstract String getGoalName(String methodName); + + @Override + public Statement apply(final Statement base, Description description) { + + testMethodName = description.getMethodName(); + + return super.apply(base, description); + + } + + @SuppressWarnings("unchecked") + protected P createMojo(File pomFile, String goalName) throws Exception { + P result = (P) lookupMojo(goalName, pomFile); + return result; + } + + /** + * Initialize the given mojo. + * + * @param mojo the instanciate mojo + * @param pomFile the pom file used to instanciate the mojo + * @throws Exception if any pb + */ + protected void setUpMojo(P mojo, File pomFile) throws Exception { + + MavenProject project = mojo.getProject(); + if (project == null) { + + log.debug("init maven project"); + ProjectBuilder projectBuilder = lookup(ProjectBuilder.class); + ProjectBuildingRequest projectBuildingRequest = new DefaultProjectBuildingRequest(); + projectBuildingRequest.setRepositorySession(new DefaultRepositorySystemSession()); + ProjectBuildingResult projectBuildingResult = projectBuilder.build(pomFile, projectBuildingRequest); + project = projectBuildingResult.getProject(); + + mojo.setProject(project); + } + + mojo.getProject().setFile(pomFile); + + } + + protected void tearDownMojo(P mojo) { + + // by default nothing to clear + + } + + @Override + protected void before() throws Throwable { + + if (TestHelper.isVerbose()) { + log.info("=============================================================================================="); + } + + log.info("Starting test: " + testClass.getName() + "#" + testMethodName); + + String goalName = getGoalName(testMethodName); + + testDirectory = getTestDir(testMethodName, goalName); + + pomFile = getPomFile(testDirectory, testMethodName, goalName); + + try { + + Assert.assertTrue("could not find pom " + pomFile.getAbsoluteFile(), pomFile.exists()); + + mojo = createMojo(pomFile, goalName); + + setUpMojo(mojo, pomFile); + + } catch (Exception ex) { + + throw new IllegalStateException("could not init test " + testClass + "#" + testMethodName, ex); + + } + + } + + @Override + protected void after() { + + if (mojo != null) { + tearDownMojo(mojo); + } + pomFile = null; + mojo = null; + testDirectory = null; + + } + + public P getMojo() { + return mojo; + } + + public File getPomFile() { + return pomFile; + } + + public File getTestDirectory() { + return testDirectory; + } + + /** + * Obtain the location of the directory where to find resources for the next test. + * + * By convention, will be the package named by the test class name from the + * {@link TestHelper#getTestBasedir()}. + * + * @param methodName the method of the next test to execute + * @param goalName the common goal name to use + * @return the directory where to find resources for the test + */ + protected File getTestDir(String methodName, String goalName) { + + //TC-20091101 use a decipatilize simple name to avoid conflict of package with existing class name. + String rep = getClass().getPackage().getName() + "." + Introspector.decapitalize(testClass.getSimpleName()); + String[] paths = rep.split("\\."); + File directory = TestHelper.getFile(TestHelper.getTestBasedir(), paths); + if (TestHelper.isVerbose()) { + log.info("test dir = " + getRelativePathFromBasedir(directory)); + } else if (log.isDebugEnabled()) { + log.debug("test dir = " + getRelativePathFromBasedir(directory)); + } + + return directory; + } + + /** + * Obtain the location of the pom file to use for next mojo test. + * <p/> + * By default, the pom file is the file with name {@code methodName+".xml"} + * in the {@code testDir}. + * + * @param testDir the location of resources for the next test (is the + * result of the method {@link #getTestDir(String, + * String)}. + * @param methodName the name of the next test + * @param goalName the name of the common goal + * @return the location of the pom file for the next mojo test. + */ + protected File getPomFile(File testDir, String methodName, String goalName) { + + File pom = new File(testDir, methodName + ".xml"); + + if (TestHelper.isVerbose()) { + log.info("pom file = " + getRelativePathFromBasedir(pom)); + } else if (log.isDebugEnabled()) { + log.debug("pom file = " + getRelativePathFromBasedir(pom)); + } + + return pom; + } + + public String getRelativePathFromBasedir(File f) { + return TestHelper.getRelativePath(TestHelper.getBasedir(), f); + } + +} diff --git a/helper-maven-plugin-test-api/src/main/java/org/nuiton/plugin/TestHelper.java b/helper-maven-plugin-test-api/src/main/java/org/nuiton/plugin/TestHelper.java new file mode 100644 index 0000000..8151a50 --- /dev/null +++ b/helper-maven-plugin-test-api/src/main/java/org/nuiton/plugin/TestHelper.java @@ -0,0 +1,117 @@ +package org.nuiton.plugin; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.codehaus.plexus.PlexusTestCase; +import org.junit.Assert; + +import java.io.File; +import java.io.IOException; + +/** + * @author tchemit <chemit@codelutin.com> + * @since 1.0.3 + */ +public abstract class TestHelper extends PluginHelper { + + /** Logger. */ + private static final Log log = LogFactory.getLog(TestHelper.class); + + protected static boolean verbose; + + protected static File basedir; + + protected static File testBasedir; + + public static File getTestBasedir() { + if (testBasedir == null) { + testBasedir = TestHelper.getFile(getBasedir(), "target", "test-classes"); + if (log.isDebugEnabled()) { + log.debug("testBasedir = " + testBasedir); + } + } + return testBasedir; + } + + /** + * @return the basedir for all tests + * @see PlexusTestCase#getBasedir() + */ + public static File getBasedir() { + if (basedir == null) { + String path = PlexusTestCase.getBasedir(); + basedir = new File(path); + if (verbose) { + System.out.println("basedir = " + basedir.getAbsolutePath()); + } + } + return basedir; + } + + public static void setBasedir(File basedir) { + TestHelper.basedir = basedir; + } + + public static boolean isVerbose() { + return verbose; + } + + public static void setVerbose(boolean verbose) { + TestHelper.verbose = verbose; + } + + public static File getTestDir(Class<?> type, String prefix) { + File f = new File(getBasedir(), prefix); + String rep = type.getName(); + String[] paths = rep.split("\\."); + File testDir = PluginHelper.getFile(f, paths); + return testDir; + } + + /** + * Checks on the given {@code file} that : + * <ul> + * <li>file exists</li> + * <li>the given {@code pattern} exists {@code required = true} + * (or not {@code required = false}) in the content of the file.</li> + * </ul> + * + * @param file the file to test + * @param pattern the pattern to search + * @param encoding encoding of the file to read + * @param required flag to says if pattern should (or not) be found in + * file's content + * @throws IOException if could not read file + */ + public static void checkExistsPattern(File file, + String pattern, + String encoding, + boolean required) throws IOException { + + // checks file exists + Assert.assertTrue("File '" + file + "' does not exist, but should...", + file.exists() + ); + + //obtain file content as a string + String content = PluginHelper.readAsString(file, encoding); + + checkPattern(file, content, pattern, required); + } + + public static void checkPattern(File file, + String content, + String pattern, + boolean required) throws IOException { + + String errorMessage = required ? "could not find the pattern : " : + "should not have found pattern :"; + + // checks pattern found (or not) in file's content + Assert.assertEquals(errorMessage + pattern + " in '" + file + "'", + required, + content.contains(pattern) + ); + } + +} diff --git a/helper-maven-plugin-test-api/src/site/apt/index.apt b/helper-maven-plugin-test-api/src/site/apt/index.apt new file mode 100644 index 0000000..cdb688d --- /dev/null +++ b/helper-maven-plugin-test-api/src/site/apt/index.apt @@ -0,0 +1,17 @@ + +---- +Introduction +---- +---- +2012-11-10 +---- + +Maven helper Plugin Test API + + This modules offers a test toolkit : usefull classes to make new tests (see {Test toolkit overview}) + +Test toolkit overview + + see the {{{./mojo-testFramework.html}Mojo test framework}} page. + + see {{{./testapidocs/index.html}test-javadoc}}. diff --git a/helper-maven-plugin-api/src/site/apt/mojo-testFramework.apt b/helper-maven-plugin-test-api/src/site/apt/mojo-testFramework.apt similarity index 86% rename from helper-maven-plugin-api/src/site/apt/mojo-testFramework.apt rename to helper-maven-plugin-test-api/src/site/apt/mojo-testFramework.apt index d4303e2..32757d7 100644 --- a/helper-maven-plugin-api/src/site/apt/mojo-testFramework.apt +++ b/helper-maven-plugin-test-api/src/site/apt/mojo-testFramework.apt @@ -1,24 +1,4 @@ -~~~ -~~ #%L -~~ Helper Maven Plugin :: API -~~ %% -~~ Copyright (C) 2009 - 2012 Codelutin, Tony Chemit -~~ %% -~~ This program is free software: you can redistribute it and/or modify -~~ it under the terms of the GNU Lesser General Public License as -~~ published by the Free Software Foundation, either version 3 of the -~~ License, or (at your option) any later version. -~~ -~~ This program is distributed in the hope that it will be useful, -~~ but WITHOUT ANY WARRANTY; without even the implied warranty of -~~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -~~ GNU General Lesser Public License for more details. -~~ -~~ You should have received a copy of the GNU General Lesser Public -~~ License along with this program. If not, see -~~ <http://www.gnu.org/licenses/lgpl-3.0.html>. -~~ #L% -~~~ + ---- Mojo Test framework ---- diff --git a/helper-maven-plugin-test-api/src/site/site.xml b/helper-maven-plugin-test-api/src/site/site.xml new file mode 100644 index 0000000..8a24ae9 --- /dev/null +++ b/helper-maven-plugin-test-api/src/site/site.xml @@ -0,0 +1,31 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<project name="${project.name}" xmlns="http://maven.apache.org/DECORATION/1.4.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/DECORATION/1.4.0 http://maven.apache.org/xsd/decoration-1.4.0.xsd"> + + <bannerLeft> + <name>${project.name}</name> + <href>index.html</href> + </bannerLeft> + + <body> + + <breadcrumbs> + <item name="${project.name}" href="index.html"/> + </breadcrumbs> + + <menu ref="parent"/> + + <menu name="User"> + <item name="Introduction" href="index.html"/> + </menu> + + <menu name="Developer"> + <item name="Mojo test framework" href="mojo-testFramework.html"/> + </menu> + + <menu ref="reports"/> + + </body> +</project> diff --git a/helper-maven-plugin/pom.xml b/helper-maven-plugin/pom.xml index e31004c..011c93c 100644 --- a/helper-maven-plugin/pom.xml +++ b/helper-maven-plugin/pom.xml @@ -72,17 +72,16 @@ <artifactId>plexus-sec-dispatcher</artifactId> </dependency> - <dependency> + <!--dependency> <groupId>org.codehaus.plexus</groupId> <artifactId>plexus-container-default</artifactId> - </dependency> + </dependency--> <dependency> <groupId>plexus</groupId> <artifactId>plexus-mail-sender-api</artifactId> </dependency> - <dependency> <groupId>org.apache.maven.plugin-tools</groupId> <artifactId>maven-plugin-annotations</artifactId> @@ -102,52 +101,60 @@ <dependency> <groupId>org.apache.maven</groupId> - <artifactId>maven-project</artifactId> + <artifactId>maven-core</artifactId> </dependency> <dependency> <groupId>org.apache.maven</groupId> - <artifactId>maven-model</artifactId> + <artifactId>maven-compat</artifactId> + </dependency> + + <dependency> + <groupId>org.eclipse.sisu</groupId> + <artifactId>org.eclipse.sisu.plexus</artifactId> + <scope>compile</scope> </dependency> <dependency> <groupId>org.apache.maven</groupId> - <artifactId>maven-settings</artifactId> + <artifactId>maven-model</artifactId> </dependency> <dependency> <groupId>org.apache.maven</groupId> - <artifactId>maven-artifact</artifactId> + <artifactId>maven-settings</artifactId> </dependency> <dependency> <groupId>org.apache.maven</groupId> - <artifactId>maven-artifact-manager</artifactId> + <artifactId>maven-artifact</artifactId> </dependency> <dependency> <groupId>org.apache.maven</groupId> <artifactId>maven-plugin-api</artifactId> + <scope>compile</scope> </dependency> <!-- tests dependencies --> <dependency> <groupId>${project.groupId}</groupId> - <artifactId>helper-maven-plugin-api</artifactId> + <artifactId>helper-maven-plugin-test-api</artifactId> <version>${project.version}</version> - <classifier>tests</classifier> <scope>test</scope> </dependency> <dependency> <groupId>org.apache.maven.plugin-testing</groupId> <artifactId>maven-plugin-testing-harness</artifactId> + <scope>test</scope> </dependency> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> + <scope>test</scope> </dependency> <dependency> diff --git a/helper-maven-plugin/src/test/java/org/nuiton/helper/plugin/SendEmailMojoTest.java b/helper-maven-plugin/src/test/java/org/nuiton/helper/plugin/SendEmailMojoTest.java index 5e46d8b..ead8638 100644 --- a/helper-maven-plugin/src/test/java/org/nuiton/helper/plugin/SendEmailMojoTest.java +++ b/helper-maven-plugin/src/test/java/org/nuiton/helper/plugin/SendEmailMojoTest.java @@ -26,70 +26,79 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.junit.Assert; import org.junit.Assume; +import org.junit.Rule; import org.junit.Test; import org.nuiton.helper.io.mail.MailSender; -import org.nuiton.plugin.AbstractMojoTest; +import org.nuiton.plugin.MojoTestRule; import java.io.File; -import java.util.Arrays; +import java.util.Collections; /** * @author tchemit <chemit@codelutin.com> * @since 1.0.0 */ -public class SendEmailMojoTest extends AbstractMojoTest<SendEmailMojo> { +public class SendEmailMojoTest { /** Logger. */ private static final Log log = LogFactory.getLog(SendEmailMojoTest.class); - protected boolean canContinue; + @Rule + public MojoTestRule<SendEmailMojo> rule = new MojoTestRule<SendEmailMojo>(SendEmailMojoTest.class) { - @Override - protected String getGoalName(String methodName) { - return "send-email"; - } + @Override + protected String getGoalName(String methodName) { + return "send-email"; + } - @Override - protected void setUpMojo(SendEmailMojo mojo, File pomFile) throws Exception { - super.setUpMojo(mojo, pomFile); + @Override + protected void setUpMojo(SendEmailMojo mojo, File pomFile) throws Exception { - // add a mailSender here - MailSender sender = new MailSender(); - sender.setName("Nuiton Release Notification"); - sender.setEmail("test@noway.fr"); - mojo.setMailSender(sender); + super.setUpMojo(mojo, pomFile); - // add a destination - mojo.setToAddresses(Arrays.asList("chemit@codelutin.com")); + // add a mailSender here + MailSender sender = new MailSender(); + sender.setName("Nuiton Release Notification"); + sender.setEmail("test@noway.fr"); + mojo.setMailSender(sender); - try { - mojo.init(); - canContinue = true; - } catch (Exception e) { - canContinue = false; - } -// canContinue = mojo.init(); - if (canContinue) { - if (mojo.isVerbose()) { - log.info("setup done for " + mojo.getProject().getFile().getName()); + // add a destination + mojo.setToAddresses(Collections.singletonList("chemit@codelutin.com")); + + try { + mojo.init(); + canContinue = true; + } catch (Exception e) { + canContinue = false; + } + + if (canContinue) { + if (mojo.isVerbose()) { + log.info("setup done for " + mojo.getProject().getFile().getName()); + } + } else { + log.error("setup was not successfull, will skip this test [" + getClass() + "]"); } - } else { - log.error("setup was not successfull, will skip this test [" + getClass() + "]"); + } - } + + }; + + protected boolean canContinue; @Test public void sendEmail() throws Exception { Assume.assumeTrue(canContinue); - Assert.assertNotNull(getMojo()); - getMojo().doAction(); + Assert.assertNotNull(rule.getMojo()); + rule.getMojo().doAction(); } @Test public void skipSendEmail() throws Exception { Assume.assumeTrue(canContinue); - Assert.assertNotNull(getMojo()); - getMojo().execute(); + Assert.assertNotNull(rule.getMojo()); + rule.getMojo().execute(); } + } diff --git a/helper-maven-plugin/src/test/java/org/nuiton/helper/plugin/TransformProjectVersionMojoTest.java b/helper-maven-plugin/src/test/java/org/nuiton/helper/plugin/TransformProjectVersionMojoTest.java index 3c3498f..2b9362e 100644 --- a/helper-maven-plugin/src/test/java/org/nuiton/helper/plugin/TransformProjectVersionMojoTest.java +++ b/helper-maven-plugin/src/test/java/org/nuiton/helper/plugin/TransformProjectVersionMojoTest.java @@ -25,8 +25,9 @@ package org.nuiton.helper.plugin; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.junit.Assert; +import org.junit.Rule; import org.junit.Test; -import org.nuiton.plugin.AbstractMojoTest; +import org.nuiton.plugin.MojoTestRule; import java.io.File; import java.util.Properties; @@ -35,42 +36,47 @@ import java.util.Properties; * @author tchemit <chemit@codelutin.com> * @since 2.0 */ -public class TransformProjectVersionMojoTest extends AbstractMojoTest<TransformProjectVersionMojo> { +public class TransformProjectVersionMojoTest { /** Logger. */ - private static final Log log = - LogFactory.getLog(TransformProjectVersionMojoTest.class); + private static final Log log = LogFactory.getLog(TransformProjectVersionMojoTest.class); protected boolean canContinue; - @Override - protected String getGoalName(String methodName) { - return "transform-project-version"; - } + @Rule + public MojoTestRule<TransformProjectVersionMojo> rule = new MojoTestRule<TransformProjectVersionMojo>(TransformProjectVersionMojoTest.class) { + + @Override + protected String getGoalName(String methodName) { + return "transform-project-version"; + } - @Override - protected void setUpMojo(TransformProjectVersionMojo mojo, File pomFile) throws Exception { - super.setUpMojo(mojo, pomFile); + @Override + protected void setUpMojo(TransformProjectVersionMojo mojo, File pomFile) throws Exception { - try { - mojo.init(); - canContinue = true; - } catch (Exception e) { + super.setUpMojo(mojo, pomFile); - canContinue = false; + try { + mojo.init(); + canContinue = true; + } catch (Exception e) { - if (log.isDebugEnabled()) { - log.debug("Could not init mojo ", e); + canContinue = false; + + if (log.isDebugEnabled()) { + log.debug("Could not init mojo ", e); + } } + } - } + }; @Test public void simple() throws Exception { Assert.assertTrue(canContinue); - Assert.assertNotNull(getMojo()); - getMojo().doAction(); + Assert.assertNotNull(rule.getMojo()); + rule.getMojo().doAction(); assertNewVersion("newVersion", "1.0-rev-1"); } @@ -79,8 +85,8 @@ public class TransformProjectVersionMojoTest extends AbstractMojoTest<TransformP public void keepSnapshot() throws Exception { Assert.assertTrue(canContinue); - Assert.assertNotNull(getMojo()); - getMojo().doAction(); + Assert.assertNotNull(rule.getMojo()); + rule.getMojo().doAction(); assertNewVersion("newVersion", "2.0-rev-2-SNAPSHOT"); } @@ -89,8 +95,8 @@ public class TransformProjectVersionMojoTest extends AbstractMojoTest<TransformP public void removeSnapshot() throws Exception { Assert.assertTrue(canContinue); - Assert.assertNotNull(getMojo()); - getMojo().doAction(); + Assert.assertNotNull(rule.getMojo()); + rule.getMojo().doAction(); assertNewVersion("newVersion", "2.0-rev-2"); } @@ -116,7 +122,7 @@ public class TransformProjectVersionMojoTest extends AbstractMojoTest<TransformP protected void assertNewVersion(String versionKey, String expectedNewVersion) { - Properties properties = getMojo().getProject().getProperties(); + Properties properties = rule.getMojo().getProject().getProperties(); Object newVersion = properties.get(versionKey); Assert.assertNotNull(newVersion); Assert.assertEquals(expectedNewVersion, newVersion); diff --git a/helper-maven-plugin/src/test/resources/log4j.properties b/helper-maven-plugin/src/test/resources/log4j.properties new file mode 100644 index 0000000..e366d88 --- /dev/null +++ b/helper-maven-plugin/src/test/resources/log4j.properties @@ -0,0 +1,32 @@ +### +# #%L +# Helper Maven Plugin :: API +# %% +# Copyright (C) 2009 - 2012 Codelutin, Tony Chemit +# %% +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Lesser Public License for more details. +# +# You should have received a copy of the GNU General Lesser Public +# License along with this program. If not, see +# <http://www.gnu.org/licenses/lgpl-3.0.html>. +# #L% +### +# Global logging configuration +log4j.rootLogger=ERROR, stdout +# Console output... +log4j.appender.stdout=org.apache.log4j.ConsoleAppender +log4j.appender.stdout.layout=org.apache.log4j.PatternLayout +log4j.appender.stdout.layout.ConversionPattern=[%p] (%F:%L) %M - %m%n +#log4j.appender.stdout.layout.ConversionPattern=[%p] [%t] (%F:%L) %M - %m%n + +# package level +log4j.logger.org.nuiton=INFO + diff --git a/pom.xml b/pom.xml index 0c4a9f3..bd10b94 100644 --- a/pom.xml +++ b/pom.xml @@ -28,7 +28,7 @@ <parent> <groupId>org.nuiton</groupId> <artifactId>nuitonpom</artifactId> - <version>1.5</version> + <version>2.1</version> </parent> <artifactId>helper-maven-plugin-parent</artifactId> @@ -42,6 +42,7 @@ <modules> <module>helper-maven-plugin-api</module> + <module>helper-maven-plugin-test-api</module> <module>helper-maven-plugin</module> </modules> @@ -97,7 +98,15 @@ <!-- documentation is in apt --> <siteSourcesType>apt</siteSourcesType> - <mavenVersion>2.2.1</mavenVersion> + <mavenVersion>3.3.3</mavenVersion> + + <javaVersion>1.7</javaVersion> + <!--TODO remove this when idea won't ask to change jdk level at each pom modification--> + <maven.compiler.source>${javaVersion}</maven.compiler.source> + <!--TODO remove this when idea won't ask to change jdk level at each pom modification--> + <maven.compiler.target>${javaVersion}</maven.compiler.target> + <signatureArtifactId>java17</signatureArtifactId> + <signatureVersion>1.0</signatureVersion> </properties> @@ -113,19 +122,19 @@ <dependency> <groupId>org.apache.commons</groupId> <artifactId>commons-lang3</artifactId> - <version>3.3.2</version> + <version>3.4</version> </dependency> <dependency> <groupId>org.apache.maven.shared</groupId> <artifactId>maven-dependency-tree</artifactId> - <version>2.1</version> + <version>2.2</version> </dependency> <dependency> <groupId>org.codehaus.plexus</groupId> <artifactId>plexus-utils</artifactId> - <version>3.0.14</version> + <version>3.0.22</version> </dependency> <dependency> @@ -157,7 +166,7 @@ <dependency> <groupId>org.apache.maven</groupId> - <artifactId>maven-project</artifactId> + <artifactId>maven-core</artifactId> <version>${mavenVersion}</version> <scope>provided</scope> </dependency> @@ -185,7 +194,7 @@ <dependency> <groupId>org.apache.maven</groupId> - <artifactId>maven-artifact-manager</artifactId> + <artifactId>maven-compat</artifactId> <version>${mavenVersion}</version> <scope>provided</scope> </dependency> @@ -197,6 +206,26 @@ <scope>provided</scope> </dependency> + <dependency> + <groupId>org.apache.maven</groupId> + <artifactId>maven-aether-provider</artifactId> + <version>${mavenVersion}</version> + <scope>provided</scope> + </dependency> + + <dependency> + <groupId>org.eclipse.aether</groupId> + <artifactId>aether-api</artifactId> + <version>1.0.2.v20150114</version> + <scope>provided</scope> + </dependency> + + <dependency> + <groupId>org.eclipse.sisu</groupId> + <artifactId>org.eclipse.sisu.plexus</artifactId> + <version>0.3.0</version> + </dependency> + <!-- dependencies to mojo annotations --> <dependency> <groupId>org.apache.maven.plugin-tools</groupId> @@ -223,8 +252,7 @@ <dependency> <groupId>org.apache.maven.plugin-testing</groupId> <artifactId>maven-plugin-testing-harness</artifactId> - <version>1.3</version> - <!--<version>2.1</version>--> + <version>3.3.0</version> <scope>test</scope> </dependency> @@ -237,7 +265,7 @@ <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> - <version>4.11</version> + <version>4.12</version> <scope>test</scope> </dependency> -- To stop receiving notification emails like this one, please contact nuiton.org SCM administrator <admin+scm@nuiton.org>.
This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository maven-helper-plugin. See http://git.nuiton.org/maven-helper-plugin.git commit d9af5591259d2c7c8f3601078072e68cd0f01338 Author: Tony CHEMIT <chemit@codelutin.com> Date: Mon May 25 12:42:55 2015 +0200 use Parameter instead of deprecated Component annotation for MavenProject and Settings (refs #3703) --- .../main/java/org/nuiton/helper/plugin/CheckAutoContainerPlugin.java | 2 +- .../src/main/java/org/nuiton/helper/plugin/CollectFilesMojo.java | 3 +-- .../main/java/org/nuiton/helper/plugin/ExecuteRemoteCommandMojo.java | 4 ++-- .../src/main/java/org/nuiton/helper/plugin/SendEmailMojo.java | 3 +-- .../main/java/org/nuiton/helper/plugin/ShareServerSecretPlugin.java | 4 ++-- .../java/org/nuiton/helper/plugin/TransformProjectVersionMojo.java | 3 +-- 6 files changed, 8 insertions(+), 11 deletions(-) diff --git a/helper-maven-plugin/src/main/java/org/nuiton/helper/plugin/CheckAutoContainerPlugin.java b/helper-maven-plugin/src/main/java/org/nuiton/helper/plugin/CheckAutoContainerPlugin.java index 1bd9094..583f7b9 100644 --- a/helper-maven-plugin/src/main/java/org/nuiton/helper/plugin/CheckAutoContainerPlugin.java +++ b/helper-maven-plugin/src/main/java/org/nuiton/helper/plugin/CheckAutoContainerPlugin.java @@ -136,7 +136,7 @@ public class CheckAutoContainerPlugin extends AbstractPlugin { * * @since 1.2.5 */ - @Component + @Parameter( defaultValue = "${project}", required = true, readonly = true ) protected MavenProject project; /** diff --git a/helper-maven-plugin/src/main/java/org/nuiton/helper/plugin/CollectFilesMojo.java b/helper-maven-plugin/src/main/java/org/nuiton/helper/plugin/CollectFilesMojo.java index a5d5e08..3439d2c 100644 --- a/helper-maven-plugin/src/main/java/org/nuiton/helper/plugin/CollectFilesMojo.java +++ b/helper-maven-plugin/src/main/java/org/nuiton/helper/plugin/CollectFilesMojo.java @@ -28,7 +28,6 @@ import org.apache.maven.artifact.metadata.ArtifactMetadata; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; -import org.apache.maven.plugins.annotations.Component; import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.Parameter; import org.apache.maven.project.MavenProject; @@ -65,7 +64,7 @@ public class CollectFilesMojo extends AbstractPlugin implements PluginWithEncodi * * @since 1.0.3 */ - @Component + @Parameter( defaultValue = "${project}", required = true, readonly = true ) protected MavenProject project; /** diff --git a/helper-maven-plugin/src/main/java/org/nuiton/helper/plugin/ExecuteRemoteCommandMojo.java b/helper-maven-plugin/src/main/java/org/nuiton/helper/plugin/ExecuteRemoteCommandMojo.java index 4e0bcf9..e3a8524 100644 --- a/helper-maven-plugin/src/main/java/org/nuiton/helper/plugin/ExecuteRemoteCommandMojo.java +++ b/helper-maven-plugin/src/main/java/org/nuiton/helper/plugin/ExecuteRemoteCommandMojo.java @@ -60,7 +60,7 @@ public class ExecuteRemoteCommandMojo extends AbstractPlugin { protected boolean verbose; /** Project. */ - @Component + @Parameter( defaultValue = "${project}", required = true, readonly = true ) protected MavenProject project; /** Active proxy from settings (if any). */ @@ -72,7 +72,7 @@ public class ExecuteRemoteCommandMojo extends AbstractPlugin { * * @since 1.1.0 */ - @Component + @Parameter( defaultValue = "${settings}", required = true, readonly = true ) protected Settings settings; /** diff --git a/helper-maven-plugin/src/main/java/org/nuiton/helper/plugin/SendEmailMojo.java b/helper-maven-plugin/src/main/java/org/nuiton/helper/plugin/SendEmailMojo.java index 947cae0..0023505 100644 --- a/helper-maven-plugin/src/main/java/org/nuiton/helper/plugin/SendEmailMojo.java +++ b/helper-maven-plugin/src/main/java/org/nuiton/helper/plugin/SendEmailMojo.java @@ -25,7 +25,6 @@ package org.nuiton.helper.plugin; import org.apache.commons.lang3.StringUtils; import org.apache.maven.model.Developer; import org.apache.maven.plugin.MojoExecutionException; -import org.apache.maven.plugins.annotations.Component; import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.Parameter; import org.apache.maven.project.MavenProject; @@ -56,7 +55,7 @@ public class SendEmailMojo extends AbstractPlugin implements PluginWithEncoding * * @since 1.0.3 */ - @Component + @Parameter( defaultValue = "${project}", required = true, readonly = true ) protected MavenProject project; /** diff --git a/helper-maven-plugin/src/main/java/org/nuiton/helper/plugin/ShareServerSecretPlugin.java b/helper-maven-plugin/src/main/java/org/nuiton/helper/plugin/ShareServerSecretPlugin.java index 57149ba..ca6be69 100644 --- a/helper-maven-plugin/src/main/java/org/nuiton/helper/plugin/ShareServerSecretPlugin.java +++ b/helper-maven-plugin/src/main/java/org/nuiton/helper/plugin/ShareServerSecretPlugin.java @@ -64,7 +64,7 @@ public class ShareServerSecretPlugin extends AbstractPlugin { * * @since 1.1.0 */ - @Component + @Parameter( defaultValue = "${project}", required = true, readonly = true ) protected MavenProject project; /** @@ -72,7 +72,7 @@ public class ShareServerSecretPlugin extends AbstractPlugin { * * @since 1.1.0 */ - @Component + @Parameter( defaultValue = "${settings}", required = true, readonly = true ) protected Settings settings; /** diff --git a/helper-maven-plugin/src/main/java/org/nuiton/helper/plugin/TransformProjectVersionMojo.java b/helper-maven-plugin/src/main/java/org/nuiton/helper/plugin/TransformProjectVersionMojo.java index a5bc844..f5564ba 100644 --- a/helper-maven-plugin/src/main/java/org/nuiton/helper/plugin/TransformProjectVersionMojo.java +++ b/helper-maven-plugin/src/main/java/org/nuiton/helper/plugin/TransformProjectVersionMojo.java @@ -23,7 +23,6 @@ package org.nuiton.helper.plugin; */ import org.apache.maven.plugin.MojoExecutionException; -import org.apache.maven.plugins.annotations.Component; import org.apache.maven.plugins.annotations.LifecyclePhase; import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.Parameter; @@ -51,7 +50,7 @@ public class TransformProjectVersionMojo extends AbstractPlugin { * * @since 2.0 */ - @Component + @Parameter( defaultValue = "${project}", required = true, readonly = true ) private MavenProject project; /** -- To stop receiving notification emails like this one, please contact nuiton.org SCM administrator <admin+scm@nuiton.org>.
This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository maven-helper-plugin. See http://git.nuiton.org/maven-helper-plugin.git commit 22b9ef3718ef42770452c303a7abe8fa5f0fff8d Author: Tony CHEMIT <chemit@codelutin.com> Date: Mon May 25 15:23:31 2015 +0200 use jdk 7 api (refs #3702) --- .../src/main/java/org/nuiton/io/FileUpdater.java | 6 +- .../main/java/org/nuiton/io/FileUpdaterHelper.java | 6 +- .../java/org/nuiton/io/MirroredFileUpdater.java | 2 +- .../main/java/org/nuiton/io/SortedProperties.java | 4 +- .../java/org/nuiton/plugin/AbstractPlugin.java | 136 ++++-------- .../java/org/nuiton/plugin/DependencyUtil.java | 14 +- .../src/main/java/org/nuiton/plugin/Plugin.java | 2 +- .../main/java/org/nuiton/plugin/PluginHelper.java | 12 +- .../java/org/nuiton/plugin/PluginIOContext.java | 2 +- .../java/org/nuiton/plugin/PluginWithEncoding.java | 2 +- .../nuiton/plugin/VelocityTemplateGenerator.java | 2 +- .../java/org/nuiton/plugin/PluginHelperTest.java | 2 +- .../test/resources/org/nuiton/io/JaxxDummy.java | 2 +- .../main/java/org/nuiton/plugin/MojoTestRule.java | 67 ++++-- .../main/java/org/nuiton/plugin/TestHelper.java | 2 +- .../java/org/nuiton/helper/io/mail/MailSender.java | 5 +- .../helper/io/mail/ProjectJavamailMailSender.java | 2 +- .../helper/plugin/CheckAutoContainerPlugin.java | 242 ++++++++++----------- .../org/nuiton/helper/plugin/CollectFilesMojo.java | 17 +- .../helper/plugin/ExecuteRemoteCommandMojo.java | 10 +- .../org/nuiton/helper/plugin/SendEmailMojo.java | 25 +-- .../helper/plugin/ShareServerSecretPlugin.java | 4 +- .../helper/plugin/TransformProjectVersionMojo.java | 27 +-- .../plugin/CheckAutoContainerPluginTest.java | 42 ++++ .../nuiton/helper/plugin/SendEmailMojoTest.java | 29 +-- .../plugin/TransformProjectVersionMojoTest.java | 46 ++-- .../checkAutoContainerPluginTest/central.xml | 83 +++++++ 27 files changed, 425 insertions(+), 368 deletions(-) diff --git a/helper-maven-plugin-api/src/main/java/org/nuiton/io/FileUpdater.java b/helper-maven-plugin-api/src/main/java/org/nuiton/io/FileUpdater.java index c8b68b9..ace721a 100644 --- a/helper-maven-plugin-api/src/main/java/org/nuiton/io/FileUpdater.java +++ b/helper-maven-plugin-api/src/main/java/org/nuiton/io/FileUpdater.java @@ -26,10 +26,10 @@ import java.io.File; /** * Contract to be realized to test if a file is up to date. - * <p/> - * use {@link #isFileUpToDate(File)} to determine if a file is up to date. * - * @author tchemit <chemit@codelutin.com> + * Use {@link #isFileUpToDate(File)} to determine if a file is up to date. + * + * @author tchemit - chemit@codelutin.com */ public interface FileUpdater { diff --git a/helper-maven-plugin-api/src/main/java/org/nuiton/io/FileUpdaterHelper.java b/helper-maven-plugin-api/src/main/java/org/nuiton/io/FileUpdaterHelper.java index 4d15393..7ac76c8 100644 --- a/helper-maven-plugin-api/src/main/java/org/nuiton/io/FileUpdaterHelper.java +++ b/helper-maven-plugin-api/src/main/java/org/nuiton/io/FileUpdaterHelper.java @@ -24,7 +24,7 @@ package org.nuiton.io; import java.io.File; -/** @author tchemit <chemit@codelutin.com> */ +/** @author tchemit - chemit@codelutin.com */ public class FileUpdaterHelper { static public MirroredFileUpdater newJavaFileUpdater() { @@ -46,7 +46,7 @@ public class FileUpdaterHelper { /** * To test if a java source file is newser than his compiled class * - * @author tchemit <chemit@codelutin.com> + * @author tchemit - chemit@codelutin.com */ public static class JavaFileUpdater extends MirroredFileUpdater { @@ -70,7 +70,7 @@ public class FileUpdaterHelper { * To test if a jaxx source file is newser than his generated java * source file. * - * @author tchemit <chemit@codelutin.com> + * @author tchemit - chemit@codelutin.com */ public static class JaxxFileUpdater extends MirroredFileUpdater { diff --git a/helper-maven-plugin-api/src/main/java/org/nuiton/io/MirroredFileUpdater.java b/helper-maven-plugin-api/src/main/java/org/nuiton/io/MirroredFileUpdater.java index 5c9460e..be3dad7 100644 --- a/helper-maven-plugin-api/src/main/java/org/nuiton/io/MirroredFileUpdater.java +++ b/helper-maven-plugin-api/src/main/java/org/nuiton/io/MirroredFileUpdater.java @@ -31,7 +31,7 @@ import java.io.File; * Simple base implementation of a {@link FileUpdater} for an updater with * a sourcedir and a destinationdir. * - * @author tchemit <chemit@codelutin.com> + * @author tchemit - chemit@codelutin.com */ public class MirroredFileUpdater implements FileUpdater { diff --git a/helper-maven-plugin-api/src/main/java/org/nuiton/io/SortedProperties.java b/helper-maven-plugin-api/src/main/java/org/nuiton/io/SortedProperties.java index 0bff97d..035f021 100644 --- a/helper-maven-plugin-api/src/main/java/org/nuiton/io/SortedProperties.java +++ b/helper-maven-plugin-api/src/main/java/org/nuiton/io/SortedProperties.java @@ -46,7 +46,7 @@ import java.util.Vector; * be defined but you must use this class only with Java 1.6. * * @author ruchaud <ruchaud@codelutin.com> - * @author tchemit <chemit@codelutin.com> + * @author tchemit - chemit@codelutin.com */ public class SortedProperties extends Properties { @@ -122,7 +122,7 @@ public class SortedProperties extends Properties { } catch (IllegalArgumentException e) { // keys are not string !!! // can not sort keys - result = new Vector<Object>(objects); + result = new Vector<>(objects); } return result.elements(); } diff --git a/helper-maven-plugin-api/src/main/java/org/nuiton/plugin/AbstractPlugin.java b/helper-maven-plugin-api/src/main/java/org/nuiton/plugin/AbstractPlugin.java index 26aac72..7ed5a9c 100644 --- a/helper-maven-plugin-api/src/main/java/org/nuiton/plugin/AbstractPlugin.java +++ b/helper-maven-plugin-api/src/main/java/org/nuiton/plugin/AbstractPlugin.java @@ -49,16 +49,14 @@ import java.util.TreeMap; /** * Base mojo with usefull methods and implementing {@link Plugin} contract. * - * @author tchemit <chemit@codelutin.com> + * @author tchemit - chemit@codelutin.com */ public abstract class AbstractPlugin extends AbstractMojo implements Plugin { /** * Method to initialize the mojo before doing any concrete actions. - * <p/> + * * <b>Note:</b> The method is invoked before the {@link #doAction()} method. - * <p/> - * <p/> * * @throws Exception if any */ @@ -66,7 +64,7 @@ public abstract class AbstractPlugin extends AbstractMojo implements Plugin { /** * Do plugin action. - * <p/> + * * The method {@link #execute()} invoke this method only and only if : * <ul> * <li>{@link #checkPackaging()} returns {@code true}.</li> @@ -103,14 +101,11 @@ public abstract class AbstractPlugin extends AbstractMojo implements Plugin { init(); - } catch (MojoFailureException e) { - throw e; - } catch (MojoExecutionException e) { + } catch (MojoFailureException | MojoExecutionException e) { throw e; } catch (Exception e) { throw new MojoExecutionException( - "could not init goal " + getClass().getSimpleName() + - " for reason : " + e.getMessage(), e); + "could not init goal " + getClass().getSimpleName() + " for reason : " + e.getMessage(), e); } // check if mojo can be skipped @@ -129,14 +124,11 @@ public abstract class AbstractPlugin extends AbstractMojo implements Plugin { doAction(); - } catch (MojoFailureException e) { - throw e; - } catch (MojoExecutionException e) { + } catch (MojoFailureException | MojoExecutionException e) { throw e; } catch (Exception e) { throw new MojoExecutionException( - "could not execute goal " + getClass().getSimpleName() + - " for reason : " + e.getMessage(), e); + "could not execute goal " + getClass().getSimpleName() + " for reason : " + e.getMessage(), e); } } finally { afterExecute(); @@ -150,18 +142,16 @@ public abstract class AbstractPlugin extends AbstractMojo implements Plugin { /** * Check if the project packaging is acceptable for the mojo. - * <p/> + * * By default, accept all packaging types. - * <p/> + * * <b>Note:</b> This method is the first instruction to be executed in * the {@link #execute()}. - * <p/> + * * <b>Tip:</b> There is two method to simplify the packaging check : - * <p/> + * * {@link #acceptPackaging(Plugin.Packaging...)} - * <p/> * and - * <p/> * {@link #rejectPackaging(Plugin.Packaging...)} * * @return {@code true} if can execute the goal for the packaging of the @@ -288,8 +278,7 @@ public abstract class AbstractPlugin extends AbstractMojo implements Plugin { * @param onlyForRoot a flag to * @param buildStartTime the build statrt time (if none means must do it) * @param newStartTime the current build start time - * {@code true} if the goal should be invoked, {@code false} - * otherwise. + * {@code true} if the goal should be invoked, {@code false} otherwise. * @since 2.1 */ protected boolean needInvoke(boolean runOnce, @@ -335,22 +324,17 @@ public abstract class AbstractPlugin extends AbstractMojo implements Plugin { } /** - * Check if an execution should be done or not according to the - * given parameters. - * <p/> - * Will search if the given {@code key} is found in project, if not then - * means that the plugin was not invoked. + * Check if an execution should be done or not according to the given parameters. + * + * Will search if the given {@code key} is found in project, if not then means that the plugin was not invoked. * * @param runOnce always return true if not set * @param onlyForRoot flag to only accept root project * @param key key to check over project (first time will put it in project properties) - * @return {@code true} if the goal should be invoked, {@code false} - * otherwise. + * @return {@code true} if the goal should be invoked, {@code false} otherwise. * @since 2.1 */ - protected boolean needInvoke(boolean runOnce, - boolean onlyForRoot, - String key) { + protected boolean needInvoke(boolean runOnce, boolean onlyForRoot, String key) { if (!runOnce) { // will run each time @@ -407,8 +391,7 @@ public abstract class AbstractPlugin extends AbstractMojo implements Plugin { * @param destFile file name of destination file. * @throws IOException if could not copy file. */ - public void copyFile(File srcFile, File destFile) - throws IOException { + public void copyFile(File srcFile, File destFile) throws IOException { getLog().info("Copying " + srcFile.getName() + " to " + destFile); PluginHelper.copy(srcFile, destFile); @@ -423,9 +406,7 @@ public abstract class AbstractPlugin extends AbstractMojo implements Plugin { * @param encoding the enconding of the file * @throws IOException if any pb while writing the content into the file */ - public void writeFile(File destFile, - String content, - String encoding) throws IOException { + public void writeFile(File destFile, String content, String encoding) throws IOException { PluginHelper.writeString(destFile, content, encoding); } @@ -487,7 +468,7 @@ public abstract class AbstractPlugin extends AbstractMojo implements Plugin { continue; } - List<String> toTreate = new ArrayList<String>(); + List<String> toTreate = new ArrayList<>(); if (updater != null) { updater.setSourceDirectory(f); @@ -528,7 +509,7 @@ public abstract class AbstractPlugin extends AbstractMojo implements Plugin { File srcDir, MirroredFileUpdater updater) { - Map<String, String> result = new TreeMap<String, String>(); + Map<String, String> result = new TreeMap<>(); DirectoryScanner ds = new DirectoryScanner(); ds.setIncludes(includes); @@ -558,7 +539,7 @@ public abstract class AbstractPlugin extends AbstractMojo implements Plugin { return result; } - List<String> toTreate = new ArrayList<String>(); + List<String> toTreate = new ArrayList<>(); if (updater != null) { updater.setSourceDirectory(srcDir); @@ -568,7 +549,7 @@ public abstract class AbstractPlugin extends AbstractMojo implements Plugin { File srcFile = new File(srcDir, filePath); File mirrorFile = updater.getMirrorFile(srcFile); // check file is up-to-date - if (updater == null || !updater.isFileUpToDate(srcFile)) { + if (!updater.isFileUpToDate(srcFile)) { result.put(filePath, mirrorFile.getAbsolutePath()); toTreate.add(filePath); } @@ -638,11 +619,9 @@ public abstract class AbstractPlugin extends AbstractMojo implements Plugin { * @param srcDir the location to remove from test compile source roots */ protected void removeTestCompileSourceRoots(File srcDir) { - if (getProject().getTestCompileSourceRoots().contains( - srcDir.getPath())) { + if (getProject().getTestCompileSourceRoots().contains(srcDir.getPath())) { if (isVerbose()) { - getLog().info("removing test source roots : " + - srcDir.getPath()); + getLog().info("removing test source roots : " + srcDir.getPath()); } getProject().getTestCompileSourceRoots().remove(srcDir.getPath()); } @@ -657,11 +636,9 @@ public abstract class AbstractPlugin extends AbstractMojo implements Plugin { * @since 1.1.1 */ protected void addResourceDir(File dir, String... includes) { - boolean added = PluginHelper.addResourceDir(dir, getProject(), - includes); + boolean added = PluginHelper.addResourceDir(dir, getProject(), includes); if (added && isVerbose()) { - getLog().info("add resource " + dir + " with includes " + - Arrays.toString(includes)); + getLog().info("add resource " + dir + " with includes " + Arrays.toString(includes)); } } @@ -674,11 +651,9 @@ public abstract class AbstractPlugin extends AbstractMojo implements Plugin { * @since 1.1.1 */ protected void addTestResourceDir(File dir, String... includes) { - boolean added = PluginHelper.addTestResourceDir( - dir, getProject(), includes); + boolean added = PluginHelper.addTestResourceDir(dir, getProject(), includes); if (added && isVerbose()) { - getLog().info("add test resource " + dir + " with includes " + - Arrays.toString(includes)); + getLog().info("add test resource " + dir + " with includes " + Arrays.toString(includes)); } } @@ -783,8 +758,8 @@ public abstract class AbstractPlugin extends AbstractMojo implements Plugin { URLClassLoader result; try { - Set<String> dones = new HashSet<String>(); - List<URL> lUrls = new ArrayList<URL>(); + Set<String> dones = new HashSet<>(); + List<URL> lUrls = new ArrayList<>(); List<String> sources = project.getCompileSourceRoots(); if (addSourcesToClassPath) { @@ -794,23 +769,18 @@ public abstract class AbstractPlugin extends AbstractMojo implements Plugin { if (testPhase) { for (Object source : project.getTestCompileSourceRoots()) { - addDirectoryToUrlsList( - new File(source.toString()), lUrls, dones); + addDirectoryToUrlsList(new File(source.toString()), lUrls, dones); } } } if (addResourcesToClassPath) { for (Object source : project.getResources()) { Resource r = (Resource) source; - addDirectoryToUrlsList( - new File(r.getDirectory()), lUrls, dones); + addDirectoryToUrlsList(new File(r.getDirectory()), lUrls, dones); } } if (testPhase && addCompileClassPath) { - addDirectoryToUrlsList( - new File(project.getBuild().getOutputDirectory()), - lUrls, - dones); + addDirectoryToUrlsList(new File(project.getBuild().getOutputDirectory()), lUrls, dones); } if (src != null) { addDirectoryToUrlsList(src, lUrls, dones); @@ -826,10 +796,7 @@ public abstract class AbstractPlugin extends AbstractMojo implements Plugin { } } - result = new URLClassLoader( - lUrls.toArray(new URL[lUrls.size()]), - getClass().getClassLoader() - ); + result = new URLClassLoader(lUrls.toArray(new URL[lUrls.size()]), getClass().getClassLoader()); } catch (IOException e) { throw new RuntimeException( @@ -838,12 +805,11 @@ public abstract class AbstractPlugin extends AbstractMojo implements Plugin { } loader = result; } else { - List<URL> lUrls = new ArrayList<URL>(); + List<URL> lUrls = new ArrayList<>(); if (addSourcesToClassPath) { lUrls.add(src.toURI().toURL()); } - loader = new URLClassLoader(lUrls.toArray(new URL[lUrls.size()]), - getClass().getClassLoader()); + loader = new URLClassLoader(lUrls.toArray(new URL[lUrls.size()]), getClass().getClassLoader()); } if (isVerbose()) { for (URL entry : loader.getURLs()) { @@ -855,7 +821,7 @@ public abstract class AbstractPlugin extends AbstractMojo implements Plugin { /** * Add the given {@code directory} in {@code urls} if not already included. - * <p/> + * * <b>Note:</b> We use a extra list to store file string representation, * since we do NOT want any url resolution and the * {@link URL#equals(Object)} is doing some... @@ -870,14 +836,13 @@ public abstract class AbstractPlugin extends AbstractMojo implements Plugin { File directory, List<URL> urls, Set<String> done) throws MalformedURLException { - // do the comparaison on a String to avoid url to be resolved - // (in URL.equals method) + // do the comparaison on a String to avoid url to be resolved (in URL.equals method) addUrlToUrlsList(directory.toURI().toURL(), urls, done); } /** * Add the given {@code url} in {@code urls} if not already included. - * <p/> + * * <b>Note:</b> We use a extra list to store file string representation, * since we do NOT want any url resolution and the * {@link URL#equals(Object)} is doing some.. @@ -887,12 +852,8 @@ public abstract class AbstractPlugin extends AbstractMojo implements Plugin { * @param done list of string representation of urls * @since 1.1.0 */ - protected void addUrlToUrlsList(URL url, - List<URL> urls, - Set<String> done) { - - // do the comparaison on a String to avoid url to be resolved - // (in URL.equals method) + protected void addUrlToUrlsList(URL url, List<URL> urls, Set<String> done) { + // do the comparaison on a String to avoid url to be resolved (in URL.equals method) String u = url.toString(); if (!done.contains(u)) { done.add(u); @@ -905,8 +866,7 @@ public abstract class AbstractPlugin extends AbstractMojo implements Plugin { * * @param f the required resource file. * @return the url of the resource - * @throws IOException for any error while looking up for the url of - * the resources + * @throws IOException for any error while looking up for the url of the resources */ protected URL getTemplate(File f) throws IOException { URL r; @@ -923,8 +883,7 @@ public abstract class AbstractPlugin extends AbstractMojo implements Plugin { * classPath. * * @param f the required resource file. - * @throws IOException for any error while looking up for the resources - * content. + * @throws IOException for any error while looking up for the resources content. */ protected void checkResource(File f) throws IOException { if (!f.exists()) { @@ -958,10 +917,10 @@ public abstract class AbstractPlugin extends AbstractMojo implements Plugin { /** * Method to be invoked in init phase to check sanity of {@link PluginWithEncoding#getEncoding()}. - * <p/> + * * If no encoding was filled, then use the default for system * (via {@code file.encoding} environement property). - * <p/> + * * <b>Note:</b> If mojo is not implementing {@link PluginWithEncoding}, * nothing is done. * @@ -972,8 +931,7 @@ public abstract class AbstractPlugin extends AbstractMojo implements Plugin { if (PluginWithEncoding.class.isAssignableFrom(getClass())) { if (isVerbose()) { - getLog().info("Will check encoding : " + - ((PluginWithEncoding) this).getEncoding()); + getLog().info("Will check encoding : " + ((PluginWithEncoding) this).getEncoding()); } PluginHelper.checkEncoding((PluginWithEncoding) this); } diff --git a/helper-maven-plugin-api/src/main/java/org/nuiton/plugin/DependencyUtil.java b/helper-maven-plugin-api/src/main/java/org/nuiton/plugin/DependencyUtil.java index e032150..7f5c087 100644 --- a/helper-maven-plugin-api/src/main/java/org/nuiton/plugin/DependencyUtil.java +++ b/helper-maven-plugin-api/src/main/java/org/nuiton/plugin/DependencyUtil.java @@ -32,7 +32,7 @@ import java.util.*; /** * Une classe de methodes utiles sur les dependences entre artifacts. * - * @author tchemit <chemit@codelutin.com> + * @author tchemit - chemit@codelutin.com * @since 0.5 */ public class DependencyUtil { @@ -49,7 +49,7 @@ public class DependencyUtil { } Map<String, ArtifactDependencyEntry> dico = - new HashMap<String, ArtifactDependencyEntry>(artifacts.size()); + new HashMap<>(artifacts.size()); for (Artifact a : artifacts) { ArtifactDependencyEntry entry = new ArtifactDependencyEntry(a); @@ -57,14 +57,14 @@ public class DependencyUtil { } // contient les artifacts non encore fixes - Set<String> universe = new HashSet<String>(dico.keySet()); + Set<String> universe = new HashSet<>(dico.keySet()); // recupere les noeuds pour chaque artifact en une seule passe setNodes(rootNode, dico, universe, verbose); // contient les artifacts resouds dans l'ordre de dependances - List<String> parsed = new ArrayList<String>(); + List<String> parsed = new ArrayList<>(); // premiere passe pour recuperer l'ensemble des dependances for (ArtifactDependencyEntry entry : dico.values()) { @@ -83,7 +83,7 @@ public class DependencyUtil { } // on parcourt les artifacts pour detecter les nouveau // artifacts fixes - List<String> levelFixed = new ArrayList<String>(); + List<String> levelFixed = new ArrayList<>(); for (String key : universe) { ArtifactDependencyEntry entry = dico.get(key); @@ -138,8 +138,8 @@ public class DependencyUtil { Set<String> universe, boolean verbose) { - List<String> order = new ArrayList<String>(); - Set<String> exclude = new HashSet<String>(); + List<String> order = new ArrayList<>(); + Set<String> exclude = new HashSet<>(); if (verbose) { log.info("start [" + entry.artifactKey + "]"); diff --git a/helper-maven-plugin-api/src/main/java/org/nuiton/plugin/Plugin.java b/helper-maven-plugin-api/src/main/java/org/nuiton/plugin/Plugin.java index 52f67bf..7ab813d 100644 --- a/helper-maven-plugin-api/src/main/java/org/nuiton/plugin/Plugin.java +++ b/helper-maven-plugin-api/src/main/java/org/nuiton/plugin/Plugin.java @@ -30,7 +30,7 @@ import org.apache.maven.project.MavenProject; * <p/> * Just expose a {@link #isVerbose()} flag and the maven project {@link #getProject()}. * - * @author tchemit <chemit@codelutin.com> + * @author tchemit - chemit@codelutin.com * @since 1.0.3 */ public interface Plugin extends Mojo { diff --git a/helper-maven-plugin-api/src/main/java/org/nuiton/plugin/PluginHelper.java b/helper-maven-plugin-api/src/main/java/org/nuiton/plugin/PluginHelper.java index e0dccf8..3e29aad 100644 --- a/helper-maven-plugin-api/src/main/java/org/nuiton/plugin/PluginHelper.java +++ b/helper-maven-plugin-api/src/main/java/org/nuiton/plugin/PluginHelper.java @@ -57,7 +57,7 @@ import java.util.zip.ZipFile; /** * Une classe pour mutualiser toutes les méthodes utiles pour un plugin. * - * @author tchemit <chemit@codelutin.com> + * @author tchemit - chemit@codelutin.com */ public class PluginHelper { @@ -209,7 +209,7 @@ public class PluginHelper { * @return la liste des clefs dont la valeur est nulle ou vide */ static public SortedSet<String> getEmptyKeys(Map<?, ?> map) { - SortedSet<String> result = new TreeSet<String>(); + SortedSet<String> result = new TreeSet<>(); for (Entry<?, ?> e : map.entrySet()) { if (e.getValue() == null || e.getValue().toString().isEmpty()) { result.add(e.getKey().toString()); @@ -446,7 +446,7 @@ public class PluginHelper { String[] includes, String[] excludes) { DirectoryScanner ds = new DirectoryScanner(); - List<File> result = new ArrayList<File>(); + List<File> result = new ArrayList<>(); ds.setBasedir(dir); if (includes != null) { ds.setIncludes(includes); @@ -587,7 +587,7 @@ public class PluginHelper { * @throws IOException if any pb while reading file */ public static String[] getLines(File src) throws IOException { - List<String> result = new ArrayList<String>(); + List<String> result = new ArrayList<>(); BufferedReader stream = new BufferedReader( new InputStreamReader(new FileInputStream(src))); @@ -610,7 +610,7 @@ public class PluginHelper { * @throws IOException if any pb while reading file */ public static File[] getLinesAsFiles(File src) throws IOException { - List<File> result = new ArrayList<File>(); + List<File> result = new ArrayList<>(); for (String line : getLines(src)) { if (!line.isEmpty()) { result.add(new File(line)); @@ -625,7 +625,7 @@ public class PluginHelper { * @throws IOException if any pb while reading file */ public static URL[] getLinesAsURL(File src) throws IOException { - List<URL> result = new ArrayList<URL>(); + List<URL> result = new ArrayList<>(); for (String line : getLines(src)) { if (!line.isEmpty()) { result.add(new URL(line)); diff --git a/helper-maven-plugin-api/src/main/java/org/nuiton/plugin/PluginIOContext.java b/helper-maven-plugin-api/src/main/java/org/nuiton/plugin/PluginIOContext.java index 6a3ea6d..b11d108 100644 --- a/helper-maven-plugin-api/src/main/java/org/nuiton/plugin/PluginIOContext.java +++ b/helper-maven-plugin-api/src/main/java/org/nuiton/plugin/PluginIOContext.java @@ -31,7 +31,7 @@ import java.io.File; * <p/> * En sortie, on ne peut avoir qu'un seul répertoire ({@link #output}. * - * @author tchemit <chemit@codelutin.com> + * @author tchemit - chemit@codelutin.com * @since 1.0.1 */ public class PluginIOContext { diff --git a/helper-maven-plugin-api/src/main/java/org/nuiton/plugin/PluginWithEncoding.java b/helper-maven-plugin-api/src/main/java/org/nuiton/plugin/PluginWithEncoding.java index f4e322b..cf529b7 100644 --- a/helper-maven-plugin-api/src/main/java/org/nuiton/plugin/PluginWithEncoding.java +++ b/helper-maven-plugin-api/src/main/java/org/nuiton/plugin/PluginWithEncoding.java @@ -27,7 +27,7 @@ package org.nuiton.plugin; * <p/> * Just expose a getter-setter {@link #getEncoding()} and {@link #setEncoding(String)}. * - * @author tchemit <chemit@codelutin.com> + * @author tchemit - chemit@codelutin.com * @since 1.2.6 */ public interface PluginWithEncoding extends Plugin { diff --git a/helper-maven-plugin-api/src/main/java/org/nuiton/plugin/VelocityTemplateGenerator.java b/helper-maven-plugin-api/src/main/java/org/nuiton/plugin/VelocityTemplateGenerator.java index 6db1fad..aaa5f8f 100644 --- a/helper-maven-plugin-api/src/main/java/org/nuiton/plugin/VelocityTemplateGenerator.java +++ b/helper-maven-plugin-api/src/main/java/org/nuiton/plugin/VelocityTemplateGenerator.java @@ -40,7 +40,7 @@ import java.util.Properties; * <p/> * TODO TC-20091011 should use plexus velocity component * - * @author tchemit <chemit@codelutin.com> + * @author tchemit - chemit@codelutin.com * @since 1.3 */ public class VelocityTemplateGenerator { diff --git a/helper-maven-plugin-api/src/test/java/org/nuiton/plugin/PluginHelperTest.java b/helper-maven-plugin-api/src/test/java/org/nuiton/plugin/PluginHelperTest.java index e6e19a9..b746d83 100644 --- a/helper-maven-plugin-api/src/test/java/org/nuiton/plugin/PluginHelperTest.java +++ b/helper-maven-plugin-api/src/test/java/org/nuiton/plugin/PluginHelperTest.java @@ -34,7 +34,7 @@ import java.net.URL; /** * Tests the {@link PluginHelper} class. * - * @author tchemit <chemit@codelutin.com> + * @author tchemit - chemit@codelutin.com * @since 1.2.3 */ public class PluginHelperTest { diff --git a/helper-maven-plugin-api/src/test/resources/org/nuiton/io/JaxxDummy.java b/helper-maven-plugin-api/src/test/resources/org/nuiton/io/JaxxDummy.java index f4110ae..14b9e2c 100644 --- a/helper-maven-plugin-api/src/test/resources/org/nuiton/io/JaxxDummy.java +++ b/helper-maven-plugin-api/src/test/resources/org/nuiton/io/JaxxDummy.java @@ -22,7 +22,7 @@ package org.nuiton.io; * #L% */ -/** @author tchemit <chemit@codelutin.com> */ +/** @author tchemit - chemit@codelutin.com */ public class JaxxDummy { /** * A dummy file to test {@link org.nuiton.util.FileUpdaterHelper.JaxxFileUpdater} in {@link JaxxFileUpdaterTest} diff --git a/helper-maven-plugin-test-api/src/main/java/org/nuiton/plugin/MojoTestRule.java b/helper-maven-plugin-test-api/src/main/java/org/nuiton/plugin/MojoTestRule.java index a014b09..a43763a 100644 --- a/helper-maven-plugin-test-api/src/main/java/org/nuiton/plugin/MojoTestRule.java +++ b/helper-maven-plugin-test-api/src/main/java/org/nuiton/plugin/MojoTestRule.java @@ -26,7 +26,7 @@ import java.io.File; * the mojo</li> <li>{@link #mojo} : the instanciated and initialized * mojo</li> </ul> */ -public abstract class MojoTestRule<P extends Plugin> extends MojoRule { +public class MojoTestRule<P extends AbstractPlugin> extends MojoRule { /** Logger. */ private static final Log log = LogFactory.getLog(MojoTestRule.class); @@ -56,11 +56,19 @@ public abstract class MojoTestRule<P extends Plugin> extends MojoRule { */ private final Class<?> testClass; - protected MojoTestRule(Class<?> testClass) { - this.testClass = testClass; + /** + * Goal name of the mojo to test. + */ + private final String goalName; + + public static <P extends AbstractPlugin> MojoTestRule<P> newRule(Class<?> testClass, String goalName) { + return new MojoTestRule<>(testClass, goalName); } - protected abstract String getGoalName(String methodName); + protected MojoTestRule(Class<?> testClass, String goalName) { + this.testClass = testClass; + this.goalName = goalName; + } @Override public Statement apply(final Statement base, Description description) { @@ -103,6 +111,28 @@ public abstract class MojoTestRule<P extends Plugin> extends MojoRule { } + public boolean initMojo(P mojo) { + + boolean canContinue; + try { + + mojo.init(); + canContinue = true; + + } catch (Exception e) { + + canContinue = false; + + if (log.isDebugEnabled()) { + log.debug("Could not init mojo ", e); + } + + } + + return canContinue; + + } + protected void tearDownMojo(P mojo) { // by default nothing to clear @@ -112,17 +142,11 @@ public abstract class MojoTestRule<P extends Plugin> extends MojoRule { @Override protected void before() throws Throwable { - if (TestHelper.isVerbose()) { - log.info("=============================================================================================="); - } - log.info("Starting test: " + testClass.getName() + "#" + testMethodName); - String goalName = getGoalName(testMethodName); + testDirectory = getTestDir(testMethodName); - testDirectory = getTestDir(testMethodName, goalName); - - pomFile = getPomFile(testDirectory, testMethodName, goalName); + pomFile = getPomFile(testDirectory, testMethodName); try { @@ -167,17 +191,15 @@ public abstract class MojoTestRule<P extends Plugin> extends MojoRule { /** * Obtain the location of the directory where to find resources for the next test. * - * By convention, will be the package named by the test class name from the - * {@link TestHelper#getTestBasedir()}. + * By convention, will be the package named by the test class name from the {@link TestHelper#getTestBasedir()}. * * @param methodName the method of the next test to execute - * @param goalName the common goal name to use * @return the directory where to find resources for the test */ - protected File getTestDir(String methodName, String goalName) { + protected File getTestDir(String methodName) { //TC-20091101 use a decipatilize simple name to avoid conflict of package with existing class name. - String rep = getClass().getPackage().getName() + "." + Introspector.decapitalize(testClass.getSimpleName()); + String rep = testClass.getPackage().getName() + "." + Introspector.decapitalize(testClass.getSimpleName()); String[] paths = rep.split("\\."); File directory = TestHelper.getFile(TestHelper.getTestBasedir(), paths); if (TestHelper.isVerbose()) { @@ -191,18 +213,15 @@ public abstract class MojoTestRule<P extends Plugin> extends MojoRule { /** * Obtain the location of the pom file to use for next mojo test. - * <p/> - * By default, the pom file is the file with name {@code methodName+".xml"} - * in the {@code testDir}. + * + * By default, the pom file is the file with name {@code methodName+".xml"} in the {@code testDir}. * * @param testDir the location of resources for the next test (is the - * result of the method {@link #getTestDir(String, - * String)}. + * result of the method {@link #getTestDir(String)}. * @param methodName the name of the next test - * @param goalName the name of the common goal * @return the location of the pom file for the next mojo test. */ - protected File getPomFile(File testDir, String methodName, String goalName) { + protected File getPomFile(File testDir, String methodName) { File pom = new File(testDir, methodName + ".xml"); diff --git a/helper-maven-plugin-test-api/src/main/java/org/nuiton/plugin/TestHelper.java b/helper-maven-plugin-test-api/src/main/java/org/nuiton/plugin/TestHelper.java index 8151a50..1f46b51 100644 --- a/helper-maven-plugin-test-api/src/main/java/org/nuiton/plugin/TestHelper.java +++ b/helper-maven-plugin-test-api/src/main/java/org/nuiton/plugin/TestHelper.java @@ -9,7 +9,7 @@ import java.io.File; import java.io.IOException; /** - * @author tchemit <chemit@codelutin.com> + * @author tchemit - chemit@codelutin.com * @since 1.0.3 */ public abstract class TestHelper extends PluginHelper { diff --git a/helper-maven-plugin/src/main/java/org/nuiton/helper/io/mail/MailSender.java b/helper-maven-plugin/src/main/java/org/nuiton/helper/io/mail/MailSender.java index 1570234..b1c312c 100644 --- a/helper-maven-plugin/src/main/java/org/nuiton/helper/io/mail/MailSender.java +++ b/helper-maven-plugin/src/main/java/org/nuiton/helper/io/mail/MailSender.java @@ -25,10 +25,9 @@ package org.nuiton.helper.io.mail; /** * Defines the sender of a email. * - * Note : this code was stolen in {@code maven-changes-plugin}, should thanks - * them... + * Note : this code was stolen in {@code maven-changes-plugin}, should thanks them... * - * @author tchemit <chemit@codelutin.com> + * @author tchemit - chemit@codelutin.com * @since 1.0.3 */ public class MailSender { diff --git a/helper-maven-plugin/src/main/java/org/nuiton/helper/io/mail/ProjectJavamailMailSender.java b/helper-maven-plugin/src/main/java/org/nuiton/helper/io/mail/ProjectJavamailMailSender.java index 1abead3..00a289d 100644 --- a/helper-maven-plugin/src/main/java/org/nuiton/helper/io/mail/ProjectJavamailMailSender.java +++ b/helper-maven-plugin/src/main/java/org/nuiton/helper/io/mail/ProjectJavamailMailSender.java @@ -48,7 +48,7 @@ import java.util.Properties; * Note : this code was stolen in {@code maven-changes-plugin}, should thanks * them... * - * @author tchemit <chemit@codelutin.com> + * @author tchemit - chemit@codelutin.com * @since 1.0.3 */ public class ProjectJavamailMailSender diff --git a/helper-maven-plugin/src/main/java/org/nuiton/helper/plugin/CheckAutoContainerPlugin.java b/helper-maven-plugin/src/main/java/org/nuiton/helper/plugin/CheckAutoContainerPlugin.java index 583f7b9..7c3fb76 100644 --- a/helper-maven-plugin/src/main/java/org/nuiton/helper/plugin/CheckAutoContainerPlugin.java +++ b/helper-maven-plugin/src/main/java/org/nuiton/helper/plugin/CheckAutoContainerPlugin.java @@ -24,12 +24,12 @@ package org.nuiton.helper.plugin; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.ArtifactUtils; -import org.apache.maven.artifact.factory.ArtifactFactory; -import org.apache.maven.artifact.manager.WagonManager; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.repository.ArtifactRepositoryFactory; import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout; import org.apache.maven.artifact.repository.layout.DefaultRepositoryLayout; +import org.apache.maven.artifact.resolver.ArtifactResolutionRequest; +import org.apache.maven.artifact.resolver.ArtifactResolutionResult; import org.apache.maven.artifact.resolver.ArtifactResolver; import org.apache.maven.plugin.MojoFailureException; import org.apache.maven.plugin.logging.Log; @@ -40,17 +40,13 @@ import org.apache.maven.plugins.annotations.Parameter; import org.apache.maven.plugins.annotations.ResolutionScope; import org.apache.maven.project.MavenProject; import org.apache.maven.settings.Proxy; -import org.apache.maven.wagon.ConnectionException; -import org.apache.maven.wagon.Wagon; -import org.apache.maven.wagon.authentication.AuthenticationInfo; -import org.apache.maven.wagon.observers.Debug; import org.apache.maven.wagon.proxy.ProxyInfo; -import org.apache.maven.wagon.repository.Repository; import org.codehaus.plexus.util.StringUtils; import org.nuiton.plugin.AbstractPlugin; import org.nuiton.plugin.PluginHelper; import java.util.ArrayList; +import java.util.Collections; import java.util.List; import java.util.Map; import java.util.TreeMap; @@ -58,15 +54,15 @@ import java.util.TreeMap; /** * Check all dependencies are auto contained in the given repositories. * - * @author tchemit <chemit@codelutin.com> + * @author tchemit - chemit@codelutin.com * @version $Id$ * @since 1.2.5 */ @Mojo(name = "check-auto-container", - defaultPhase = LifecyclePhase.VALIDATE, - requiresProject = true, - requiresOnline = true, - requiresDependencyResolution = ResolutionScope.RUNTIME) + defaultPhase = LifecyclePhase.VALIDATE, + requiresProject = true, + requiresOnline = true, + requiresDependencyResolution = ResolutionScope.RUNTIME) public class CheckAutoContainerPlugin extends AbstractPlugin { /** @@ -136,7 +132,7 @@ public class CheckAutoContainerPlugin extends AbstractPlugin { * * @since 1.2.5 */ - @Parameter( defaultValue = "${project}", required = true, readonly = true ) + @Parameter(defaultValue = "${project}", required = true, readonly = true) protected MavenProject project; /** @@ -156,14 +152,6 @@ public class CheckAutoContainerPlugin extends AbstractPlugin { protected Proxy proxy; /** - * Local repository. - * - * @since 1.2.5 - */ - @Parameter(property = "localRepository", required = true, readonly = true) - protected ArtifactRepository localRepository; - - /** * Artifact repository factory component. * * @since 1.2.5 @@ -172,28 +160,12 @@ public class CheckAutoContainerPlugin extends AbstractPlugin { protected ArtifactRepositoryFactory artifactRepositoryFactory; /** - * Artifact factory component. - * - * @since 1.2.5 - */ - @Component - protected ArtifactFactory factory; - - /** - * Artifact resolver component. - * - * @since 1.2.5 - */ - @Component - protected ArtifactResolver resolver; - - /** * Wagon manager component. * * @since 1.2.5 */ @Component - protected WagonManager wagonManager; + protected ArtifactResolver artifactResolver; /** * Authorized Remote Repositories. @@ -210,8 +182,7 @@ public class CheckAutoContainerPlugin extends AbstractPlugin { private List<Artifact> artifacts; /** - * Dictionnary of already resolved artifacts (keys are repository url and - * values are list of artifact ids). + * Dictionnary of already resolved artifacts (keys are repository url and values are list of artifact ids). * * @since 1.2.5 */ @@ -321,29 +292,26 @@ public class CheckAutoContainerPlugin extends AbstractPlugin { // no more artifacts to check continue; } + long t0 = System.nanoTime(); String url = repository.getUrl(); List<String> ids = getRepositoryCache(url); - Wagon wagon = getWagon(repository); - try { - if (verbose) { - log.info("Use repository " + url); - } - List<Artifact> found = checkDependency(repository, wagon, ids); - long delay = System.nanoTime() - t0; - String message; - if (found.isEmpty()) { - message = "No artifact resolved by the repository " + url; - } else { - message = String.format("%1$4s artifact(s) resolved by repository %2$s in %3$s", found.size(), url, PluginHelper.convertTime(delay)); - } - log.info(message); - artifacts.removeAll(found); - } finally { - disconnect(wagon); + if (verbose) { + log.info("Use repository " + url); + } + List<Artifact> found = checkDependency(repository, ids); + long delay = System.nanoTime() - t0; + String message; + if (found.isEmpty()) { + message = "No artifact resolved by the repository " + url; + } else { + message = String.format("%1$4s artifact(s) resolved by repository %2$s in %3$s", found.size(), url, PluginHelper.convertTime(delay)); } + log.info(message); + artifacts.removeAll(found); + } boolean safe = artifacts.isEmpty(); @@ -363,47 +331,49 @@ public class CheckAutoContainerPlugin extends AbstractPlugin { } protected List<ArtifactRepository> createSafeRepositories() { - List<ArtifactRepository> safeRepositories = new ArrayList<ArtifactRepository>(); + + List<ArtifactRepository> result = new ArrayList<>(); ArtifactRepositoryLayout repositoryLayout = new DefaultRepositoryLayout(); - if (repositories == null) { - repositories = new TreeMap<String, String>(); + if (this.repositories == null) { + this.repositories = new TreeMap<>(); } - List<String> ids = new ArrayList<String>(repositories.keySet()); + List<String> ids = new ArrayList<>(this.repositories.keySet()); if (addMavenCentral) { ids.add(0, MAVEN_CENTRAL_ID); - repositories.put(MAVEN_CENTRAL_ID, MAVEN_CENTRAL_URL); + this.repositories.put(MAVEN_CENTRAL_ID, MAVEN_CENTRAL_URL); } for (String id : ids) { - String url = repositories.get(id); - url = url.trim(); - ArtifactRepository repo; - repo = artifactRepositoryFactory.createDeploymentArtifactRepository( - String.valueOf(id), - url, - repositoryLayout, true); + String url = this.repositories.get(id).trim(); + + ArtifactRepository repo = artifactRepositoryFactory.createDeploymentArtifactRepository( + String.valueOf(id), url, repositoryLayout, true); getLog().info("Will use repository " + repo.getUrl()); if (verbose) { getLog().info(repo.toString()); } - safeRepositories.add(repo); + result.add(repo); } - return safeRepositories; + + return result; + } protected List<Artifact> prepareArtifacts() { - List<Artifact> result = new ArrayList<Artifact>(); + List<Artifact> result = new ArrayList<>(); - List<String> siblings = new ArrayList<String>(); + List<String> siblings = new ArrayList<>(); - for (Object o : reactorProjects) { - MavenProject m = (MavenProject) o; - siblings.add(getArtifactId(m.getArtifact())); + if (reactorProjects != null) { + for (Object o : reactorProjects) { + MavenProject m = (MavenProject) o; + siblings.add(getArtifactId(m.getArtifact())); + } } // treate classic dependencies @@ -454,12 +424,10 @@ public class CheckAutoContainerPlugin extends AbstractPlugin { return artifact; } - private List<Artifact> checkDependency(ArtifactRepository repo, - Wagon wagon, - List<String> ids) throws Exception { + private List<Artifact> checkDependency(ArtifactRepository repo, List<String> ids) throws Exception { + Log log = getLog(); - List<Artifact> result = new ArrayList<Artifact>(); - String url = repo.getUrl(); + List<Artifact> result = new ArrayList<>(); for (Artifact artifact : artifacts) { if (log.isDebugEnabled()) { @@ -467,36 +435,54 @@ public class CheckAutoContainerPlugin extends AbstractPlugin { } String id = getArtifactId(artifact); - boolean resolved; + boolean found; + boolean inCache = ids.contains(id); if (inCache) { // already resolved - resolved = true; + found = true; + } else { // first time resolving this artifact - Artifact copyArtifact = ArtifactUtils.copyArtifact(artifact); - String path = url + "/" + repo.pathOf(copyArtifact); + ArtifactResolutionRequest request = new ArtifactResolutionRequest(); + request.setForceUpdate(true); + request.setRemoteRepositories(Collections.singletonList(repo)); + + if (proxy != null) { + + request.setProxies(Collections.singletonList(proxy)); + + } + request.setArtifact(artifact); + + ArtifactResolutionResult resolutionResult = artifactResolver.resolve(request); + + found = resolutionResult.isSuccess(); - resolved = wagon.resourceExists(StringUtils.replace(path, repo.getUrl(), "")); } - if (resolved) { + if (found) { if (verbose) { log.info(" - [ resolved ] " + artifact + (inCache ? " (from cache)" : "")); } result.add(artifact); ids.add(id); + } else { + if (log.isDebugEnabled()) { log.debug(" - [unresolved] " + artifact); } + } } + return result; + } protected String getArtifactId(Artifact artifact) { @@ -508,56 +494,56 @@ public class CheckAutoContainerPlugin extends AbstractPlugin { protected List<String> getRepositoryCache(String url) { if (resolved == null) { - resolved = new TreeMap<String, List<String>>(); + resolved = new TreeMap<>(); } List<String> ids = resolved.get(url); if (ids == null) { - ids = new ArrayList<String>(); + ids = new ArrayList<>(); resolved.put(url, ids); } return ids; } - protected Wagon getWagon(ArtifactRepository repo) throws Exception { - - Repository repository = new Repository(repo.getId(), repo.getUrl()); - Wagon wagon = wagonManager.getWagon(repository); - - wagon.setTimeout(1000); - - if (getLog().isDebugEnabled()) { - Debug debug = new Debug(); - - wagon.addSessionListener(debug); - wagon.addTransferListener(debug); - } - - // FIXME when upgrading to maven 3.x : this must be changed. - AuthenticationInfo auth = wagonManager.getAuthenticationInfo(repo.getId()); - - ProxyInfo proxyInfo = getProxyInfo(); - if (proxyInfo != null) { - wagon.connect(repository, auth, proxyInfo); - } else { - wagon.connect(repository, auth); - } - - return wagon; - } - - protected void disconnect(Wagon wagon) { - try { - wagon.disconnect(); - } catch (ConnectionException e) { - Log log = getLog(); - if (log.isDebugEnabled()) { - log.error("Error disconnecting wagon - ignored", e); - } else { - log.error("Error disconnecting wagon - ignored"); - } - } - } +// protected Wagon getWagon(ArtifactRepository repo) throws Exception { +// +// Repository repository = new Repository(repo.getId(), repo.getUrl()); +// Wagon wagon = wagonManager.getWagon(repository); +// +// wagon.setTimeout(1000); +// +// if (getLog().isDebugEnabled()) { +// Debug debug = new Debug(); +// +// wagon.addSessionListener(debug); +// wagon.addTransferListener(debug); +// } +// +// // FIXME when upgrading to maven 3.x : this must be changed. +// AuthenticationInfo auth = wagonManager.getAuthenticationInfo(repo.getId()); +// +// ProxyInfo proxyInfo = getProxyInfo(); +// if (proxyInfo != null) { +// wagon.connect(repository, auth, proxyInfo); +// } else { +// wagon.connect(repository, auth); +// } +// +// return wagon; +// } +// +// protected void disconnect(Wagon wagon) { +// try { +// wagon.disconnect(); +// } catch (ConnectionException e) { +// Log log = getLog(); +// if (log.isDebugEnabled()) { +// log.error("Error disconnecting wagon - ignored", e); +// } else { +// log.error("Error disconnecting wagon - ignored"); +// } +// } +// } protected ProxyInfo getProxyInfo() { ProxyInfo proxyInfo = null; diff --git a/helper-maven-plugin/src/main/java/org/nuiton/helper/plugin/CollectFilesMojo.java b/helper-maven-plugin/src/main/java/org/nuiton/helper/plugin/CollectFilesMojo.java index 3439d2c..8d65dcd 100644 --- a/helper-maven-plugin/src/main/java/org/nuiton/helper/plugin/CollectFilesMojo.java +++ b/helper-maven-plugin/src/main/java/org/nuiton/helper/plugin/CollectFilesMojo.java @@ -45,7 +45,7 @@ import java.util.regex.Pattern; /** * Collect files some files from a project and copy them into a directory. * - * @author tchemit <chemit@codelutin.com> + * @author tchemit - chemit@codelutin.com * @since 1.1.0 */ @Mojo(name = "collect-files", requiresProject = true) @@ -298,18 +298,16 @@ public class CollectFilesMojo extends AbstractPlugin implements PluginWithEncodi incomingFiles = getFiles(description); getLog().info("Loaded " + description); } catch (IOException ex) { - throw new MojoExecutionException( - "could not load file " + description, ex); + throw new MojoExecutionException("could not load file " + description, ex); } } else { - incomingFiles = new ArrayList<File>(); + incomingFiles = new ArrayList<>(); } } if (!withDescriptionFile && !copyFiles) { throw new MojoExecutionException( - "must use at least one of the parameters 'copyFiles' or " + - "'descriptionFile'"); + "must use at least one of the parameters 'copyFiles' or 'descriptionFile'"); } String basedir = rootProject.getBasedir().getAbsolutePath(); @@ -344,8 +342,7 @@ public class CollectFilesMojo extends AbstractPlugin implements PluginWithEncodi getLog().info("Saved " + description); } } catch (IOException ex) { - throw new MojoExecutionException( - "could not save file " + description, ex); + throw new MojoExecutionException("could not save file " + description, ex); } } } @@ -358,7 +355,7 @@ public class CollectFilesMojo extends AbstractPlugin implements PluginWithEncodi * @throws IOException if any pb while reading file */ public List<File> getFiles(File input) throws IOException { - List<File> result = new ArrayList<File>(); + List<File> result = new ArrayList<>(); result.addAll(Arrays.asList(PluginHelper.getLinesAsFiles(input))); return result; } @@ -387,7 +384,7 @@ public class CollectFilesMojo extends AbstractPlugin implements PluginWithEncodi Pattern excludePattern = StringUtils.isBlank(excludes) ? null : Pattern.compile(excludes.trim()); - List<File> result = new ArrayList<File>(); + List<File> result = new ArrayList<>(); // attach the project mail file diff --git a/helper-maven-plugin/src/main/java/org/nuiton/helper/plugin/ExecuteRemoteCommandMojo.java b/helper-maven-plugin/src/main/java/org/nuiton/helper/plugin/ExecuteRemoteCommandMojo.java index e3a8524..8c7e265 100644 --- a/helper-maven-plugin/src/main/java/org/nuiton/helper/plugin/ExecuteRemoteCommandMojo.java +++ b/helper-maven-plugin/src/main/java/org/nuiton/helper/plugin/ExecuteRemoteCommandMojo.java @@ -46,7 +46,7 @@ import org.nuiton.plugin.AbstractPlugin; /** * Mojo to execute on a remote server some scripts. * - * @author tchemit <chemit@codelutin.com> + * @author tchemit - chemit@codelutin.com * @since 1.3.1 */ @Mojo(name = "execute-remote-command", @@ -85,7 +85,7 @@ public class ExecuteRemoteCommandMojo extends AbstractPlugin { /** * Url where to execute script. - * <p/> + * * The url must contains the wagon protocol (says scp:... or scpexe:...). */ @Parameter(property = "helper.repositoryUrl", required = true) @@ -120,8 +120,7 @@ public class ExecuteRemoteCommandMojo extends AbstractPlugin { if (server == null) { throw new MojoExecutionException( - "Could not find server with id '" + repositoryId + - "', check your settings.xml file."); + "Could not find server with id '" + repositoryId + "', check your settings.xml file."); } Repository repository = new Repository(repositoryId, repositoryUrl); @@ -132,8 +131,7 @@ public class ExecuteRemoteCommandMojo extends AbstractPlugin { disconnect(wagon); throw new MojoExecutionException( - "The wagon " + wagon + " is not a command executor, " + - "will not be able to execute command."); + "The wagon " + wagon + " is not a command executor, will not be able to execute command."); } commandExecutor = (CommandExecutor) wagon; diff --git a/helper-maven-plugin/src/main/java/org/nuiton/helper/plugin/SendEmailMojo.java b/helper-maven-plugin/src/main/java/org/nuiton/helper/plugin/SendEmailMojo.java index 0023505..40a51cc 100644 --- a/helper-maven-plugin/src/main/java/org/nuiton/helper/plugin/SendEmailMojo.java +++ b/helper-maven-plugin/src/main/java/org/nuiton/helper/plugin/SendEmailMojo.java @@ -44,7 +44,7 @@ import java.util.List; /** * Send a email. * - * @author tchemit <chemit@codelutin.com> + * @author tchemit - chemit@codelutin.com * @since 1.0.3 */ @Mojo(name = "send-email", requiresOnline = true, requiresProject = true) @@ -244,8 +244,7 @@ public class SendEmailMojo extends AbstractPlugin implements PluginWithEncoding if (!emailContentFile.exists()) { // no file to publish... - throw new MojoExecutionException( - "could not find the template " + emailContentFile); + throw new MojoExecutionException("could not find the template " + emailContentFile); } // check mail sender @@ -265,16 +264,13 @@ public class SendEmailMojo extends AbstractPlugin implements PluginWithEncoding } else { for (Developer developer : from) { if (fromDeveloperId.equals(developer.getId())) { - mailSender = new MailSender(developer.getName(), - developer.getEmail() - ); + mailSender = new MailSender(developer.getName(), developer.getEmail()); break; } } if (mailSender == null) { throw new MojoExecutionException( - "Missing developer with id '" + fromDeveloperId + - "' in the <developers> section in your pom."); + "Missing developer with id '" + fromDeveloperId + "' in the <developers> section in your pom."); } } } @@ -282,13 +278,11 @@ public class SendEmailMojo extends AbstractPlugin implements PluginWithEncoding String fromAddress = mailSender.getEmail(); if (StringUtils.isEmpty(fromAddress)) { throw new MojoExecutionException( - "Invalid mail sender: name and email is mandatory (" + - mailSender + ")."); + "Invalid mail sender: name and email is mandatory (" + mailSender + ")."); } if (StringUtils.isBlank(emailTitle)) { - throw new MojoExecutionException( - "Mail title can not be blank."); + throw new MojoExecutionException("Mail title can not be blank."); } emailTitle = emailTitle.trim(); @@ -367,15 +361,12 @@ public class SendEmailMojo extends AbstractPlugin implements PluginWithEncoding return skipSendEmail; } - protected MailMessage createMessage( - String newsContent, - MailSender mailSender) throws MailSenderException { + protected MailMessage createMessage(String newsContent, MailSender mailSender) throws MailSenderException { String fromName = mailSender.getName(); String fromAddress = mailSender.getEmail(); - getLog().info("Using this sender for email announcement: " + - fromAddress + " < " + fromName + " > "); + getLog().info("Using this sender for email announcement: " + fromAddress + " < " + fromName + " > "); MailMessage mailMsg = new MailMessage(); mailMsg.setSubject(emailTitle); diff --git a/helper-maven-plugin/src/main/java/org/nuiton/helper/plugin/ShareServerSecretPlugin.java b/helper-maven-plugin/src/main/java/org/nuiton/helper/plugin/ShareServerSecretPlugin.java index ca6be69..b2ef259 100644 --- a/helper-maven-plugin/src/main/java/org/nuiton/helper/plugin/ShareServerSecretPlugin.java +++ b/helper-maven-plugin/src/main/java/org/nuiton/helper/plugin/ShareServerSecretPlugin.java @@ -51,7 +51,7 @@ import java.util.Properties; * passphraseOut * </pre> * - * @author tchemit <chemit@codelutin.com> + * @author tchemit - chemit@codelutin.com * @since 1.1.0 */ @Mojo(name = "share-server-secret", @@ -225,7 +225,7 @@ public class ShareServerSecretPlugin extends AbstractPlugin { return; } - propertiesToTreate = new EnumMap<Property, String>(Property.class); + propertiesToTreate = new EnumMap<>(Property.class); if (StringUtils.isNotEmpty(usernameOut)) { propertiesToTreate.put(Property.username, usernameOut); diff --git a/helper-maven-plugin/src/main/java/org/nuiton/helper/plugin/TransformProjectVersionMojo.java b/helper-maven-plugin/src/main/java/org/nuiton/helper/plugin/TransformProjectVersionMojo.java index f5564ba..0d170d6 100644 --- a/helper-maven-plugin/src/main/java/org/nuiton/helper/plugin/TransformProjectVersionMojo.java +++ b/helper-maven-plugin/src/main/java/org/nuiton/helper/plugin/TransformProjectVersionMojo.java @@ -34,7 +34,7 @@ import java.util.Properties; /** * Transform the version of the project and store it in a project property. * - * @author tchemit <chemit@codelutin.com> + * @author tchemit - chemit@codelutin.com * @since 2.0 */ @Mojo(name = "transform-project-version", @@ -88,8 +88,7 @@ public class TransformProjectVersionMojo extends AbstractPlugin { * * @since 2.0 */ - @Parameter(property = "helper.versionKey", defaultValue = "newVersion", - required = true) + @Parameter(property = "helper.versionKey", defaultValue = "newVersion", required = true) private String versionKey = "newVersion"; /** @@ -122,11 +121,13 @@ public class TransformProjectVersionMojo extends AbstractPlugin { // check if plugin was already done. - boolean shouldInvoke = needInvoke(runOnce, false, key); + boolean shouldInvoke = needInvoke(true, false, key); - return shouldInvoke && super.checkSkip(); + result = shouldInvoke && super.checkSkip(); } + return result; + } @Override @@ -136,9 +137,7 @@ public class TransformProjectVersionMojo extends AbstractPlugin { if (!newVersionPattern.contains("#V") && !newVersionPattern.contains("#R")) { throw new MojoExecutionException( - "newVersionPattern (" + newVersionPattern + - ") must at least contains one of those patterns:" + - " *#V* or *#R*."); + "newVersionPattern (" + newVersionPattern + ") must at least contains one of those patterns: *#V* or *#R*."); } if (newVersionPattern.contains("#S")) { @@ -149,14 +148,12 @@ public class TransformProjectVersionMojo extends AbstractPlugin { if (firstIndex != lastIndex) { throw new MojoExecutionException( - "newVersionPattern (" + newVersionPattern + - ") can only contains one pattern *#S*."); + "newVersionPattern (" + newVersionPattern + ") can only contains one pattern *#S*."); } if (lastIndex != newVersionPattern.length() - 2) { throw new MojoExecutionException( - "newVersionPattern (" + newVersionPattern + - ") can only contains pattern *#S* at his end."); + "newVersionPattern (" + newVersionPattern + ") can only contains pattern *#S* at his end."); } } @@ -174,8 +171,7 @@ public class TransformProjectVersionMojo extends AbstractPlugin { if (snapshotFound) { // remove snapshot - version = version.substring(0, version.length() - - SNAPSHOT_SUFFIX.length()); + version = version.substring(0, version.length() - SNAPSHOT_SUFFIX.length()); } String newVersion = newVersionPattern.replaceAll("#V", version); @@ -189,8 +185,7 @@ public class TransformProjectVersionMojo extends AbstractPlugin { Properties properties = project.getProperties(); - getLog().info("export newVersion [" + newVersion + "] " + - " in ${" + versionKey + "}"); + getLog().info("export newVersion [" + newVersion + "] in ${" + versionKey + "}"); properties.setProperty(versionKey, newVersion); } diff --git a/helper-maven-plugin/src/test/java/org/nuiton/helper/plugin/CheckAutoContainerPluginTest.java b/helper-maven-plugin/src/test/java/org/nuiton/helper/plugin/CheckAutoContainerPluginTest.java new file mode 100644 index 0000000..977d15a --- /dev/null +++ b/helper-maven-plugin/src/test/java/org/nuiton/helper/plugin/CheckAutoContainerPluginTest.java @@ -0,0 +1,42 @@ +package org.nuiton.helper.plugin; + +import org.junit.Assert; +import org.junit.Assume; +import org.junit.Ignore; +import org.junit.Rule; +import org.junit.Test; +import org.nuiton.plugin.MojoTestRule; + +/** + * Created on 5/25/15. + * + * @author Tony Chemit - chemit@codelutin.com + * @since 2.2 + */ +public class CheckAutoContainerPluginTest { + + @Rule + public MojoTestRule<CheckAutoContainerPlugin> rule = + MojoTestRule.newRule(CheckAutoContainerPluginTest.class, "check-auto-container"); + + //FIXME Got a NPE in artifact resolver (session is null) :( + /* + java.lang.NullPointerException + at org.apache.maven.artifact.resolver.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:208) + at org.apache.maven.artifact.resolver.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:401) + at org.nuiton.helper.plugin.CheckAutoContainerPlugin.checkDependency(CheckAutoContainerPlugin.java:461) + */ + @Ignore + @Test + public void central() throws Exception { + + CheckAutoContainerPlugin mojo = rule.getMojo(); + Assert.assertNotNull(mojo); + boolean canContinue = rule.initMojo(mojo); + Assume.assumeTrue(canContinue); + + mojo.doAction(); + + } + +} \ No newline at end of file diff --git a/helper-maven-plugin/src/test/java/org/nuiton/helper/plugin/SendEmailMojoTest.java b/helper-maven-plugin/src/test/java/org/nuiton/helper/plugin/SendEmailMojoTest.java index ead8638..4546600 100644 --- a/helper-maven-plugin/src/test/java/org/nuiton/helper/plugin/SendEmailMojoTest.java +++ b/helper-maven-plugin/src/test/java/org/nuiton/helper/plugin/SendEmailMojoTest.java @@ -35,7 +35,7 @@ import java.io.File; import java.util.Collections; /** - * @author tchemit <chemit@codelutin.com> + * @author tchemit - chemit@codelutin.com * @since 1.0.0 */ public class SendEmailMojoTest { @@ -44,12 +44,7 @@ public class SendEmailMojoTest { private static final Log log = LogFactory.getLog(SendEmailMojoTest.class); @Rule - public MojoTestRule<SendEmailMojo> rule = new MojoTestRule<SendEmailMojo>(SendEmailMojoTest.class) { - - @Override - protected String getGoalName(String methodName) { - return "send-email"; - } + public MojoTestRule<SendEmailMojo> rule = new MojoTestRule<SendEmailMojo>(SendEmailMojoTest.class, "send-email") { @Override protected void setUpMojo(SendEmailMojo mojo, File pomFile) throws Exception { @@ -65,12 +60,7 @@ public class SendEmailMojoTest { // add a destination mojo.setToAddresses(Collections.singletonList("chemit@codelutin.com")); - try { - mojo.init(); - canContinue = true; - } catch (Exception e) { - canContinue = false; - } + canContinue = initMojo(mojo); if (canContinue) { if (mojo.isVerbose()) { @@ -88,17 +78,22 @@ public class SendEmailMojoTest { @Test public void sendEmail() throws Exception { + Assume.assumeTrue(canContinue); + SendEmailMojo mojo = rule.getMojo(); + Assert.assertNotNull(mojo); + mojo.doAction(); - Assert.assertNotNull(rule.getMojo()); - rule.getMojo().doAction(); } @Test public void skipSendEmail() throws Exception { + Assume.assumeTrue(canContinue); - Assert.assertNotNull(rule.getMojo()); - rule.getMojo().execute(); + SendEmailMojo mojo = rule.getMojo(); + Assert.assertNotNull(mojo); + mojo.execute(); + } } diff --git a/helper-maven-plugin/src/test/java/org/nuiton/helper/plugin/TransformProjectVersionMojoTest.java b/helper-maven-plugin/src/test/java/org/nuiton/helper/plugin/TransformProjectVersionMojoTest.java index 2b9362e..85e6dfc 100644 --- a/helper-maven-plugin/src/test/java/org/nuiton/helper/plugin/TransformProjectVersionMojoTest.java +++ b/helper-maven-plugin/src/test/java/org/nuiton/helper/plugin/TransformProjectVersionMojoTest.java @@ -33,7 +33,7 @@ import java.io.File; import java.util.Properties; /** - * @author tchemit <chemit@codelutin.com> + * @author tchemit - chemit@codelutin.com * @since 2.0 */ public class TransformProjectVersionMojoTest { @@ -44,29 +44,14 @@ public class TransformProjectVersionMojoTest { protected boolean canContinue; @Rule - public MojoTestRule<TransformProjectVersionMojo> rule = new MojoTestRule<TransformProjectVersionMojo>(TransformProjectVersionMojoTest.class) { - - @Override - protected String getGoalName(String methodName) { - return "transform-project-version"; - } + public MojoTestRule<TransformProjectVersionMojo> rule = new MojoTestRule<TransformProjectVersionMojo>(TransformProjectVersionMojoTest.class, "transform-project-version") { @Override protected void setUpMojo(TransformProjectVersionMojo mojo, File pomFile) throws Exception { super.setUpMojo(mojo, pomFile); - try { - mojo.init(); - canContinue = true; - } catch (Exception e) { - - canContinue = false; - - if (log.isDebugEnabled()) { - log.debug("Could not init mojo ", e); - } - } + canContinue = initMojo(mojo); } }; @@ -75,57 +60,66 @@ public class TransformProjectVersionMojoTest { public void simple() throws Exception { Assert.assertTrue(canContinue); - Assert.assertNotNull(rule.getMojo()); - rule.getMojo().doAction(); + TransformProjectVersionMojo mojo = rule.getMojo(); + Assert.assertNotNull(mojo); + mojo.doAction(); assertNewVersion("newVersion", "1.0-rev-1"); + } @Test public void keepSnapshot() throws Exception { Assert.assertTrue(canContinue); - Assert.assertNotNull(rule.getMojo()); - rule.getMojo().doAction(); + TransformProjectVersionMojo mojo = rule.getMojo(); + Assert.assertNotNull(mojo); + mojo.doAction(); assertNewVersion("newVersion", "2.0-rev-2-SNAPSHOT"); + } @Test public void removeSnapshot() throws Exception { Assert.assertTrue(canContinue); - Assert.assertNotNull(rule.getMojo()); - rule.getMojo().doAction(); + TransformProjectVersionMojo mojo = rule.getMojo(); + Assert.assertNotNull(mojo); + mojo.doAction(); assertNewVersion("newVersion", "2.0-rev-2"); + } @Test public void badVersionPattern1() throws Exception { Assert.assertFalse(canContinue); + } @Test public void badVersionPattern2() throws Exception { Assert.assertFalse(canContinue); + } @Test public void badVersionPattern3() throws Exception { Assert.assertFalse(canContinue); + } - protected void assertNewVersion(String versionKey, - String expectedNewVersion) { + protected void assertNewVersion(String versionKey, String expectedNewVersion) { Properties properties = rule.getMojo().getProject().getProperties(); Object newVersion = properties.get(versionKey); Assert.assertNotNull(newVersion); Assert.assertEquals(expectedNewVersion, newVersion); + } } diff --git a/helper-maven-plugin/src/test/resources/org/nuiton/helper/plugin/checkAutoContainerPluginTest/central.xml b/helper-maven-plugin/src/test/resources/org/nuiton/helper/plugin/checkAutoContainerPluginTest/central.xml new file mode 100644 index 0000000..b243690 --- /dev/null +++ b/helper-maven-plugin/src/test/resources/org/nuiton/helper/plugin/checkAutoContainerPluginTest/central.xml @@ -0,0 +1,83 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + #%L + Helper Maven Plugin :: Mojos + %% + Copyright (C) 2009 - 2012 Codelutin, Tony Chemit + %% + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation, either version 3 of the + License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Lesser Public License for more details. + + You should have received a copy of the GNU General Lesser Public + License along with this program. If not, see + <http://www.gnu.org/licenses/lgpl-3.0.html>. + #L% + --> + +<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/maven-v4_0_0.xsd"> + + <modelVersion>4.0.0</modelVersion> + <groupId>org.nuiton.test</groupId> + <artifactId>check-auto-container-central</artifactId> + <version>0</version> + + <name>check-auto-container-central</name> + <description>check all dependencies are in central.</description> + + <url>http://www.foo.com</url> + + <properties> + + <pluginVersion>@pom.version@</pluginVersion> + + <!-- default encoding --> + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> + + </properties> + + <dependencies> + + <dependency> + <groupId>commons-lang</groupId> + <artifactId>commons-lang</artifactId> + <version>2.4</version> + </dependency> + + </dependencies> + <build> + + <plugins> + + <plugin> + <groupId>org.nuiton</groupId> + <artifactId>helper-maven-plugin</artifactId> + <configuration> + <addMavenCentral>true</addMavenCentral> + <failIfNotSafe>true</failIfNotSafe> + <verbose>true</verbose> + </configuration> + <executions> + <execution> + <id>check-central-safe</id> + <goals> + <goal>check-auto-container</goal> + </goals> + <phase>validate</phase> + </execution> + </executions> + </plugin> + + </plugins> + + </build> + +</project> -- To stop receiving notification emails like this one, please contact nuiton.org SCM administrator <admin+scm@nuiton.org>.
This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository maven-helper-plugin. See http://git.nuiton.org/maven-helper-plugin.git commit 20eb087a770db3410d4a7f7357f896b0363c3716 Author: Tony CHEMIT <chemit@codelutin.com> Date: Mon May 25 15:41:33 2015 +0200 make javadoc jdk8 compat (refs #3702) --- .../java/org/nuiton/io/MirroredFileUpdater.java | 2 +- .../io/PropertiesDateRemoveFilterStream.java | 3 +- .../main/java/org/nuiton/io/SortedProperties.java | 21 +++--- .../nuiton/plugin/AbstractAvailableDataMojo.java | 5 +- .../java/org/nuiton/plugin/AbstractPlugin.java | 49 +++++-------- .../java/org/nuiton/plugin/DependencyUtil.java | 19 ++--- .../src/main/java/org/nuiton/plugin/Plugin.java | 2 +- .../main/java/org/nuiton/plugin/PluginHelper.java | 28 +++----- .../java/org/nuiton/plugin/PluginIOContext.java | 4 +- .../java/org/nuiton/plugin/PluginWithEncoding.java | 3 +- .../nuiton/plugin/VelocityTemplateGenerator.java | 21 ++---- .../main/java/org/nuiton/plugin/MojoTestRule.java | 16 +++-- .../helper/io/mail/ProjectJavamailMailSender.java | 5 +- .../helper/plugin/CheckAutoContainerPlugin.java | 7 +- .../org/nuiton/helper/plugin/CollectFilesMojo.java | 80 ++++++---------------- .../helper/plugin/ExecuteRemoteCommandMojo.java | 35 ++++++---- .../org/nuiton/helper/plugin/SendEmailMojo.java | 2 +- .../helper/plugin/ShareServerSecretPlugin.java | 53 +++++++------- .../helper/plugin/TransformProjectVersionMojo.java | 8 +-- 19 files changed, 144 insertions(+), 219 deletions(-) diff --git a/helper-maven-plugin-api/src/main/java/org/nuiton/io/MirroredFileUpdater.java b/helper-maven-plugin-api/src/main/java/org/nuiton/io/MirroredFileUpdater.java index be3dad7..e149f56 100644 --- a/helper-maven-plugin-api/src/main/java/org/nuiton/io/MirroredFileUpdater.java +++ b/helper-maven-plugin-api/src/main/java/org/nuiton/io/MirroredFileUpdater.java @@ -35,7 +35,7 @@ import java.io.File; */ public class MirroredFileUpdater implements FileUpdater { - /** to use log facility, just put in your code: log.info(\"...\"); */ + /** Logger. */ static private final Log log = LogFactory.getLog(MirroredFileUpdater.class); /** source basedir */ diff --git a/helper-maven-plugin-api/src/main/java/org/nuiton/io/PropertiesDateRemoveFilterStream.java b/helper-maven-plugin-api/src/main/java/org/nuiton/io/PropertiesDateRemoveFilterStream.java index aebacf6..9c3f164 100644 --- a/helper-maven-plugin-api/src/main/java/org/nuiton/io/PropertiesDateRemoveFilterStream.java +++ b/helper-maven-plugin-api/src/main/java/org/nuiton/io/PropertiesDateRemoveFilterStream.java @@ -29,9 +29,8 @@ import java.io.OutputStream; /** * Un ecrivain qui supprime la premiere ligne rencontree dans le flux. * - * * <b>Note: </b> Attention, les performance d'utilisation de cet ecrivain - * est problèmatique, car sur de gros fichiers (>1000 entrees) les + * est problèmatique, car sur de gros fichiers (>1000 entrees) les * performances se degradent serieusement : pour 1200 entrees on arrive à * plus de 5 secondes, alors que sans on a 76 ms! ... * diff --git a/helper-maven-plugin-api/src/main/java/org/nuiton/io/SortedProperties.java b/helper-maven-plugin-api/src/main/java/org/nuiton/io/SortedProperties.java index 035f021..e5e4c87 100644 --- a/helper-maven-plugin-api/src/main/java/org/nuiton/io/SortedProperties.java +++ b/helper-maven-plugin-api/src/main/java/org/nuiton/io/SortedProperties.java @@ -45,7 +45,7 @@ import java.util.Vector; * Extend {@link Properties} to allow alphabetical order. Encoding could also * be defined but you must use this class only with Java 1.6. * - * @author ruchaud <ruchaud@codelutin.com> + * @author ruchaud - ruchaud@codelutin.com * @author tchemit - chemit@codelutin.com */ public class SortedProperties extends Properties { @@ -76,7 +76,7 @@ public class SortedProperties extends Properties { /** * A flag to write unicode using the a lower letter. - * <p/> + * * Example : {@code \u00e9} instead of {@code \u00E9}. */ final protected boolean unicodeLower; @@ -146,11 +146,11 @@ public class SortedProperties extends Properties { * and {@link #ENCODING_ASCII}. A specific {@link Reader} will * be used to read the file. * - * @param src File where Properties will be loaded + * @param src File where Properties will be loaded * @param encoding Encoding to use + * @return this instance * @throws IOException for any file errors * @since 1.3 - * @return this instance */ public SortedProperties load(File src, String encoding) throws IOException { Reader reader = new InputStreamReader(new FileInputStream(src), encoding); @@ -181,7 +181,7 @@ public class SortedProperties extends Properties { * be used to save the file. Otherwise the default Properties behavior * will escape unicode chars with <code>\u</code><i>xxxx</i>. * - * @param dst File to save Properties + * @param dst File to save Properties * @param encoding Encoding to use * @throws IOException for any file errors * @since 1.3 @@ -198,18 +198,18 @@ public class SortedProperties extends Properties { /** * If encoding is not the default Properties one, we will use a writer * to use this custom encoding. - * <p/> + * * We must call the right method depends on encoding, for a custom one * the {@link #store(Writer, String)} method is used otherwise the * default encoding 8859_1 must be used as superclass define it in * {@link #store(OutputStream, String)}. - * <p/> + * * Encoding {@link #ENCODING_DEFAULT}, * {@link #ENCODING_LATIN1} and {@link #ENCODING_ASCII} * are considered as default Properties one, so the old method will be use * escaping unicode chars like <code>\u</code><i>xxxx</i>. * - * @param stream OutputStream to save in + * @param stream OutputStream to save in * @param encoding Encoding to use * @throws IOException For any file errors */ @@ -296,7 +296,7 @@ public class SortedProperties extends Properties { } synchronized (this) { - for (Enumeration e = keys(); e.hasMoreElements();) { + for (Enumeration e = keys(); e.hasMoreElements(); ) { String key = (String) e.nextElement(); String val = (String) get(key); key = saveConvert(key, true, escUnicode); @@ -424,9 +424,10 @@ public class SortedProperties extends Properties { } /** - * Convert a nibble to a hex character + * Convert a nibble to a hex character. * * @param nibble the nibble to convert. + * @return the converted nibble */ protected char toHex(int nibble) { return hexDigit[(nibble & 0xF)]; diff --git a/helper-maven-plugin-api/src/main/java/org/nuiton/plugin/AbstractAvailableDataMojo.java b/helper-maven-plugin-api/src/main/java/org/nuiton/plugin/AbstractAvailableDataMojo.java index 9fb92c6..050e1ff 100644 --- a/helper-maven-plugin-api/src/main/java/org/nuiton/plugin/AbstractAvailableDataMojo.java +++ b/helper-maven-plugin-api/src/main/java/org/nuiton/plugin/AbstractAvailableDataMojo.java @@ -31,11 +31,10 @@ import java.util.Map; /** * Abstract mojo used to display {@link AvailableData} in a simple way. - * <p/> + * * Created: 10/05/11 * - * @author fdesbois <desbois@codelutin.com> - * $Id$ + * @author fdesbois - desbois@codelutin.com * @since 1.3 */ public abstract class AbstractAvailableDataMojo extends AbstractMojo { diff --git a/helper-maven-plugin-api/src/main/java/org/nuiton/plugin/AbstractPlugin.java b/helper-maven-plugin-api/src/main/java/org/nuiton/plugin/AbstractPlugin.java index 7ed5a9c..d4af6a7 100644 --- a/helper-maven-plugin-api/src/main/java/org/nuiton/plugin/AbstractPlugin.java +++ b/helper-maven-plugin-api/src/main/java/org/nuiton/plugin/AbstractPlugin.java @@ -154,8 +154,7 @@ public abstract class AbstractPlugin extends AbstractMojo implements Plugin { * and * {@link #rejectPackaging(Plugin.Packaging...)} * - * @return {@code true} if can execute the goal for the packaging of the - * project, {@code false} otherwise. + * @return {@code true} if can execute the goal for the packaging of the project, {@code false} otherwise. */ protected boolean checkPackaging() { // by default, accept every type of packaging @@ -216,8 +215,7 @@ public abstract class AbstractPlugin extends AbstractMojo implements Plugin { } /** - * Check if an execution was already done according to the given - * parameters based on a timestamp. + * Check if an execution was already done according to the given parameters based on a timestamp. * * @param runOnce the flag * @param onlyForRoot a flag to @@ -271,14 +269,13 @@ public abstract class AbstractPlugin extends AbstractMojo implements Plugin { } /** - * Check if an execution should be done or not according to the - * given parameters. + * Check if an execution should be done or not according to the given parameters. * * @param runOnce the flag * @param onlyForRoot a flag to * @param buildStartTime the build statrt time (if none means must do it) - * @param newStartTime the current build start time - * {@code true} if the goal should be invoked, {@code false} otherwise. + * @param newStartTime the current build start time {@code true} if the goal should be invoked, {@code false} otherwise. + * @return {@code true} if should be invoked, {@code false} otherwise. * @since 2.1 */ protected boolean needInvoke(boolean runOnce, @@ -369,8 +366,7 @@ public abstract class AbstractPlugin extends AbstractMojo implements Plugin { } /** - * Recupere le fichier donnée à partir de son chemin relatif sur le basedir - * du projet maven. + * Recupere le fichier donnée à partir de son chemin relatif sur le basedir du projet maven. * * @param paths les paths pour atteindre le fichier ou le répertoire * @return le fichier de la destination @@ -398,8 +394,7 @@ public abstract class AbstractPlugin extends AbstractMojo implements Plugin { } /** - * Write a {@code content} into the given destination file for the given - * {@code encoding}. + * Write a {@code content} into the given destination file for the given {@code encoding}. * * @param destFile location where to write the content * @param content content ot write in the file @@ -414,8 +409,7 @@ public abstract class AbstractPlugin extends AbstractMojo implements Plugin { * Test if a file exists and is newer than the pom file. * * @param f the file to test - * @return {@code true} if file exists and is newer than the pom file, - * {@code false} otherwise. + * @return {@code true} if file exists and is newer than the pom file, {@code false} otherwise. */ protected boolean isFileNewerThanPomFile(File f) { File pomFile = getProject().getFile(); @@ -429,8 +423,7 @@ public abstract class AbstractPlugin extends AbstractMojo implements Plugin { * @param excludes excludes * @param roots root directories to treate * @param files cache of file detected indexed by their root directory - * @param updater the updater used to detect changes (if none, will get all - * the files) + * @param updater the updater used to detect changes (if none, will get all the files) */ protected void getFilesToTreateForRoots( String[] includes, @@ -566,8 +559,7 @@ public abstract class AbstractPlugin extends AbstractMojo implements Plugin { } /** - * Add a given directory in maven project's compile source roots (if not - * already present). + * Add a given directory in maven project's compile source roots (if not already present). * * @param srcDir the location to include in compile source roots */ @@ -581,8 +573,7 @@ public abstract class AbstractPlugin extends AbstractMojo implements Plugin { } /** - * Remove a given directory in maven project's compile source roots (if - * present). + * Remove a given directory in maven project's compile source roots (if present). * * @param srcDir the location to remove from compile source roots */ @@ -596,8 +587,7 @@ public abstract class AbstractPlugin extends AbstractMojo implements Plugin { } /** - * Add a given directory in maven project's test compile source roots - * (if not already present). + * Add a given directory in maven project's test compile source roots (if not already present). * * @param srcDir the location to include in test compile source roots */ @@ -613,8 +603,7 @@ public abstract class AbstractPlugin extends AbstractMojo implements Plugin { } /** - * Remove a given directory in maven project's test compile source roots - * (if present). + * Remove a given directory in maven project's test compile source roots (if present). * * @param srcDir the location to remove from test compile source roots */ @@ -628,8 +617,7 @@ public abstract class AbstractPlugin extends AbstractMojo implements Plugin { } /** - * Add a new resource location to the maven project - * (in not already present). + * Add a new resource location to the maven project (in not already present). * * @param dir the new resource location to add * @param includes files to include @@ -643,8 +631,7 @@ public abstract class AbstractPlugin extends AbstractMojo implements Plugin { } /** - * Add a new test resource location to the maven project - * (in not already present). + * Add a new test resource location to the maven project (in not already present). * * @param dir the new resource location to add * @param includes files to include @@ -715,8 +702,7 @@ public abstract class AbstractPlugin extends AbstractMojo implements Plugin { } /** - * Backups the given file using the {@link #getBackupFile(File)} as - * destination file. + * Backups the given file using the {@link #getBackupFile(File)} as destination file. * * @param f the file to backup * @throws IOException if any pb while copying the file @@ -879,8 +865,7 @@ public abstract class AbstractPlugin extends AbstractMojo implements Plugin { } /** - * Check that the given resource exists in a simple fs file or in the - * classPath. + * Check that the given resource exists in a simple fs file or in the classPath. * * @param f the required resource file. * @throws IOException for any error while looking up for the resources content. diff --git a/helper-maven-plugin-api/src/main/java/org/nuiton/plugin/DependencyUtil.java b/helper-maven-plugin-api/src/main/java/org/nuiton/plugin/DependencyUtil.java index 7f5c087..b221647 100644 --- a/helper-maven-plugin-api/src/main/java/org/nuiton/plugin/DependencyUtil.java +++ b/helper-maven-plugin-api/src/main/java/org/nuiton/plugin/DependencyUtil.java @@ -37,12 +37,10 @@ import java.util.*; */ public class DependencyUtil { - /** to use log facility, just put in your code: log.info(\"...\"); */ + /** Logger. */ private static final Log log = LogFactory.getLog(DependencyUtil.class); - public static void sortArtifacts(DependencyNode rootNode, - List<Artifact> artifacts, - boolean verbose) { + public static void sortArtifacts(DependencyNode rootNode, List<Artifact> artifacts, boolean verbose) { if (artifacts.size() < 2) { return; @@ -68,11 +66,7 @@ public class DependencyUtil { // premiere passe pour recuperer l'ensemble des dependances for (ArtifactDependencyEntry entry : dico.values()) { - List<String> dependencies = getDependencies(rootNode, - entry, - universe, - verbose - ); + List<String> dependencies = getDependencies(rootNode, entry, universe, verbose); entry.depIds = dependencies; } @@ -99,8 +93,7 @@ public class DependencyUtil { if (levelFixed.isEmpty()) { // aucune modification, c'est un cycle! - throw new IllegalStateException( - "cycle detecte ! entre les artifacts " + universe); + throw new IllegalStateException("cycle detecte ! entre les artifacts " + universe); } // on met a jour les listes @@ -244,9 +237,7 @@ public class DependencyUtil { } } - protected static DependencyNode getNode(DependencyNode rootNode, - String requiredKey, - boolean verbose) { + protected static DependencyNode getNode(DependencyNode rootNode, String requiredKey, boolean verbose) { for (Iterator<?> itr = rootNode.preorderIterator(); itr.hasNext();) { DependencyNode d = (DependencyNode) itr.next(); diff --git a/helper-maven-plugin-api/src/main/java/org/nuiton/plugin/Plugin.java b/helper-maven-plugin-api/src/main/java/org/nuiton/plugin/Plugin.java index 7ab813d..99c91cd 100644 --- a/helper-maven-plugin-api/src/main/java/org/nuiton/plugin/Plugin.java +++ b/helper-maven-plugin-api/src/main/java/org/nuiton/plugin/Plugin.java @@ -27,7 +27,7 @@ import org.apache.maven.project.MavenProject; /** * A common contract to be implements by our mojo and reports. - * <p/> + * * Just expose a {@link #isVerbose()} flag and the maven project {@link #getProject()}. * * @author tchemit - chemit@codelutin.com diff --git a/helper-maven-plugin-api/src/main/java/org/nuiton/plugin/PluginHelper.java b/helper-maven-plugin-api/src/main/java/org/nuiton/plugin/PluginHelper.java index 3e29aad..a638e48 100644 --- a/helper-maven-plugin-api/src/main/java/org/nuiton/plugin/PluginHelper.java +++ b/helper-maven-plugin-api/src/main/java/org/nuiton/plugin/PluginHelper.java @@ -76,11 +76,11 @@ public class PluginHelper { /** * Permet de convertir une liste non typee, en une liste typee. - * <p/> + * * La liste en entree en juste bien castee. - * <p/> + * * On effectue une verification sur le typage des elements de la liste. - * <p/> + * * Note : <b>Aucune liste n'est creee, ni recopiee</b> * * @param <O> le type des objets de la liste @@ -202,8 +202,7 @@ public class PluginHelper { } /** - * Obtenir les clefs de toutes les valeurs nulles ou vide a partir d'un - * dictionnaire donne. + * Obtenir les clefs de toutes les valeurs nulles ou vide a partir d'un dictionnaire donne. * * @param map le dictionner a parcourir * @return la liste des clefs dont la valeur est nulle ou vide @@ -299,8 +298,7 @@ public class PluginHelper { * Cretae the directory (and his parents) if necessary. * * @param dir the directory to create if not exisiting - * @return {@code true} if directory was created, {@code false} if was no - * need to create it + * @return {@code true} if directory was created, {@code false} if was no need to create it * @throws IOException if could not create directory * @since 1.1.1 */ @@ -389,8 +387,7 @@ public class PluginHelper { } /** - * Permet de lire un fichier et de retourner sont contenu sous forme d'une - * chaine de carateres + * Permet de lire un fichier et de retourner sont contenu sous forme d'une chaine de carateres * * @param file le fichier a lire * @param encoding encoding to read file @@ -410,8 +407,7 @@ public class PluginHelper { } /** - * Permet de lire un fichier et de retourner sont contenu sous forme d'une - * chaine de carateres + * Permet de lire un fichier et de retourner sont contenu sous forme d'une chaine de carateres * * @param reader la source alire * @return the content of the file @@ -656,12 +652,10 @@ public class PluginHelper { /** * Method to be invoked in init phase to check sanity of {@link PluginWithEncoding#getEncoding()}. - * <p/> - * If no encoding was filled, then use the default for system - * (via {@code file.encoding} environement property). - * <p/> - * <b>Note:</b> If mojo is not implementing {@link PluginWithEncoding}, - * nothing is done. + * + * If no encoding was filled, then use the default for system (via {@code file.encoding} environement property). + * + * <b>Note:</b> If mojo is not implementing {@link PluginWithEncoding}, nothing is done. * * @param mojo the mojo to check. * @since 1.2.6 diff --git a/helper-maven-plugin-api/src/main/java/org/nuiton/plugin/PluginIOContext.java b/helper-maven-plugin-api/src/main/java/org/nuiton/plugin/PluginIOContext.java index b11d108..f5d9213 100644 --- a/helper-maven-plugin-api/src/main/java/org/nuiton/plugin/PluginIOContext.java +++ b/helper-maven-plugin-api/src/main/java/org/nuiton/plugin/PluginIOContext.java @@ -26,9 +26,9 @@ import java.io.File; /** * Une classe pour définir les entrées-sortie d'un plugin. - * <p/> + * * En entrée, on peut avoir un ou plusieurs répertoires ({@link #inputs}. - * <p/> + * * En sortie, on ne peut avoir qu'un seul répertoire ({@link #output}. * * @author tchemit - chemit@codelutin.com diff --git a/helper-maven-plugin-api/src/main/java/org/nuiton/plugin/PluginWithEncoding.java b/helper-maven-plugin-api/src/main/java/org/nuiton/plugin/PluginWithEncoding.java index cf529b7..c057558 100644 --- a/helper-maven-plugin-api/src/main/java/org/nuiton/plugin/PluginWithEncoding.java +++ b/helper-maven-plugin-api/src/main/java/org/nuiton/plugin/PluginWithEncoding.java @@ -24,7 +24,7 @@ package org.nuiton.plugin; /** * A common contract to be implements by our mojo and reports which needs encoding. - * <p/> + * * Just expose a getter-setter {@link #getEncoding()} and {@link #setEncoding(String)}. * * @author tchemit - chemit@codelutin.com @@ -32,7 +32,6 @@ package org.nuiton.plugin; */ public interface PluginWithEncoding extends Plugin { - /** * Gets the encoding to be used to read and write io resources. * diff --git a/helper-maven-plugin-api/src/main/java/org/nuiton/plugin/VelocityTemplateGenerator.java b/helper-maven-plugin-api/src/main/java/org/nuiton/plugin/VelocityTemplateGenerator.java index aaa5f8f..1486f08 100644 --- a/helper-maven-plugin-api/src/main/java/org/nuiton/plugin/VelocityTemplateGenerator.java +++ b/helper-maven-plugin-api/src/main/java/org/nuiton/plugin/VelocityTemplateGenerator.java @@ -37,7 +37,7 @@ import java.util.Properties; /** * Generator of template base on velocity. - * <p/> + * * TODO TC-20091011 should use plexus velocity component * * @author tchemit - chemit@codelutin.com @@ -51,8 +51,7 @@ public class VelocityTemplateGenerator { protected Template velocityTemplate; - public VelocityTemplateGenerator(MavenProject mavenProject, - URL template) throws URISyntaxException { + public VelocityTemplateGenerator(MavenProject mavenProject, URL template) throws URISyntaxException { if (mavenProject == null) { throw new IllegalArgumentException("mavenProject must not be null"); @@ -90,8 +89,7 @@ public class VelocityTemplateGenerator { int i = url.indexOf("!"); templateName = url.substring(i + 2); - props.setProperty("jar.resource.loader.path", - url.substring(0, i + 2)); + props.setProperty("jar.resource.loader.path", url.substring(0, i + 2)); } else { @@ -105,8 +103,7 @@ public class VelocityTemplateGenerator { engine = new VelocityEngine(); engine.init(props); } catch (Exception e) { - IllegalArgumentException iae = new IllegalArgumentException( - "Could not initialise Velocity"); + IllegalArgumentException iae = new IllegalArgumentException("Could not initialise Velocity"); iae.initCause(e); throw iae; } @@ -115,9 +112,7 @@ public class VelocityTemplateGenerator { velocityTemplate = engine.getTemplate(templateName); } catch (Exception e) { IllegalArgumentException iae = - new IllegalArgumentException( - "Could not load the template file from '" + - template + "'"); + new IllegalArgumentException("Could not load the template file from '" + template + "'"); iae.initCause(e); throw iae; } @@ -171,15 +166,13 @@ public class VelocityTemplateGenerator { writer.flush(); } catch (Exception e) { throw new Exception( - "Could not generate the template " + - velocityTemplate.getName() + ": " + e.getMessage(), e); + "Could not generate the template " + velocityTemplate.getName() + ": " + e.getMessage(), e); } finally { writer.close(); } } - protected void addPropertiesToContext(Properties properties, - VelocityContext context) { + protected void addPropertiesToContext(Properties properties, VelocityContext context) { for (Object o : properties.keySet()) { String key = (String) o; diff --git a/helper-maven-plugin-test-api/src/main/java/org/nuiton/plugin/MojoTestRule.java b/helper-maven-plugin-test-api/src/main/java/org/nuiton/plugin/MojoTestRule.java index a43763a..f232039 100644 --- a/helper-maven-plugin-test-api/src/main/java/org/nuiton/plugin/MojoTestRule.java +++ b/helper-maven-plugin-test-api/src/main/java/org/nuiton/plugin/MojoTestRule.java @@ -18,13 +18,15 @@ import java.beans.Introspector; import java.io.File; /** - * To offer inside each test method (annotated by a {@link Test}) the - * following properties : - * <p/> - * <ul> <li>{@link #testDirectory} : location where to find resources for the - * test</li> <li>{@link #pomFile} : location of the pom file to use to build - * the mojo</li> <li>{@link #mojo} : the instanciated and initialized - * mojo</li> </ul> + * TODO Review this documentation. + * + * To offer inside each test method (annotated by a {@link Test}) the following properties : + * + * <ul> + * <li>{@link #testDirectory} : location where to find resources for the test</li> + * <li>{@link #pomFile} : location of the pom file to use to build the mojo</li> + * <li>{@link #mojo} : the instanciated and initialized mojo</li> + * </ul> */ public class MojoTestRule<P extends AbstractPlugin> extends MojoRule { diff --git a/helper-maven-plugin/src/main/java/org/nuiton/helper/io/mail/ProjectJavamailMailSender.java b/helper-maven-plugin/src/main/java/org/nuiton/helper/io/mail/ProjectJavamailMailSender.java index 00a289d..23a0962 100644 --- a/helper-maven-plugin/src/main/java/org/nuiton/helper/io/mail/ProjectJavamailMailSender.java +++ b/helper-maven-plugin/src/main/java/org/nuiton/helper/io/mail/ProjectJavamailMailSender.java @@ -44,9 +44,8 @@ import java.util.Properties; /** * Helper class for sending email. - * <p/> - * Note : this code was stolen in {@code maven-changes-plugin}, should thanks - * them... + * + * Note : this code was stolen in {@code maven-changes-plugin}, should thanks them... * * @author tchemit - chemit@codelutin.com * @since 1.0.3 diff --git a/helper-maven-plugin/src/main/java/org/nuiton/helper/plugin/CheckAutoContainerPlugin.java b/helper-maven-plugin/src/main/java/org/nuiton/helper/plugin/CheckAutoContainerPlugin.java index 7c3fb76..49b8896 100644 --- a/helper-maven-plugin/src/main/java/org/nuiton/helper/plugin/CheckAutoContainerPlugin.java +++ b/helper-maven-plugin/src/main/java/org/nuiton/helper/plugin/CheckAutoContainerPlugin.java @@ -67,7 +67,7 @@ public class CheckAutoContainerPlugin extends AbstractPlugin { /** * Map of repositories to use. - * <p/> + * * Keys are repository id and Values are repository url. * * @since 1.2.5 @@ -102,9 +102,8 @@ public class CheckAutoContainerPlugin extends AbstractPlugin { /** * A flag to execute only once the mojo. - * <p/> - * <b>Note:</b> By default, value is {@code true} since it is not necessary - * to check twice for a same artifact. + * + * <b>Note:</b> By default, value is {@code true} since it is not necessary to check twice for a same artifact. * * @since 1.2.6 */ diff --git a/helper-maven-plugin/src/main/java/org/nuiton/helper/plugin/CollectFilesMojo.java b/helper-maven-plugin/src/main/java/org/nuiton/helper/plugin/CollectFilesMojo.java index 8d65dcd..35442fb 100644 --- a/helper-maven-plugin/src/main/java/org/nuiton/helper/plugin/CollectFilesMojo.java +++ b/helper-maven-plugin/src/main/java/org/nuiton/helper/plugin/CollectFilesMojo.java @@ -101,7 +101,7 @@ public class CollectFilesMojo extends AbstractPlugin implements PluginWithEncodi /** * User extra files to collect. - * <p/> + * * Multi values can be used, separated by comma. * * @since 1.0.0 @@ -111,7 +111,7 @@ public class CollectFilesMojo extends AbstractPlugin implements PluginWithEncodi /** * File name pattern of selected files to publish. - * <p/> + * * If no Set - no include filter * * @since 1.0.0 @@ -121,7 +121,7 @@ public class CollectFilesMojo extends AbstractPlugin implements PluginWithEncodi /** * File name pattern of selected files to publish. - * <p/> + * * If no Set - no exclude filter * * @since 1.0.0 @@ -131,7 +131,7 @@ public class CollectFilesMojo extends AbstractPlugin implements PluginWithEncodi /** * Directory where to store collected files. - * <p/> + * * <b>Note :</b> In a multi-module context, will always use the value of * the property of the root module, because we need to push collected files * to only one place. @@ -143,7 +143,7 @@ public class CollectFilesMojo extends AbstractPlugin implements PluginWithEncodi /** * File with all files collected (one file by line in absolute path). - * <p/> + * * <b>Note :</b> If not Set, will not generate the description file. * * @since 1.0.0 @@ -230,7 +230,6 @@ public class CollectFilesMojo extends AbstractPlugin implements PluginWithEncodi } if (files.isEmpty()) { - getLog().warn("Skipping goal (No file to collect)."); return false; } @@ -258,8 +257,7 @@ public class CollectFilesMojo extends AbstractPlugin implements PluginWithEncodi File base = new File(rootProject.getBasedir(), outputDirectory); - File output = new File(base, project.getGroupId() + "--" + - project.getArtifactId()); + File output = new File(base, project.getGroupId() + "--" + project.getArtifactId()); if (verbose) { getLog().info("Ouput dir : " + output); @@ -306,8 +304,7 @@ public class CollectFilesMojo extends AbstractPlugin implements PluginWithEncodi } if (!withDescriptionFile && !copyFiles) { - throw new MojoExecutionException( - "must use at least one of the parameters 'copyFiles' or 'descriptionFile'"); + throw new MojoExecutionException("must use at least one of the parameters 'copyFiles' or 'descriptionFile'"); } String basedir = rootProject.getBasedir().getAbsolutePath(); @@ -362,7 +359,7 @@ public class CollectFilesMojo extends AbstractPlugin implements PluginWithEncodi /** * Save the list of files in the given output file. - * <p/> + * * Each line is the absolute path of each files of the list * * @param output the file when to write @@ -379,10 +376,8 @@ public class CollectFilesMojo extends AbstractPlugin implements PluginWithEncodi protected List<File> getFiles() { - Pattern includePattern = StringUtils.isBlank(includes) ? null : - Pattern.compile(includes.trim()); - Pattern excludePattern = StringUtils.isBlank(excludes) ? null : - Pattern.compile(excludes.trim()); + Pattern includePattern = StringUtils.isBlank(includes) ? null : Pattern.compile(includes.trim()); + Pattern excludePattern = StringUtils.isBlank(excludes) ? null : Pattern.compile(excludes.trim()); List<File> result = new ArrayList<>(); @@ -391,20 +386,10 @@ public class CollectFilesMojo extends AbstractPlugin implements PluginWithEncodi if (includeAttached) { if ("pom".equals(project.getPackaging())) { - addFile(project.getFile(), - "adding artifact file : ", - result, - includePattern, - excludePattern - ); + addFile(project.getFile(), "adding artifact file : ", result, includePattern, excludePattern); } else { - addFile(artifact.getFile(), - "adding artifact file : ", - result, - includePattern, - excludePattern - ); + addFile(artifact.getFile(), "adding artifact file : ", result, includePattern, excludePattern); } } File file; @@ -422,12 +407,7 @@ public class CollectFilesMojo extends AbstractPlugin implements PluginWithEncodi file = new File(basedir, path.trim()); } - addFile(file, - "adding user file : ", - result, - includePattern, - excludePattern - ); + addFile(file, "adding user file : ", result, includePattern, excludePattern); } } @@ -442,12 +422,7 @@ public class CollectFilesMojo extends AbstractPlugin implements PluginWithEncodi for (Object o : attachedArtifacts) { file = ((Artifact) o).getFile(); - addFile(file, - "adding attached artifact file : ", - result, - includePattern, - excludePattern - ); + addFile(file, "adding attached artifact file : ", result, includePattern, excludePattern); } } @@ -461,20 +436,10 @@ public class CollectFilesMojo extends AbstractPlugin implements PluginWithEncodi //This is a big hack and we should sheck this name does not // changes when bumping maven version (anyway, it is not risky // since this class should never change ?) - if ("SiteDescriptorArtifactMetadata".equals( - o.getClass().getSimpleName())) { - String path = - localRepository.pathOfLocalRepositoryMetadata( - o, deploymentRepository); - File destination = new File( - localRepository.getBasedir(), - path); - addFile(destination, - "adding site descriptor file : ", - result, - includePattern, - excludePattern - ); + if ("SiteDescriptorArtifactMetadata".equals(o.getClass().getSimpleName())) { + String path = localRepository.pathOfLocalRepositoryMetadata(o, deploymentRepository); + File destination = new File(localRepository.getBasedir(), path); + addFile(destination, "adding site descriptor file : ", result, includePattern, excludePattern); } } } @@ -482,11 +447,7 @@ public class CollectFilesMojo extends AbstractPlugin implements PluginWithEncodi return result; } - protected void addFile(File f, - String msg, - List<File> files, - Pattern includePattern, - Pattern excludePattern) { + protected void addFile(File f, String msg, List<File> files, Pattern includePattern, Pattern excludePattern) { if (f == null) { return; } @@ -507,8 +468,7 @@ public class CollectFilesMojo extends AbstractPlugin implements PluginWithEncodi if (!includePattern.matcher(f.getName()).matches()) { // skip this file if (verbose) { - getLog().info( - "skip " + f + " : not in includes " + includes); + getLog().info("skip " + f + " : not in includes " + includes); } return; } diff --git a/helper-maven-plugin/src/main/java/org/nuiton/helper/plugin/ExecuteRemoteCommandMojo.java b/helper-maven-plugin/src/main/java/org/nuiton/helper/plugin/ExecuteRemoteCommandMojo.java index 8c7e265..091c282 100644 --- a/helper-maven-plugin/src/main/java/org/nuiton/helper/plugin/ExecuteRemoteCommandMojo.java +++ b/helper-maven-plugin/src/main/java/org/nuiton/helper/plugin/ExecuteRemoteCommandMojo.java @@ -50,20 +50,26 @@ import org.nuiton.plugin.AbstractPlugin; * @since 1.3.1 */ @Mojo(name = "execute-remote-command", - defaultPhase = LifecyclePhase.VALIDATE, - requiresOnline = true, - requiresProject = true) + defaultPhase = LifecyclePhase.VALIDATE, + requiresOnline = true, + requiresProject = true) public class ExecuteRemoteCommandMojo extends AbstractPlugin { - /** A flag to activate verbose mode. */ + /** + * A flag to activate verbose mode. + */ @Parameter(property = "helper.verbose", defaultValue = "${maven.verbose}") protected boolean verbose; - /** Project. */ - @Parameter( defaultValue = "${project}", required = true, readonly = true ) + /** + * Project. + */ + @Parameter(defaultValue = "${project}", required = true, readonly = true) protected MavenProject project; - /** Active proxy from settings (if any). */ + /** + * Active proxy from settings (if any). + */ @Parameter(defaultValue = "${settings.activeProxy}", required = true, readonly = true) protected Proxy proxy; @@ -72,12 +78,12 @@ public class ExecuteRemoteCommandMojo extends AbstractPlugin { * * @since 1.1.0 */ - @Parameter( defaultValue = "${settings}", required = true, readonly = true ) + @Parameter(defaultValue = "${settings}", required = true, readonly = true) protected Settings settings; /** * Id of the server to use to obtain user login. - * <p/> + * * Must be found in your settings.xml. */ @Parameter(property = "helper.repositoryId", required = true) @@ -91,11 +97,15 @@ public class ExecuteRemoteCommandMojo extends AbstractPlugin { @Parameter(property = "helper.repositoryUrl", required = true) protected String repositoryUrl; - /** Command to execute on remote server. */ + /** + * Command to execute on remote server. + */ @Parameter(property = "helper.command", required = true) protected String command; - /** Wagon manager component. */ + /** + * Wagon manager component. + */ @Component protected WagonManager wagonManager; @@ -185,8 +195,7 @@ public class ExecuteRemoteCommandMojo extends AbstractPlugin { } // FIXME when upgrading to maven 3.x : this must be changed. - AuthenticationInfo auth = - wagonManager.getAuthenticationInfo(repository.getId()); + AuthenticationInfo auth = wagonManager.getAuthenticationInfo(repository.getId()); ProxyInfo proxyInfo = getProxyInfo(); if (proxyInfo != null) { diff --git a/helper-maven-plugin/src/main/java/org/nuiton/helper/plugin/SendEmailMojo.java b/helper-maven-plugin/src/main/java/org/nuiton/helper/plugin/SendEmailMojo.java index 40a51cc..5c547e6 100644 --- a/helper-maven-plugin/src/main/java/org/nuiton/helper/plugin/SendEmailMojo.java +++ b/helper-maven-plugin/src/main/java/org/nuiton/helper/plugin/SendEmailMojo.java @@ -124,7 +124,7 @@ public class SendEmailMojo extends AbstractPlugin implements PluginWithEncoding /** * The id of the developer sending the announcement mail. Only used if - * the <tt>mailSender</tt> attribute is not set. In this case, this should + * the <i>mailSender</i> attribute is not set. In this case, this should * match the id of one of the developers in the pom. If a matching * developer is not found, then the first developer in the pom will be * used. diff --git a/helper-maven-plugin/src/main/java/org/nuiton/helper/plugin/ShareServerSecretPlugin.java b/helper-maven-plugin/src/main/java/org/nuiton/helper/plugin/ShareServerSecretPlugin.java index b2ef259..9c28a85 100644 --- a/helper-maven-plugin/src/main/java/org/nuiton/helper/plugin/ShareServerSecretPlugin.java +++ b/helper-maven-plugin/src/main/java/org/nuiton/helper/plugin/ShareServerSecretPlugin.java @@ -41,7 +41,7 @@ import java.util.Properties; /** * Obtain a server authentication and share it in the maven * project properties. - * <p/> + * * To select data to export from the server with the given {@code serverId}, * fill the properties : * <pre> @@ -55,8 +55,8 @@ import java.util.Properties; * @since 1.1.0 */ @Mojo(name = "share-server-secret", - defaultPhase = LifecyclePhase.INITIALIZE, - requiresProject = true) + defaultPhase = LifecyclePhase.INITIALIZE, + requiresProject = true) public class ShareServerSecretPlugin extends AbstractPlugin { /** @@ -64,7 +64,7 @@ public class ShareServerSecretPlugin extends AbstractPlugin { * * @since 1.1.0 */ - @Parameter( defaultValue = "${project}", required = true, readonly = true ) + @Parameter(defaultValue = "${project}", required = true, readonly = true) protected MavenProject project; /** @@ -72,13 +72,12 @@ public class ShareServerSecretPlugin extends AbstractPlugin { * * @since 1.1.0 */ - @Parameter( defaultValue = "${settings}", required = true, readonly = true ) + @Parameter(defaultValue = "${settings}", required = true, readonly = true) protected Settings settings; /** * Server id to use for authentication (must be defined in your setting - * and use the maven >= 2.1.0 password encryption mecanism). - * <p/> + * and use the maven >= 2.1.0 password encryption mecanism). * * @since 1.1.0 */ @@ -87,7 +86,7 @@ public class ShareServerSecretPlugin extends AbstractPlugin { /** * The name of the property where to export the username of the server. - * <p/> + * * <b>Note:</b> If not set - then no export of the username of the server. * * @since 1.1.0 @@ -97,11 +96,10 @@ public class ShareServerSecretPlugin extends AbstractPlugin { /** * The name of the property where to export the password of the server. - * <p/> + * * <b>Note:</b> If not set - then no export of the password of the server. - * <p/> - * <b>Note:</b> If the password is crypted (since maven 2.1.0) then - * decrypt it. + * + * <b>Note:</b> If the password is crypted (since maven 2.1.0) then decrypt it. * * @since 1.1.0 */ @@ -110,11 +108,10 @@ public class ShareServerSecretPlugin extends AbstractPlugin { /** * The name of the property where to export the passphrase of the server. - * <p/> + * * <b>Note:</b> If not set - then no export of the passphrase of the server. - * <p/> - * <b>Note:</b> If the passphrase is crypted (since maven 2.1.0) then - * decrypt it. + * + * <b>Note:</b> If the passphrase is crypted (since maven 2.1.0) then decrypt it. * * @since 1.1.0 */ @@ -123,7 +120,7 @@ public class ShareServerSecretPlugin extends AbstractPlugin { /** * The name of the property where to export the private key of the server. - * <p/> + * * <b>Note:</b> If not set - then no export of the private key of the server. * * @since 1.1.0 @@ -141,9 +138,8 @@ public class ShareServerSecretPlugin extends AbstractPlugin { /** * A flag to execute only once the mojo. - * <p/> - * <b>Note:</b> By default, value is {@code true} since it is not necessary - * to inject twice secrets in session. + * + * <b>Note:</b> By default, value is {@code true} since it is not necessary to inject twice secrets in session. * * @since 1.1.0 */ @@ -183,10 +179,14 @@ public class ShareServerSecretPlugin extends AbstractPlugin { @Component(hint = "maven-helper-plugin") protected SecDispatcher sec; - /** the server to use to obtain secrets */ + /** + * The server to use to obtain secrets. + */ private Server server; - /** server secrets to expose */ + /** + * Server secrets to expose. + */ private Map<Property, String> propertiesToTreate; public enum Property { @@ -254,8 +254,7 @@ public class ShareServerSecretPlugin extends AbstractPlugin { if (server == null) { throw new MojoExecutionException( - "Could not find server with id '" + serverId + - "', check your settings.xml file."); + "Could not find server with id '" + serverId + "', check your settings.xml file."); } } @@ -310,14 +309,12 @@ public class ShareServerSecretPlugin extends AbstractPlugin { } else { throw new MojoExecutionException( "Null values found for server [" + - serverId + "] " + key.name() + - ", use skipNullValue to authrize it."); + serverId + "] " + key.name() + ", use skipNullValue to authrize it."); } } else { - getLog().info("Exporting server [" + serverId + "] " + key.name() + - " in ${" + propertyTargetName + "}"); + getLog().info("Exporting server [" + serverId + "] " + key.name() + " in ${" + propertyTargetName + "}"); properties.setProperty(propertyTargetName, propertyValue); } diff --git a/helper-maven-plugin/src/main/java/org/nuiton/helper/plugin/TransformProjectVersionMojo.java b/helper-maven-plugin/src/main/java/org/nuiton/helper/plugin/TransformProjectVersionMojo.java index 0d170d6..bd93448 100644 --- a/helper-maven-plugin/src/main/java/org/nuiton/helper/plugin/TransformProjectVersionMojo.java +++ b/helper-maven-plugin/src/main/java/org/nuiton/helper/plugin/TransformProjectVersionMojo.java @@ -64,18 +64,16 @@ public class TransformProjectVersionMojo extends AbstractPlugin { /** * Pattern of the new version. - * <p/> + * * Use {@code #V} for project version (without snapshot suffix) and * {@code #R} for the given scm revision and #S to add snapshot suffix - * <p/> + * * Example: - * <p/> * <pre> * #V-rev-#V -> 1.0-rev-1 (version=1.0 and revision=1) * #V-rev-#V#S -> 1.0-rev-1-SNAPSHOT (version=1.0 and revision=1) * #V-rev-#V#S -> 1.0-rev-1-SNAPSHOT (version=1.0-SNAPSHOT and revision=1) * </pre> - * <p/> * Note that the #S can only be putted at the end of the pattern * * @since 2.0 @@ -101,7 +99,7 @@ public class TransformProjectVersionMojo extends AbstractPlugin { /** * A flag to execute only once the mojo. - * <p/> + * * <b>Note:</b> By default, value is {@code true} since it is not necessary * to inject twice secrets in session. * -- To stop receiving notification emails like this one, please contact nuiton.org SCM administrator <admin+scm@nuiton.org>.
This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository maven-helper-plugin. See http://git.nuiton.org/maven-helper-plugin.git commit 3e93d173dffec25358f52a802efd0133b82a80db Merge: 5b75d40 20eb087 Author: Tony CHEMIT <chemit@codelutin.com> Date: Mon May 25 15:48:53 2015 +0200 fixes #3702: Use maven 3 API fixes #3703: Split mojo Api in two modules (one with Api and one with test Api) Merge branch 'feature/3702' into develop helper-maven-plugin-api/pom.xml | 112 +----- .../src/main/java/org/nuiton/io/FileUpdater.java | 6 +- .../main/java/org/nuiton/io/FileUpdaterHelper.java | 6 +- .../java/org/nuiton/io/MirroredFileUpdater.java | 4 +- .../io/PropertiesDateRemoveFilterStream.java | 3 +- .../main/java/org/nuiton/io/SortedProperties.java | 25 +- .../nuiton/plugin/AbstractAvailableDataMojo.java | 5 +- .../java/org/nuiton/plugin/AbstractPlugin.java | 183 ++++------ .../java/org/nuiton/plugin/DependencyUtil.java | 33 +- .../src/main/java/org/nuiton/plugin/Plugin.java | 4 +- .../main/java/org/nuiton/plugin/PluginHelper.java | 40 +-- .../java/org/nuiton/plugin/PluginIOContext.java | 6 +- .../java/org/nuiton/plugin/PluginWithEncoding.java | 5 +- .../nuiton/plugin/VelocityTemplateGenerator.java | 23 +- .../java/org/nuiton/plugin/AbstractMojoTest.java | 387 --------------------- .../java/org/nuiton/plugin/PluginHelperTest.java | 2 +- .../test/java/org/nuiton/plugin/TestHelper.java | 121 ------- .../test/resources/org/nuiton/io/JaxxDummy.java | 2 +- helper-maven-plugin-test-api/LICENSE.txt | 165 +++++++++ helper-maven-plugin-test-api/README.txt | 0 helper-maven-plugin-test-api/changelog.txt | 0 .../pom.xml | 130 ++----- .../src/license/THIRD-PARTY.properties | 32 ++ .../main/java/org/nuiton/plugin/MojoTestRule.java | 243 +++++++++++++ .../main/java/org/nuiton/plugin/TestHelper.java | 117 +++++++ .../src/site/apt/index.apt | 17 + .../src/site/apt/mojo-testFramework.apt | 22 +- helper-maven-plugin-test-api/src/site/site.xml | 31 ++ helper-maven-plugin/pom.xml | 27 +- .../java/org/nuiton/helper/io/mail/MailSender.java | 5 +- .../helper/io/mail/ProjectJavamailMailSender.java | 7 +- .../helper/plugin/CheckAutoContainerPlugin.java | 249 +++++++------ .../org/nuiton/helper/plugin/CollectFilesMojo.java | 98 ++---- .../helper/plugin/ExecuteRemoteCommandMojo.java | 45 ++- .../org/nuiton/helper/plugin/SendEmailMojo.java | 30 +- .../helper/plugin/ShareServerSecretPlugin.java | 57 ++- .../helper/plugin/TransformProjectVersionMojo.java | 38 +- .../plugin/CheckAutoContainerPluginTest.java | 42 +++ .../nuiton/helper/plugin/SendEmailMojoTest.java | 76 ++-- .../plugin/TransformProjectVersionMojoTest.java | 60 ++-- .../src/test/resources/log4j.properties | 32 ++ .../checkAutoContainerPluginTest/central.xml | 83 +++++ pom.xml | 48 ++- 43 files changed, 1284 insertions(+), 1337 deletions(-) -- To stop receiving notification emails like this one, please contact nuiton.org SCM administrator <admin+scm@nuiton.org>.
participants (1)
-
nuiton.org scm