Author: tchemit Date: 2010-01-21 13:14:14 +0100 (Thu, 21 Jan 2010) New Revision: 1675 Modified: trunk/pom.xml trunk/src/main/java/org/nuiton/license/plugin/AddThirdPartyFilePlugin.java trunk/src/main/java/org/nuiton/license/plugin/GeneratorListPlugin.java trunk/src/main/java/org/nuiton/license/plugin/UpdateHeaderPlugin.java trunk/src/main/java/org/nuiton/license/plugin/header/generator/HeaderGenerator.java trunk/src/main/java/org/nuiton/license/plugin/header/generator/PropertiesLicenseHeaderGeneratorImpl.java Log: - use pluginManagment from mavenpom - clean code Modified: trunk/pom.xml =================================================================== --- trunk/pom.xml 2010-01-19 17:34:02 UTC (rev 1674) +++ trunk/pom.xml 2010-01-21 12:14:14 UTC (rev 1675) @@ -328,22 +328,7 @@ <plugins> <plugin> - <groupId>org.codehaus.plexus</groupId> - <artifactId>plexus-component-metadata</artifactId> - <version>1.4.0</version> - </plugin> - - <plugin> - <artifactId>maven-resources-plugin</artifactId> - <version>2.3</version> - <configuration> - <encoding>${project.build.sourceEncoding}</encoding> - </configuration> - </plugin> - - <plugin> <artifactId>maven-site-plugin</artifactId> - <version>2.0.1</version> <dependencies> <dependency> <groupId>org.nuiton.jrst</groupId> Modified: trunk/src/main/java/org/nuiton/license/plugin/AddThirdPartyFilePlugin.java =================================================================== --- trunk/src/main/java/org/nuiton/license/plugin/AddThirdPartyFilePlugin.java 2010-01-19 17:34:02 UTC (rev 1674) +++ trunk/src/main/java/org/nuiton/license/plugin/AddThirdPartyFilePlugin.java 2010-01-21 12:14:14 UTC (rev 1675) @@ -103,7 +103,7 @@ */ protected boolean keepBackup; /** - * Un flag pour farie une copie nommé dans META-INF (prefixe avec le nom de l'artifact). + * Un flag pour faire une copie nommé dans META-INF (prefixe avec le nom de l'artifact). * * @parameter expression="${helper.copyToMETA_INF}" default-value="false" * @since 1.0.0 @@ -171,10 +171,6 @@ protected String thirdPartyFileContent; protected File thirdPartyFile; -// public AddThirdPartyFilePlugin() { -// super("all files are up-to-date."); -// } - @Override protected boolean checkPackaging() { return rejectPackaging(Packaging.pom); @@ -183,7 +179,6 @@ @Override protected void init() throws Exception { -// protected boolean init() throws Exception { doGenerate = true; thirdPartyFile = new File(outputDirectory, thirdPartyFilename); @@ -219,8 +214,6 @@ } else { thirdPartyFileContent = PluginHelper.readAsString(thirdPartyFile, encoding); } - -// return true; } @Override @@ -234,7 +227,6 @@ getLog().info("backup " + thirdPartyFile); } backupFile(thirdPartyFile); -// thirdPartyFile.renameTo(new File(thirdPartyFile.getAbsolutePath() + '~')); } writeFile(thirdPartyFile, thirdPartyFileContent, encoding); } @@ -242,7 +234,6 @@ copyFile(thirdPartyFile, new File(outputDirectory, "META-INF" + File.separator + project.getArtifactId() + "-" + thirdPartyFile.getName())); } addResourceDir(outputDirectory,"**/*.txt"); -// addResourceDir(outputDirectory.getAbsolutePath()); } /** @return resolve the dependency tree */ Modified: trunk/src/main/java/org/nuiton/license/plugin/GeneratorListPlugin.java =================================================================== --- trunk/src/main/java/org/nuiton/license/plugin/GeneratorListPlugin.java 2010-01-19 17:34:02 UTC (rev 1674) +++ trunk/src/main/java/org/nuiton/license/plugin/GeneratorListPlugin.java 2010-01-21 12:14:14 UTC (rev 1675) @@ -20,7 +20,6 @@ */ package org.nuiton.license.plugin; -import java.util.Iterator; import java.util.Map; import java.util.Map.Entry; import org.apache.maven.plugin.AbstractMojo; @@ -60,7 +59,7 @@ public void execute() throws MojoExecutionException, MojoFailureException { // display it - StringBuilder buffer = new StringBuilder('\n'); + StringBuilder buffer = new StringBuilder("\n"); buffer.append("\n\n-------------------------------------------------------------------------------\n"); buffer.append(" maven-license-plugin\n"); buffer.append("-------------------------------------------------------------------------------\n\n"); @@ -68,9 +67,8 @@ buffer.append("No generator found.\n\n"); } else { buffer.append("List of available generators :\n\n"); - Iterator<Entry<String, HeaderGenerator>> itr = _generators.entrySet().iterator(); - while (itr.hasNext()) { - Entry<String, HeaderGenerator> e = itr.next(); + for (Entry<String, HeaderGenerator> stringHeaderGeneratorEntry : _generators.entrySet()) { + Entry<String, HeaderGenerator> e = stringHeaderGeneratorEntry; HeaderGenerator generator = e.getValue(); buffer.append(" - ").append(e.getKey()).append(" : ").append(generator.getDescription()); buffer.append("\n"); Modified: trunk/src/main/java/org/nuiton/license/plugin/UpdateHeaderPlugin.java =================================================================== --- trunk/src/main/java/org/nuiton/license/plugin/UpdateHeaderPlugin.java 2010-01-19 17:34:02 UTC (rev 1674) +++ trunk/src/main/java/org/nuiton/license/plugin/UpdateHeaderPlugin.java 2010-01-21 12:14:14 UTC (rev 1675) @@ -234,10 +234,6 @@ */ protected long timestamp; -// public UpdateHeaderPlugin() { -// super("all files are up-to-date."); -// } - @Override public boolean isVerbose() { return verbose; @@ -278,7 +274,6 @@ @Override public void init() throws Exception { -// public boolean init() throws Exception { if (skipUpdateHeader) { return; @@ -288,8 +283,6 @@ if (_generators == null) { // should never happen... throw new MojoExecutionException("no header generator found"); -// getLog().warn("no header generator found"); -// return false; } if (verbose) { for (Entry<String, HeaderGenerator> stringHeaderGeneratorEntry : _generators.entrySet()) { @@ -300,8 +293,6 @@ if (!_generators.containsKey(generatorName.trim())) { throw new MojoExecutionException("the generator named '" + generatorName + "' is unknown (use generator-list goal to see all of them)"); -// getLog().warn("the generator named '" + generatorName + "' is unknown (use generator-list goal to see all of them)"); -// return false; } HeaderGenerator generator = _generators.get(generatorName); @@ -316,7 +307,6 @@ if (filesToTreate.isEmpty()) { return; } -// if (!filesToTreate.isEmpty()) { File templateFile = new File(template); @@ -341,24 +331,10 @@ getLog().info("config - header to use\n" + boxedLicenseHeaderContent); } -// } else { -// getLog().info("no file to treate."); -// } - -// return true; } @Override protected void doAction() throws Exception { -// if (skipUpdateHeader) { -// getLog().info("skip flag is on, the goal is skip."); -// return; -// } -// -// if (filesToTreate.isEmpty()) { -// getLog().info("No file to treate."); -// return; -// } // create a licence processor with given header LicenseProcessor p = new LicenseProcessor(licenseHeaderContent); @@ -399,21 +375,17 @@ getLog().debug("backup original file " + file); } renameFile(file, backupFile); -// file.renameTo(backupFile); } if (dryRun) { deleteFile(processFile); -// processFile.delete(); } else { renameFile(processFile, file); -// processFile.renameTo(file); } } catch (Exception e) { getLog().warn("skip file " + file + " (could not process for reason : " + e.getMessage() + ")"); deleteFile(processFile); -// processFile.delete(); } finally { // toujours cleaner les états du filtre du processeur p.getLicenceFilter().reset(); Modified: trunk/src/main/java/org/nuiton/license/plugin/header/generator/HeaderGenerator.java =================================================================== --- trunk/src/main/java/org/nuiton/license/plugin/header/generator/HeaderGenerator.java 2010-01-19 17:34:02 UTC (rev 1674) +++ trunk/src/main/java/org/nuiton/license/plugin/header/generator/HeaderGenerator.java 2010-01-21 12:14:14 UTC (rev 1675) @@ -63,7 +63,7 @@ * * @param content * @return the prefix content - * @throws IOException + * @throws IOException if any io exceptions */ String prefixContent(String content) throws IOException; Modified: trunk/src/main/java/org/nuiton/license/plugin/header/generator/PropertiesLicenseHeaderGeneratorImpl.java =================================================================== --- trunk/src/main/java/org/nuiton/license/plugin/header/generator/PropertiesLicenseHeaderGeneratorImpl.java 2010-01-19 17:34:02 UTC (rev 1674) +++ trunk/src/main/java/org/nuiton/license/plugin/header/generator/PropertiesLicenseHeaderGeneratorImpl.java 2010-01-21 12:14:14 UTC (rev 1675) @@ -38,7 +38,7 @@ public static final String PREFIX = "#"; public PropertiesLicenseHeaderGeneratorImpl() { - super("#", LINE, LINE, LicenseFilter.HEADER, LicenseFilter.FOOTER); + super(PREFIX, LINE, LINE, LicenseFilter.HEADER, LicenseFilter.FOOTER); } @Override