Author: tchemit Date: 2008-08-17 21:43:01 +0000 (Sun, 17 Aug 2008) New Revision: 1042 Removed: trunk/maven-license-switcher-plugin/src/main/java/org/codelutin/license/LicenseFilter.java trunk/maven-license-switcher-plugin/src/main/java/org/codelutin/license/LicenseProcessor.java Modified: trunk/maven-license-switcher-plugin/pom.xml trunk/maven-license-switcher-plugin/src/main/java/org/codelutin/license/SwitchLicenseMojo.java Log: deplacement des fichiers filter et processor vers le projet lutinprocessor suppression dependances inutiles Modified: trunk/maven-license-switcher-plugin/pom.xml =================================================================== --- trunk/maven-license-switcher-plugin/pom.xml 2008-08-17 21:19:32 UTC (rev 1041) +++ trunk/maven-license-switcher-plugin/pom.xml 2008-08-17 21:43:01 UTC (rev 1042) @@ -40,20 +40,6 @@ </dependency> <dependency> - <groupId>xalan</groupId> - <artifactId>xalan</artifactId> - <version>2.7.0</version> - <scope>compile</scope> - </dependency> - - <dependency> - <groupId>commons-collections</groupId> - <artifactId>commons-collections</artifactId> - <version>3.1</version> - <scope>compile</scope> - </dependency> - - <dependency> <groupId>org.codelutin</groupId> <artifactId>lutinpluginutil</artifactId> <version>0.1</version> Deleted: trunk/maven-license-switcher-plugin/src/main/java/org/codelutin/license/LicenseFilter.java =================================================================== --- trunk/maven-license-switcher-plugin/src/main/java/org/codelutin/license/LicenseFilter.java 2008-08-17 21:19:32 UTC (rev 1041) +++ trunk/maven-license-switcher-plugin/src/main/java/org/codelutin/license/LicenseFilter.java 2008-08-17 21:43:01 UTC (rev 1042) @@ -1,80 +0,0 @@ -/** - * *##% Plugin maven pour switcher les licenses - * Copyright (C) 2008 CodeLutin - * - * 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>. ##%* - */ -package org.codelutin.license; - -import org.codelutin.processor.filters.DefaultFilter; - -/** - * Un filtre pour remplacer la license d'un fichier source java. - * <p/> - * fixme : il faut ne pas autoriser le process de fichier java qui ne sont pas valide selon le header - footer... - * - * @author chemit - */ -public class LicenseFilter extends DefaultFilter { - - protected static final String header = "*"+"##%"; - protected static final String footer = "#"+"#%*"; - /** - * la licence a insere dans le header du fichier source. Ce header est formatte en commentaire (chaque ligne - * commence par un ' * ', sauf pour la premiere et derniere ligne). - */ - protected String licenseHeader; - - /** flag pour indiquer si la licence a ete trouvee entre le header et le footer */ - protected boolean touched; - - public LicenseFilter(String licenseHeader) { - this.licenseHeader = " " + licenseHeader + " "; - } - - protected String performInFilter(String ch) { - if (wasTouched()) { - // on autorise pas deux process de la licence dans un fichier java - throw new IllegalStateException("has find more than once the license processor tags in a file"); - } - touched = true; - return header + licenseHeader + footer; - } - - protected String performOutFilter(String ch) { - return ch; - } - - protected String getHeader() { - return header; - } - - protected String getFooter() { - return footer; - } - - @Override - public String flush() { - return super.flush(); - } - - public boolean wasTouched() { - return touched; - } - - public void reset() { - touched = false; - } -} Deleted: trunk/maven-license-switcher-plugin/src/main/java/org/codelutin/license/LicenseProcessor.java =================================================================== --- trunk/maven-license-switcher-plugin/src/main/java/org/codelutin/license/LicenseProcessor.java 2008-08-17 21:19:32 UTC (rev 1041) +++ trunk/maven-license-switcher-plugin/src/main/java/org/codelutin/license/LicenseProcessor.java 2008-08-17 21:43:01 UTC (rev 1042) @@ -1,43 +0,0 @@ -/** - * *##% Plugin maven pour switcher les licenses - * Copyright (C) 2008 CodeLutin - * - * 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>. ##%* - */ -package org.codelutin.license; - -import java.io.File; -import java.io.FileReader; -import java.io.FileWriter; -import java.io.IOException; - -/** @author chemit */ -public class LicenseProcessor extends org.codelutin.processor.Processor { - - protected LicenseFilter licenseFilter; - - public LicenseProcessor(String header) { - licenseFilter = new LicenseFilter(header); - setInputFilter(licenseFilter); - } - - public LicenseFilter getLicenceFilter() { - return licenseFilter; - } - - public void process(File filein, File fileout) throws IOException { - process(new FileReader(filein), new FileWriter(fileout)); - } -} Modified: trunk/maven-license-switcher-plugin/src/main/java/org/codelutin/license/SwitchLicenseMojo.java =================================================================== --- trunk/maven-license-switcher-plugin/src/main/java/org/codelutin/license/SwitchLicenseMojo.java 2008-08-17 21:19:32 UTC (rev 1041) +++ trunk/maven-license-switcher-plugin/src/main/java/org/codelutin/license/SwitchLicenseMojo.java 2008-08-17 21:43:01 UTC (rev 1042) @@ -23,6 +23,8 @@ import org.apache.maven.plugin.MojoFailureException; import org.apache.maven.project.MavenProject; import org.codehaus.plexus.util.DirectoryScanner; +import org.codelutin.processor.LicenseProcessor; +import org.codelutin.processor.filters.LicenseFilter; import org.codelutin.util.FileUtil; import java.io.BufferedReader; @@ -222,7 +224,7 @@ protected void addLicenseToJavaSourceFile(File sourceFile, File processFile) throws IOException { getLog().warn("no license was found on file " + sourceFile + ", adding one"); String content = FileUtil.readAsString(sourceFile, encoding); - content = "/**\n * " + LicenseFilter.header + " " + licenseHeaderContent + " " + LicenseFilter.header + "\n */\n" + content; + content = "/**\n * " + LicenseFilter.HEADER+ " " + licenseHeaderContent + " " + LicenseFilter.HEADER+ "\n */\n" + content; FileUtil.writeString(processFile, content, encoding); }