Maven-helper-plugin-commits
Threads by month
- ----- 2026 -----
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- 421 discussions
r574 - trunk/src/test/resources/org/nuiton/license/plugin/LicensePluginTest
by tchemit@users.nuiton.org 15 Sep '09
by tchemit@users.nuiton.org 15 Sep '09
15 Sep '09
Author: tchemit
Date: 2009-09-15 17:44:51 +0200 (Tue, 15 Sep 2009)
New Revision: 574
Added:
trunk/src/test/resources/org/nuiton/license/plugin/LicensePluginTest/licenseTwo.txt
trunk/src/test/resources/org/nuiton/license/plugin/LicensePluginTest/testTwo.xml
Log:
[FEATURE #50 & #51] update to junit 4.7, rethink AbstractPlugin api
Added: trunk/src/test/resources/org/nuiton/license/plugin/LicensePluginTest/licenseTwo.txt
===================================================================
--- trunk/src/test/resources/org/nuiton/license/plugin/LicensePluginTest/licenseTwo.txt (rev 0)
+++ trunk/src/test/resources/org/nuiton/license/plugin/LicensePluginTest/licenseTwo.txt 2009-09-15 15:44:51 UTC (rev 574)
@@ -0,0 +1 @@
+dummy license
\ No newline at end of file
Added: trunk/src/test/resources/org/nuiton/license/plugin/LicensePluginTest/testTwo.xml
===================================================================
--- trunk/src/test/resources/org/nuiton/license/plugin/LicensePluginTest/testTwo.xml (rev 0)
+++ trunk/src/test/resources/org/nuiton/license/plugin/LicensePluginTest/testTwo.xml 2009-09-15 15:44:51 UTC (rev 574)
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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">
+
+ <groupId>org.nuiton</groupId>
+ <artifactId>maven-helper-plugin-testOne</artifactId>
+ <version>0</version>
+
+ <build>
+
+ <plugins>
+ <plugin>
+ <groupId>org.nuiton</groupId>
+ <artifactId>maven-helper-plugin</artifactId>
+ <configuration>
+ <encoding>UTF-8</encoding>
+ <licenseName>lgpl_v3</licenseName>
+ <licenseFile>licenseTwo.txt</licenseFile>
+ <outputDirectory>target/tests/license-plugin-test</outputDirectory>
+ <verbose>true</verbose>
+ </configuration>
+ <executions>
+ <execution>
+ <goals>
+ <goal>add-license</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+</project>
\ No newline at end of file
1
0
r573 - in trunk: . src/main/java/org/nuiton src/main/java/org/nuiton/license/plugin src/main/java/org/nuiton/plugin src/test/java/org/nuiton src/test/java/org/nuiton/license src/test/java/org/nuiton/license/plugin src/test/java/org/nuiton/plugin src/test/java/org/nuiton/util
by tchemit@users.nuiton.org 15 Sep '09
by tchemit@users.nuiton.org 15 Sep '09
15 Sep '09
Author: tchemit
Date: 2009-09-15 17:44:19 +0200 (Tue, 15 Sep 2009)
New Revision: 573
Added:
trunk/src/main/java/org/nuiton/plugin/
trunk/src/main/java/org/nuiton/plugin/AbstractPlugin.java
trunk/src/main/java/org/nuiton/plugin/Plugin.java
trunk/src/test/java/org/nuiton/plugin/
trunk/src/test/java/org/nuiton/plugin/AbstractMojoTest.java
trunk/src/test/java/org/nuiton/plugin/TestHelper.java
Removed:
trunk/src/main/java/org/nuiton/Plugin.java
trunk/src/main/java/org/nuiton/RunJavaPlugin.java
Modified:
trunk/pom.xml
trunk/src/main/java/org/nuiton/AbstractPlugin.java
trunk/src/main/java/org/nuiton/license/plugin/LicensePlugin.java
trunk/src/main/java/org/nuiton/license/plugin/ThirdPartyPlugin.java
trunk/src/test/java/org/nuiton/license/BaseLicenseTestCase.java
trunk/src/test/java/org/nuiton/license/plugin/LicensePluginTest.java
trunk/src/test/java/org/nuiton/util/BasePluginTestCase.java
trunk/src/test/java/org/nuiton/util/JavaFileUpdaterTest.java
trunk/src/test/java/org/nuiton/util/JaxxFileUpdaterTest.java
trunk/src/test/java/org/nuiton/util/PluginConfig.java
Log:
[FEATURE #50 & #51] update to junit 4.7, rethink AbstractPlugin api
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2009-09-11 22:06:27 UTC (rev 572)
+++ trunk/pom.xml 2009-09-15 15:44:19 UTC (rev 573)
@@ -22,12 +22,6 @@
<version>1.1.1</version>
</dependency>
- <!--dependency>
- <groupId>org.apache.maven.enforcer</groupId>
- <artifactId>enforcer-api</artifactId>
- <version>1.0-beta-1</version>
- </dependency-->
-
<dependency>
<groupId>org.apache.maven.shared</groupId>
<artifactId>maven-dependency-tree</artifactId>
@@ -83,17 +77,10 @@
<scope>test</scope>
</dependency>
- <!--dependency>
- <groupId>org.apache.maven.shared</groupId>
- <artifactId>maven-verifier</artifactId>
- <version>1.0</version>
- <scope>test</scope>
- </dependency-->
-
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
- <version>4.6</version>
+ <version>4.7</version>
<scope>test</scope>
</dependency>
@@ -115,7 +102,6 @@
<licenses>
<license>
<name>Lesser General Public License (LGPL)</name>
- <!--<url>http://www.gnu.org/licenses/lgpl.txt</url>-->
<url>${project.basedir}/LICENSE.txt</url>
<distribution>local</distribution>
</license>
Modified: trunk/src/main/java/org/nuiton/AbstractPlugin.java
===================================================================
--- trunk/src/main/java/org/nuiton/AbstractPlugin.java 2009-09-11 22:06:27 UTC (rev 572)
+++ trunk/src/main/java/org/nuiton/AbstractPlugin.java 2009-09-15 15:44:19 UTC (rev 573)
@@ -41,6 +41,7 @@
import org.codehaus.plexus.util.DirectoryScanner;
import org.codehaus.plexus.util.FileUtils;
import org.codehaus.plexus.util.io.RawInputStreamFacade;
+import org.nuiton.plugin.Plugin;
import org.nuiton.util.MirroredFileUpdater;
import org.nuiton.util.PluginHelper;
@@ -48,7 +49,9 @@
* Un MOJO de base pour les autres MOJO concrets avec les options communes.
*
* @author chemit
+ * @deprecated since 1.0.3, prefer use {@link org.nuiton.plugin.AbstractPlugin}
*/
+@Deprecated
public abstract class AbstractPlugin extends AbstractMojo implements Plugin {
protected abstract boolean ensurePackaging();
Deleted: trunk/src/main/java/org/nuiton/Plugin.java
===================================================================
--- trunk/src/main/java/org/nuiton/Plugin.java 2009-09-11 22:06:27 UTC (rev 572)
+++ trunk/src/main/java/org/nuiton/Plugin.java 2009-09-15 15:44:19 UTC (rev 573)
@@ -1,23 +0,0 @@
-package org.nuiton;
-
-import org.apache.maven.plugin.Mojo;
-import org.apache.maven.project.MavenProject;
-
-/**
- * A common contract to be implements by our mojo and reports.
- *
- * Just expose a {@link #isVerbose()} flag and the maven project {@link #getProject()}.
- *
- * @author chemit
- * @since 1.0.3
- */
-public interface Plugin extends Mojo {
-
- MavenProject getProject();
-
- void setProject(MavenProject project);
-
- boolean isVerbose();
-
- void setVerbose(boolean verbose);
-}
Deleted: trunk/src/main/java/org/nuiton/RunJavaPlugin.java
===================================================================
--- trunk/src/main/java/org/nuiton/RunJavaPlugin.java 2009-09-11 22:06:27 UTC (rev 572)
+++ trunk/src/main/java/org/nuiton/RunJavaPlugin.java 2009-09-15 15:44:19 UTC (rev 573)
@@ -1,190 +0,0 @@
-/*
- * *##%
- * Maven helper plugin
- * Copyright (C) 2009 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.nuiton;
-
-import java.io.File;
-import java.lang.reflect.Method;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
-import org.apache.maven.project.MavenProject;
-
-/**
- * @goal runJava
- * @requiresDependencyResolution test
- * @requiresProject true
- * @execute phase="process-classes"
- * @since 1.0
- * @author chemit
- */
-public class RunJavaPlugin extends AbstractPlugin {
-
- /**
- * Dependance du projet.
- *
- * @parameter default-value="${project}"
- * @required
- * @since 1.0.0
- */
- protected MavenProject project;
- /**
- * The main class to execute.
- *
- * @parameter expression="${mainClass}" default-value="${maven.jar.main.class}"
- * @required
- * @since 1.0
- */
- protected String mainClass;
- /**
- * The class arguments.
- *
- * @parameter expression="${args}"
- * @since 1.0
- */
- protected String args;
- /**
- * Un flag pour activer le mode verbeux.
- *
- * @parameter expression="${helper.verbose}" default-value="${maven.verbose}"
- * @since 1.0.0
- */
- protected boolean verbose;
- protected Class<?> clazz;
- protected ClassLoader cl;
-
- public RunJavaPlugin() {
- super("");
- }
-
- @Override
- protected boolean ensurePackaging() {
- return project != null && ("pom".equals(project.getPackaging()) || "site".equals(project.getPackaging()));
- }
-
- @Override
- protected boolean init() throws Exception {
-
- cl = initClassLoader(project, new File(project.getBuild().getOutputDirectory()), false, false, false, true, true);
-
- Thread.currentThread().setContextClassLoader(cl);
-
- clazz = Class.forName(mainClass, true, cl);
-
- if (args == null) {
- args = "";
- }
- return true;
- }
-
- @Override
- protected void doAction() throws Exception {
- ThreadGroup threadGroup = Thread.currentThread().getThreadGroup();
- Thread bootstrapThread = new Thread(threadGroup, new Runnable() {
-
- @Override
- public void run() {
- try {
- Method main = Class.forName(mainClass, true, cl).getMethod("main", String[].class);
- if (!main.isAccessible()) {
- getLog().debug("Setting accessibility to true in order to invoke main().");
- main.setAccessible(true);
- }
- main.invoke(main, new Object[]{args.split(" ")});
- } catch (NoSuchMethodException e) {
- // just pass it on
- Thread.currentThread().getThreadGroup().uncaughtException(Thread.currentThread(), new Exception("The specified mainClass doesn't contain a main method with appropriate signature.", e));
- } catch (Exception e) {
- // just pass it on
- Thread.currentThread().getThreadGroup().uncaughtException(Thread.currentThread(), e);
- } finally {
-
- }
- }
- }, mainClass + ".main()");
-
- bootstrapThread.setContextClassLoader(cl);
-
- bootstrapThread.start();
-
- joinNonDaemonThreads(threadGroup);
- }
-
- @Override
- public MavenProject getProject() {
- return project;
- }
-
- @Override
- public void setProject(MavenProject project) {
- this.project = project;
- }
-
- @Override
- public boolean isVerbose() {
- return verbose;
- }
-
- @Override
- public void setVerbose(boolean verbose) {
- this.verbose = verbose;
- }
-
- private void joinNonDaemonThreads(ThreadGroup threadGroup) {
- boolean foundNonDaemon;
- do {
- foundNonDaemon = false;
- Collection<Thread> threads = getActiveThreads(threadGroup);
- for (Iterator<Thread> iter = threads.iterator(); iter.hasNext();) {
- Thread thread = iter.next();
- if (thread.isDaemon()) {
- continue;
- }
- foundNonDaemon = true; //try again; maybe more threads were created while we were busy
- joinThread(thread, 0);
- }
- } while (foundNonDaemon);
- }
-
- private void joinThread(Thread thread, long timeoutMsecs) {
- try {
- getLog().debug("joining on thread " + thread);
- thread.join(timeoutMsecs);
- } catch (InterruptedException e) {
- Thread.currentThread().interrupt(); // good practice if don't throw
- getLog().warn("interrupted while joining against thread " + thread, e); // not expected!
- }
- if (thread.isAlive()) //generally abnormal
- {
- getLog().warn("thread " + thread + " was interrupted but is still alive after waiting at least " + timeoutMsecs + "msecs");
- }
- }
-
- private Collection<Thread> getActiveThreads(ThreadGroup threadGroup) {
- Thread[] threads = new Thread[threadGroup.activeCount()];
- int numThreads = threadGroup.enumerate(threads);
- Collection<Thread> result = new ArrayList<Thread>(numThreads);
- for (int i = 0; i < threads.length && threads[i] != null; i++) {
- result.add(threads[i]);
- }
- return result; //note: result should be modifiable
- }
-
-}
Modified: trunk/src/main/java/org/nuiton/license/plugin/LicensePlugin.java
===================================================================
--- trunk/src/main/java/org/nuiton/license/plugin/LicensePlugin.java 2009-09-11 22:06:27 UTC (rev 572)
+++ trunk/src/main/java/org/nuiton/license/plugin/LicensePlugin.java 2009-09-15 15:44:19 UTC (rev 573)
@@ -35,7 +35,7 @@
* @requiresProject true
* @requiresDependencyResolution compile
*/
-public class LicensePlugin extends org.nuiton.AbstractPlugin {
+public class LicensePlugin extends org.nuiton.plugin.AbstractPlugin {
/**
* Dependance du projet.
Modified: trunk/src/main/java/org/nuiton/license/plugin/ThirdPartyPlugin.java
===================================================================
--- trunk/src/main/java/org/nuiton/license/plugin/ThirdPartyPlugin.java 2009-09-11 22:06:27 UTC (rev 572)
+++ trunk/src/main/java/org/nuiton/license/plugin/ThirdPartyPlugin.java 2009-09-15 15:44:19 UTC (rev 573)
@@ -41,7 +41,7 @@
import java.util.SortedSet;
import java.util.TreeSet;
import org.codehaus.plexus.util.IOUtil;
-import org.nuiton.AbstractPlugin;
+import org.nuiton.plugin.AbstractPlugin;
/**
* Le goal pour copier le fichier THIRD-PARTY.txt (contenant les licenses de toutes les dependances du projet)
Copied: trunk/src/main/java/org/nuiton/plugin/AbstractPlugin.java (from rev 571, trunk/src/main/java/org/nuiton/AbstractPlugin.java)
===================================================================
--- trunk/src/main/java/org/nuiton/plugin/AbstractPlugin.java (rev 0)
+++ trunk/src/main/java/org/nuiton/plugin/AbstractPlugin.java 2009-09-15 15:44:19 UTC (rev 573)
@@ -0,0 +1,438 @@
+/*
+ * *##%
+ * Maven helper plugin
+ * Copyright (C) 2009 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.nuiton.plugin;
+
+import java.io.ByteArrayInputStream;
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
+import org.apache.maven.project.MavenProject;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.model.Resource;
+import org.codehaus.plexus.util.DirectoryScanner;
+import org.codehaus.plexus.util.FileUtils;
+import org.codehaus.plexus.util.io.RawInputStreamFacade;
+import org.nuiton.util.MirroredFileUpdater;
+import org.nuiton.util.PluginHelper;
+
+/**
+ * Un MOJO de base pour les autres MOJO concrets avec les options communes.
+ *
+ * @author chemit
+ */
+public abstract class AbstractPlugin extends AbstractMojo implements Plugin {
+
+ protected abstract boolean ensurePackaging();
+
+ /**
+ * la methode qui est lancee au debut de la methode {@link #execute()} pour preparer l'init du goal.
+ *
+ * @return <code>true</code> if there is something to generate, <code>false</code> otherwise.
+ * @throws Exception if any
+ */
+ protected abstract boolean init() throws Exception;
+
+ /**
+ * Do plugin action.
+ * <p/>
+ * The method {@link #execute()} invoke this method only and only if :
+ * <ul>
+ * <li>{@link #ensurePackaging()} returns <code>false</code> (filtrer project type, for example).</li>
+ * <li>method {@link #init()} returns <code>true</code>.</li>
+ * </ul>
+ *
+ * @throws Exception if any
+ */
+ protected abstract void doAction() throws Exception;
+ protected final String skipAfterInitMessage;
+
+ protected AbstractPlugin(String skipAfterInitMessage) {
+ this.skipAfterInitMessage = skipAfterInitMessage;
+ }
+
+ @Override
+ public void execute() throws MojoExecutionException, MojoFailureException {
+ try {
+
+ if (ensurePackaging()) {
+ getLog().info("skip goal for packaging " + getProject().getPackaging());
+ return;
+ }
+
+ boolean canContinue = init();
+
+ if (!canContinue) {
+ getLog().info(skipAfterInitMessage);
+ return;
+ }
+
+ doAction();
+
+ } catch (Exception e) {
+ throw new MojoExecutionException("could not init goal " + getClass().getSimpleName() + " for reason : " + e.getMessage(), e);
+ }
+ }
+
+ /**
+ * Does the actual copy of the file and logging.
+ *
+ * @param srcFile represents the file to copy.
+ * @param destFile file name of destination file.
+ *
+ * @throws MojoExecutionException with a message if an
+ * error occurs.
+ */
+ protected void copyFile(File srcFile, File destFile)
+ throws MojoExecutionException {
+ try {
+ getLog().info("Copying " + srcFile.getName() + " to " + destFile);
+
+ FileUtils.copyFile(srcFile, destFile);
+
+ } catch (Exception e) {
+ throw new MojoExecutionException("Error copying from " + srcFile + " to " + destFile, e);
+ }
+ }
+
+ /**
+ * Does the actual copy of the content to a fileand logging.
+ *
+ * @param content represents the content to writeFile into file.
+ * @param destFile file name of destination file.
+ * @param encoding encoding to use to writeFile file
+ * @throws MojoExecutionException with a message if an
+ * error occurs.
+ */
+ protected void copyFile(String content, File destFile, String encoding)
+ throws MojoExecutionException {
+ try {
+ getLog().info("Copying content to " + destFile);
+
+ InputStream in = new ByteArrayInputStream(content.getBytes(encoding));
+ RawInputStreamFacade facade = new RawInputStreamFacade(in);
+
+ FileUtils.copyStreamToFile(facade, destFile);
+
+ } catch (Exception e) {
+ throw new MojoExecutionException("Error copying content to " + destFile, e);
+ }
+ }
+
+ public void writeFile(File destFile, String content, String encoding) throws IOException {
+ PluginHelper.write(destFile, content, encoding);
+ }
+
+ /**
+ * Test if a file exists and is newer than the pom file.
+ *
+ * @param f the file to test
+ * @return <code>true</code> if file exists and is newer than the pom file,
+ * <code>false</code> otherwise.
+ */
+ protected boolean isFileNewerThanPomFile(File f) {
+ File pomFile = getProject().getFile();
+ return f.exists() && f.lastModified() > pomFile.lastModified();
+ }
+
+ protected void getFilesToTreateForRoots(String[] includes, String[] excludes, List<String> roots, Map<File, String[]> files, MirroredFileUpdater updater) {
+
+ DirectoryScanner ds = new DirectoryScanner();
+ ds.setIncludes(includes);
+ if (excludes != null) {
+ ds.setExcludes(excludes);
+
+ }
+ for (String src : roots) {
+
+ File f = new File(src);
+ if (!f.exists()) {
+ // do nothing on a non-existent
+ continue;
+ }
+
+ if (isVerbose()) {
+ getLog().info("discovering java source files in root " + src);
+ }
+
+ ds.setBasedir(f);
+ // scan
+ ds.scan();
+
+ // get files
+ String[] tmp = ds.getIncludedFiles();
+
+ if (tmp.length < 1) {
+ // no files found
+ continue;
+ }
+
+ List<String> toTreate = new ArrayList<String>();
+
+ if (updater != null) {
+ updater.setSourceDirectory(f);
+ }
+
+
+ for (String filePath : tmp) {
+ File srcFile = new File(f, filePath);
+ // check file is up-to-date
+ if (updater == null || !updater.isFileUpToDate(srcFile)) {
+ toTreate.add(filePath);
+ }
+ }
+
+
+ if (toTreate.isEmpty()) {
+ // no file or all are up-to-date
+ continue;
+ }
+
+ // register files
+ files.put(f, toTreate.toArray(new String[toTreate.size()]));
+
+ }
+ }
+
+ protected Map<String, String> getFilesToTreate(String[] includes, String[] excludes, File srcDir, MirroredFileUpdater updater) {
+
+ Map<String, String> result = new java.util.TreeMap<String, String>();
+
+ DirectoryScanner ds = new DirectoryScanner();
+ ds.setIncludes(includes);
+ if (excludes != null) {
+ ds.setExcludes(excludes);
+
+ }
+
+ if (!srcDir.exists()) {
+ // do nothing on a non-existent
+ return result;
+ }
+
+ if (isVerbose()) {
+ getLog().info("discovering files for " + srcDir);
+ }
+
+ ds.setBasedir(srcDir);
+ // scan
+ ds.scan();
+
+ // get files
+ String[] tmp = ds.getIncludedFiles();
+
+ if (tmp.length < 1) {
+ // no files found
+ return result;
+ }
+
+ List<String> toTreate = new ArrayList<String>();
+
+ if (updater != null) {
+ updater.setSourceDirectory(srcDir);
+ }
+
+ for (String filePath : tmp) {
+ File srcFile = new File(srcDir, filePath);
+ File mirrorFile = updater.getMirrorFile(srcFile);
+ // check file is up-to-date
+ if (updater == null || !updater.isFileUpToDate(srcFile)) {
+ result.put(filePath, mirrorFile.getAbsolutePath());
+ toTreate.add(filePath);
+ }
+ }
+
+
+ if (toTreate.isEmpty()) {
+ // no file or all are up-to-date
+ return result;
+ }
+
+ // register files
+ return result;
+ }
+
+ protected void addCompileSourceRoots(File srcDir) {
+ if (!getProject().getCompileSourceRoots().contains(srcDir.getPath())) {
+ if (isVerbose()) {
+ getLog().info("adding source roots : " + srcDir.getPath());
+ }
+ getProject().addCompileSourceRoot(srcDir.getPath());
+ }
+ }
+
+ protected void removeCompileSourceRoots(File srcDir) {
+ if (getProject().getCompileSourceRoots().contains(srcDir.getPath())) {
+ if (isVerbose()) {
+ getLog().info("removing source roots : " + srcDir.getPath());
+ }
+ getProject().getCompileSourceRoots().remove(srcDir.getPath());
+ }
+ }
+
+ protected void addTestCompileSourceRoots(File srcDir) {
+ if (!getProject().getTestCompileSourceRoots().contains(srcDir.getPath())) {
+ if (isVerbose()) {
+ getLog().info("adding test source roots : " + srcDir.getPath());
+ }
+ getProject().addTestCompileSourceRoot(srcDir.getPath());
+ }
+ }
+
+ protected void removeTestCompileSourceRoots(File srcDir) {
+ if (getProject().getTestCompileSourceRoots().contains(srcDir.getPath())) {
+ if (isVerbose()) {
+ getLog().info("removing test source roots : " + srcDir.getPath());
+ }
+ getProject().getTestCompileSourceRoots().remove(srcDir.getPath());
+ }
+ }
+
+ protected void addResourceDir(String dir) {
+ boolean added = PluginHelper.addResourceDir(dir, getProject());
+ if (added) {
+ getLog().info("add resource " + dir);
+ }
+ }
+
+ protected void addTestResourceDir(String dir) {
+ boolean added = PluginHelper.addTestResourceDir(dir, getProject());
+ if (added) {
+ getLog().info("add test resource " + dir);
+ }
+ }
+
+ @SuppressWarnings({"unchecked"})
+ protected URLClassLoader initClassLoader(MavenProject project, File src, boolean addSourcesToClassPath, boolean testPhase, boolean addResourcesToClassPath, boolean addCompileClassPath, boolean addProjectClassPath) throws MalformedURLException {
+ URLClassLoader loader = null;
+ if (project != null) {
+
+ URLClassLoader result;
+ try {
+
+ List<URL> lUrls = new ArrayList<URL>();
+ List<String> sources = project.getCompileSourceRoots();
+
+ if (addSourcesToClassPath) {
+ for (String source : sources) {
+ lUrls.add(new File(source).toURI().toURL());
+ }
+ if (testPhase) {
+ for (Object source : project.getTestCompileSourceRoots()) {
+ lUrls.add(new File(source.toString()).toURI().toURL());
+ }
+ }
+ }
+ if (addResourcesToClassPath) {
+ for (Object source : project.getResources()) {
+ Resource r = (Resource) source;
+ lUrls.add(new File(r.getDirectory()).toURI().toURL());
+ }
+ }
+ if (testPhase && addCompileClassPath) {
+ if (project != null) {
+ lUrls.add(new File(project.getBuild().getOutputDirectory()).toURI().toURL());
+ }
+ }
+ if (src != null) {
+ lUrls.add(src.toURI().toURL());
+ }
+ if (addProjectClassPath) {
+ getLog().info("use project compile scope class-path");
+ // add also all dependencies of the project in compile scope
+ Set<?> artifacts = project.getArtifacts();
+ for (Object o : artifacts) {
+ Artifact a = (Artifact) o;
+ lUrls.add(a.getFile().toURI().toURL());
+ }
+ }
+
+ result = new URLClassLoader(lUrls.toArray(new URL[lUrls.size()]), getClass().getClassLoader());
+
+ } catch (IOException e) {
+ throw new RuntimeException("Can't create ClassLoader for reason " + e.getMessage(), e);
+ }
+ loader = result;
+ } else {
+ List<URL> lUrls = new ArrayList<URL>();
+ if (addSourcesToClassPath) {
+ lUrls.add(src.toURI().toURL());
+ }
+ loader = new URLClassLoader(lUrls.toArray(new URL[lUrls.size()]), getClass().getClassLoader());
+ }
+ if (isVerbose()) {
+ for (URL entry : loader.getURLs()) {
+ getLog().info("classpath : " + entry);
+ }
+ }
+ return loader;
+ }
+
+ /**
+ *
+ * @param f le fichier de template
+ * @return l'url du fichier demande
+ * @throws IOException pour toute erreur de recherche
+ */
+ protected URL getTemplate(File f) throws IOException {
+ URL r = null;
+ if (f.exists()) {
+ r = f.toURI().toURL();
+ } else {
+ r = getClass().getResource(f.toString());
+ }
+ return r;
+ }
+
+ /**
+ * Vérifie que le fichier donné existe bien (sur le filesystem ou
+ * dans le class-path).
+ *
+ * @param f le fichier que l'on veut vérifié
+ * @throws IOException pour tout erreur de recherche
+ */
+ protected void checkResource(File f) throws IOException {
+ if (!f.exists()) {
+ // test in classPath
+ InputStream r = null;
+ try {
+ r = getClass().getResourceAsStream(f.toString());
+ if (r == null) {
+ throw new IOException("could not find ressource " + f);
+ }
+ } finally {
+ if (r != null) {
+ r.close();
+ }
+ }
+ }
+ }
+}
Property changes on: trunk/src/main/java/org/nuiton/plugin/AbstractPlugin.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: trunk/src/main/java/org/nuiton/plugin/Plugin.java (from rev 571, trunk/src/main/java/org/nuiton/Plugin.java)
===================================================================
--- trunk/src/main/java/org/nuiton/plugin/Plugin.java (rev 0)
+++ trunk/src/main/java/org/nuiton/plugin/Plugin.java 2009-09-15 15:44:19 UTC (rev 573)
@@ -0,0 +1,23 @@
+package org.nuiton.plugin;
+
+import org.apache.maven.plugin.Mojo;
+import org.apache.maven.project.MavenProject;
+
+/**
+ * A common contract to be implements by our mojo and reports.
+ *
+ * Just expose a {@link #isVerbose()} flag and the maven project {@link #getProject()}.
+ *
+ * @author chemit
+ * @since 1.0.3
+ */
+public interface Plugin extends Mojo {
+
+ MavenProject getProject();
+
+ void setProject(MavenProject project);
+
+ boolean isVerbose();
+
+ void setVerbose(boolean verbose);
+}
Property changes on: trunk/src/main/java/org/nuiton/plugin/Plugin.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL
Added: svn:mergeinfo
+
Modified: trunk/src/test/java/org/nuiton/license/BaseLicenseTestCase.java
===================================================================
--- trunk/src/test/java/org/nuiton/license/BaseLicenseTestCase.java 2009-09-11 22:06:27 UTC (rev 572)
+++ trunk/src/test/java/org/nuiton/license/BaseLicenseTestCase.java 2009-09-15 15:44:19 UTC (rev 573)
@@ -23,22 +23,21 @@
import org.junit.Assert;
import java.io.File;
-import java.io.FileInputStream;
import java.io.IOException;
-import org.codehaus.plexus.util.IOUtil;
+import org.nuiton.plugin.TestHelper;
import org.nuiton.util.PluginHelper;
/** @author chemit */
public abstract class BaseLicenseTestCase extends Assert {
protected static final String encoding = "utf-8";
+ protected File baseDir;
protected File getBaseDir() {
- String path = System.getenv("basedir");
- if (path == null) {
- path = new File("").getAbsolutePath();
+ if (baseDir == null) {
+ baseDir = TestHelper.getBasedir();
}
- return new File(path);
+ return baseDir;
}
protected void assertLicenseFound(String name, License license) throws IOException {
@@ -51,7 +50,7 @@
protected File createLicenseRepository(boolean createLicene) throws IOException {
long timestamp = System.currentTimeMillis();
- File repo = new File(getBaseDir(), "target" + File.separator + "licenses_" + timestamp);
+ File repo = TestHelper.getFile(getBaseDir(), "target", "licenses_" + timestamp);
if (createLicene) {
@@ -68,20 +67,16 @@
String content = "";
if (defFile.exists()) {
- content = IOUtil.toString(new FileInputStream(defFile), encoding) + "\n";
-// content = FileUtil.readAsString(defFile, encoding) + "\n";
+ content = PluginHelper.readAsString(defFile, encoding) + "\n";
}
-
PluginHelper.write(defFile, content + licenseName + "=My dummy license\n", encoding);
-// FileUtil.writeString(defFile, content + licenseName + "=My dummy license\n", encoding);
+
// create dummy licenses
File file = new File(repo, licenseName);
file.mkdirs();
PluginHelper.write(new File(file, "license.txt"), "license:" + licenseName, encoding);
PluginHelper.write(new File(file, "header.txt"), "header:" + licenseName, encoding);
-// FileUtil.writeString(new File(file, "license.txt"), "license:" + licenseName, encoding);
-// FileUtil.writeString(new File(file, "header.txt"), "header:" + licenseName, encoding);
}
}
Modified: trunk/src/test/java/org/nuiton/license/plugin/LicensePluginTest.java
===================================================================
--- trunk/src/test/java/org/nuiton/license/plugin/LicensePluginTest.java 2009-09-11 22:06:27 UTC (rev 572)
+++ trunk/src/test/java/org/nuiton/license/plugin/LicensePluginTest.java 2009-09-15 15:44:19 UTC (rev 573)
@@ -20,51 +20,38 @@
*/
package org.nuiton.license.plugin;
-import org.nuiton.util.PluginConfig;
-import org.apache.maven.plugin.MojoExecutionException;
-import org.apache.maven.plugin.MojoFailureException;
import static org.junit.Assert.*;
-import org.junit.Before;
-import org.junit.BeforeClass;
import org.junit.Test;
import java.io.File;
import java.io.IOException;
-import org.junit.AfterClass;
-import org.nuiton.util.BasePluginTestCase;
+import org.nuiton.plugin.AbstractMojoTest;
-/** @author chemit */
-public class LicensePluginTest extends BasePluginTestCase<LicensePlugin> {
+public class LicensePluginTest extends AbstractMojoTest<LicensePlugin> {
- @BeforeClass
- public static void initClass() throws Exception {
- initConfigs(LicensePluginTest.class, "testOne");
+ @Override
+ protected String getGoalName(String methodName) {
+ return "add-license";
}
- @AfterClass
- public static void afterClass() throws Exception {
- configItr = null;
- testDir = null;
- }
-
- @Before
@Override
- public void setUp() throws Exception {
- super.setUp();
- mojo.setOutputDirectory(new File(getBaseDir(), mojo.getOutputDirectory().toString()));
- if (!mojo.getOutputDirectory().exists()) {
- if (!mojo.getOutputDirectory().mkdirs()) {
- throw new IOException("could not create directory : " + mojo.getOutputDirectory());
+ protected void setUpMojo(LicensePlugin mojo, File pomFile) throws Exception {
+ super.setUpMojo(mojo, pomFile);
+ File outputDirectory = new File(getBasedir(), mojo.getOutputDirectory().toString());
+ mojo.setOutputDirectory(outputDirectory);
+ if (!outputDirectory.exists()) {
+ if (!outputDirectory.mkdirs()) {
+ throw new IOException("could not create directory : " + outputDirectory);
}
}
mojo.setLicenseFile(new File(pomFile.getParentFile(), mojo.getLicenseFile().toString()));
}
@Test
- @PluginConfig(pomName = "testOne.xml", goalName = "add-license")
- public void testOne() throws MojoExecutionException, MojoFailureException {
- assertNotNull(mojo);
+ public void testOne() throws Exception {
+ LicensePlugin mojo = getMojo();
+
long t0 = mojo.getLicenseFile().lastModified();
// always assume pom is older than any file
@@ -84,4 +71,29 @@
assertTrue(t1 > t0);
}
+
+ @Test
+ public void testTwo() throws Exception {
+
+ LicensePlugin mojo = getMojo();
+
+ long t0 = mojo.getLicenseFile().lastModified();
+
+ // always assume pom is older than any file
+ // since we can not ensure order of copy test resources
+ mojo.getProject().getFile().setLastModified(0);
+
+ mojo.execute();
+
+ long t1 = mojo.getLicenseFile().lastModified();
+
+ assertEquals(t0, t1);
+
+ mojo.setForce(true);
+
+ mojo.execute();
+ t1 = mojo.getLicenseFile().lastModified();
+
+ assertTrue(t1 > t0);
+ }
}
Added: trunk/src/test/java/org/nuiton/plugin/AbstractMojoTest.java
===================================================================
--- trunk/src/test/java/org/nuiton/plugin/AbstractMojoTest.java (rev 0)
+++ trunk/src/test/java/org/nuiton/plugin/AbstractMojoTest.java 2009-09-15 15:44:19 UTC (rev 573)
@@ -0,0 +1,163 @@
+package org.nuiton.plugin;
+
+import java.io.File;
+import org.apache.maven.plugin.Mojo;
+import org.apache.maven.plugin.logging.Log;
+import org.apache.maven.plugin.logging.SystemStreamLog;
+import org.apache.maven.project.MavenProject;
+import org.junit.rules.TestName;
+import org.junit.Rule;
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.runners.model.FrameworkMethod;
+
+/**
+ *
+ * @param <P> type of goal to test
+ * @author chemit
+ * @since 1.0.3
+ */
+public abstract class AbstractMojoTest<P extends Plugin> {
+
+ protected static Log log;
+ protected static File testDir;
+ @Rule
+ public MojoTestName name = new MojoTestName();
+
+ @BeforeClass
+ public static void beforeClass() throws Exception {
+ log = new SystemStreamLog();
+ TestHelper.getBasedir();
+ }
+
+ @AfterClass
+ public static void afterClass() throws Exception {
+ testDir = null;
+ log = null;
+ }
+
+ protected abstract String getGoalName(String methodName);
+
+ protected File getPomFile(File testDir, String methodName, String goalName) {
+ File pom = new File(testDir, methodName + ".xml");
+
+ if (isVerbose()) {
+ log.info("getPomFile = " + TestHelper.getRelativePath(getBasedir(), pom));
+ }
+
+ return pom;
+ }
+
+ @SuppressWarnings("unchecked")
+ protected P createMojo(File pomFile, String goalName) throws Exception {
+ Mojo lookupMojo = TestHelper.lookupMojo(goalName, pomFile);
+ P mojo = (P) lookupMojo;
+ return mojo;
+ }
+
+ protected void setUpMojo(P mojo, File pomFile) throws Exception {
+
+ MavenProject project = mojo.getProject();
+ if (project == null) {
+
+// MavenProjectBuilder projectBuilder = (MavenProjectBuilder) delegate.getContainer().lookup(MavenProjectBuilder.ROLE);
+// ProjectBuilderConfiguration projectBuilderConfiguration = null;
+// 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 getBasedir() {
+ return TestHelper.getBasedir();
+ }
+
+ protected File getTestDir() {
+ if (testDir == null) {
+
+ String rep = getClass().getName();
+ rep = rep.replaceAll("\\.", File.separator);
+
+ File f = TestHelper.getFile(getBasedir(), "target", "test-classes");
+
+ testDir = new File(f, rep);
+ if (isVerbose()) {
+ log.info("test dir = " + TestHelper.getRelativePath(getBasedir(), testDir));
+ }
+ }
+ return testDir;
+ }
+
+ protected boolean isVerbose() {
+ return TestHelper.isVerbose();
+ }
+
+ public class MojoTestName extends TestName {
+
+ private File pomFile;
+ private P mojo;
+
+ public MojoTestName() {
+ if (log.isDebugEnabled()) {
+ log.debug("NEW MojotestName instance for " + AbstractMojoTest.this);
+ }
+ getTestDir();
+ }
+
+ @Override
+ public void starting(FrameworkMethod method) {
+ super.starting(method);
+
+ if (isVerbose()) {
+ log.info("==============================================================================================");
+ }
+ log.info("NEW Mojo test starting : " + AbstractMojoTest.this.getClass().getName() + "#" + getMethodName());
+ String goalName = getGoalName(name.getMethodName());
+
+ pomFile = AbstractMojoTest.this.getPomFile(getTestDir(), getMethodName(), goalName);
+
+ try {
+ Assert.assertTrue("could not find pom " + pomFile.getAbsoluteFile(), pomFile.exists());
+
+ mojo = createMojo(pomFile, goalName);
+
+ AbstractMojoTest.this.setUpMojo(mojo, pomFile);
+
+ } catch (Exception ex) {
+ throw new IllegalStateException("could not init test " + getClass() + " - " + getMethodName() + " for reason " + ex.getMessage(), ex);
+ }
+ }
+
+ @Override
+ public void finished(FrameworkMethod method) {
+ super.finished(method);
+ pomFile = null;
+ mojo = null;
+ }
+
+ public P getMojo() {
+ return mojo;
+ }
+
+ public File getPomFile() {
+ return pomFile;
+ }
+ }
+}
Property changes on: trunk/src/test/java/org/nuiton/plugin/AbstractMojoTest.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL
Added: trunk/src/test/java/org/nuiton/plugin/TestHelper.java
===================================================================
--- trunk/src/test/java/org/nuiton/plugin/TestHelper.java (rev 0)
+++ trunk/src/test/java/org/nuiton/plugin/TestHelper.java 2009-09-15 15:44:19 UTC (rev 573)
@@ -0,0 +1,113 @@
+package org.nuiton.plugin;
+
+import org.apache.maven.plugin.Mojo;
+import org.apache.maven.plugin.testing.AbstractMojoTestCase;
+import org.codehaus.plexus.PlexusContainer;
+import org.codehaus.plexus.PlexusTestCase;
+import java.io.File;
+import org.junit.Assert;
+
+/**
+ *
+ * @author chemit
+ * @since 1.0.3
+ */
+public abstract class TestHelper {
+
+ 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) {
+ String rep = type.getName();
+ rep = rep.replaceAll("\\.", File.separator);
+
+ File f = new File(getBasedir(), prefix);
+ File testDir = new File(f, rep);
+ 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 (TestHelper.delegateMojoTest == null) {
+ TestHelper.delegateMojoTest = new DelegateMojoTestCase();
+ TestHelper.delegateMojoTest.setUp();
+ }
+ return TestHelper.delegateMojoTest;
+ }
+
+ public static void setDelegateMojoTest(DelegateMojoTestCase delegateMojoTest) {
+ TestHelper.delegateMojoTest = delegateMojoTest;
+ }
+
+ public static File getFile(File base, String... paths) {
+ StringBuilder buffer = new StringBuilder();
+ for (String path : paths) {
+ buffer.append(File.separator).append(path);
+ }
+ File f = new File(base, buffer.substring(1));
+ return f;
+ }
+
+ public static String getRelativePath(File base, File file) {
+ String result = file.getAbsolutePath().substring(base.getAbsolutePath().length() + 1);
+ return result;
+ }
+
+ 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();
+ }
+ }
+}
Property changes on: trunk/src/test/java/org/nuiton/plugin/TestHelper.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL
Modified: trunk/src/test/java/org/nuiton/util/BasePluginTestCase.java
===================================================================
--- trunk/src/test/java/org/nuiton/util/BasePluginTestCase.java 2009-09-11 22:06:27 UTC (rev 572)
+++ trunk/src/test/java/org/nuiton/util/BasePluginTestCase.java 2009-09-15 15:44:19 UTC (rev 573)
@@ -35,11 +35,16 @@
import org.codehaus.plexus.PlexusTestCase;
import org.junit.Ignore;
import org.junit.Test;
-import org.nuiton.Plugin;
+import org.nuiton.plugin.Plugin;
/**
* @param <P> le mojo a test
- * @author chemit */
+ * @author chemit
+ *
+ * @deprecated since 1.0.3, prefer use the {@link AbstractMojoTest} which
+ * need no more annotation on each test method.
+ */
+@Deprecated
public abstract class BasePluginTestCase<P extends Plugin> {
protected static SystemStreamLog log;
Modified: trunk/src/test/java/org/nuiton/util/JavaFileUpdaterTest.java
===================================================================
--- trunk/src/test/java/org/nuiton/util/JavaFileUpdaterTest.java 2009-09-11 22:06:27 UTC (rev 572)
+++ trunk/src/test/java/org/nuiton/util/JavaFileUpdaterTest.java 2009-09-15 15:44:19 UTC (rev 573)
@@ -20,13 +20,11 @@
*/
package org.nuiton.util;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
import org.nuiton.util.FileUpdaterHelper.JavaFileUpdater;
import java.io.File;
import org.junit.BeforeClass;
import org.junit.Test;
+import org.nuiton.plugin.TestHelper;
import static org.junit.Assert.*;
/**
@@ -36,32 +34,20 @@
*/
public class JavaFileUpdaterTest {
- /** to use log facility, just put in your code: log.info(\"...\"); */
- static private final Log log = LogFactory.getLog(FileUpdaterHelper.class);
-
-
- static final char SEP = File.separatorChar;
-
static MirroredFileUpdater fileUpdater;
-
static File sourceFile;
static File mirrorFile;
@BeforeClass
public static void initClass() throws Exception {
- String basedir = System.getProperty("basedir");
- if (basedir == null) {
- log.warn("basedir not found, test is not executed from maven...");
- basedir = new File(new File("").getAbsolutePath()).getAbsolutePath();
- }
- log.info("basedir = " + basedir);
+ File basedir = TestHelper.getBasedir();
- File src = new File(basedir, "src" + SEP + "test" + SEP + "java");
- File dir = new File(basedir, "target" + SEP + "test-classes");
- fileUpdater = (MirroredFileUpdater) FileUpdaterHelper.newJavaFileUpdater(src, dir);
- log.info(fileUpdater);
+ File src = TestHelper.getFile(basedir, "src", "test", "java");
+ File dir = TestHelper.getFile(basedir, "target", "test-classes");
+ fileUpdater = FileUpdaterHelper.newJavaFileUpdater(src, dir);
+
// test source dir exists
File sourceDirectory = fileUpdater.getSourceDirectory();
assertTrue("sourcedir is null", sourceDirectory != null);
@@ -72,11 +58,11 @@
assertTrue("destinationDirectory is null", destinationDirectory != null);
assertTrue("destinationDirectory does not exists " + destinationDirectory, destinationDirectory.exists());
- sourceFile = new File(fileUpdater.getSourceDirectory(), "org" + SEP + "nuiton" + SEP + "util" + SEP + JavaDummy.class.getSimpleName() + ".java");
+ sourceFile = TestHelper.getFile(fileUpdater.getSourceDirectory(), "org", "nuiton", "util", JavaDummy.class.getSimpleName() + ".java");
}
-@Test
+ @Test
public void testSourceFileIsUptoDate() throws Exception {
assertTrue("fileUpdater was not init", fileUpdater != null);
@@ -89,7 +75,7 @@
mirrorFile = fileUpdater.getMirrorFile(sourceFile);
}
-@Test
+ @Test
public void testSourceFileDoesNotHaveMirrorFile() throws Exception {
assertTrue("fileUpdater was not init", fileUpdater != null);
@@ -112,7 +98,7 @@
assertTrue(sourceFile + " should be uptodate", fileUpdater.isFileUpToDate(sourceFile));
}
-@Test
+ @Test
public void testSourceFileIsNewerThanMirrorFile() throws Exception {
assertTrue("fileUpdater was not init", fileUpdater != null);
@@ -136,5 +122,4 @@
// java file is now up to date (rename method does not affect lasmodified property on a file)
assertTrue(sourceFile + " should be uptodate", fileUpdater.isFileUpToDate(sourceFile));
}
-
}
Modified: trunk/src/test/java/org/nuiton/util/JaxxFileUpdaterTest.java
===================================================================
--- trunk/src/test/java/org/nuiton/util/JaxxFileUpdaterTest.java 2009-09-11 22:06:27 UTC (rev 572)
+++ trunk/src/test/java/org/nuiton/util/JaxxFileUpdaterTest.java 2009-09-15 15:44:19 UTC (rev 573)
@@ -20,12 +20,10 @@
*/
package org.nuiton.util;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
import java.io.File;
import org.junit.BeforeClass;
import org.junit.Test;
+import org.nuiton.plugin.TestHelper;
import static org.junit.Assert.*;
/**
@@ -35,9 +33,6 @@
*/
public class JaxxFileUpdaterTest {
- /** to use log facility, just put in your code: log.info(\"...\"); */
- static private final Log log = LogFactory.getLog(FileUpdaterHelper.class);
- static final char SEP = File.separatorChar;
static MirroredFileUpdater fileUpdater;
static File sourceFile;
static File mirrorFile;
@@ -45,18 +40,11 @@
@BeforeClass
public static void initClass() throws Exception {
- String basedir = System.getProperty("basedir");
- if (basedir == null) {
- log.warn("basedir not found, test is not executed from maven...");
- basedir = new File(new File("").getAbsolutePath()).getAbsolutePath();
- }
+ File basedir = TestHelper.getBasedir();
- log.info("basedir = " + basedir);
-
- File src = new File(basedir, "src" + SEP + "test" + SEP + "resources");
- File dir = new File(basedir, "src" + SEP + "test" + SEP + "java");
+ File src = TestHelper.getFile(basedir, "src", "test", "resources");
+ File dir = TestHelper.getFile(basedir, "src", "test", "java");
fileUpdater = FileUpdaterHelper.newJaxxFileUpdater(src, dir);
- log.info(fileUpdater);
// test source dir exists
File sourceDirectory = fileUpdater.getSourceDirectory();
@@ -68,7 +56,7 @@
assertTrue("destinationDirectory is null", destinationDirectory != null);
assertTrue("destinationDirectory does not exists " + destinationDirectory, destinationDirectory.exists());
- sourceFile = new File(fileUpdater.getSourceDirectory(), "org" + SEP + "nuiton" + SEP + "util" + SEP + JaxxDummy.class.getSimpleName() + ".jaxx");
+ sourceFile = TestHelper.getFile(fileUpdater.getSourceDirectory(), "org", "nuiton", "util", JaxxDummy.class.getSimpleName() + ".jaxx");
}
Modified: trunk/src/test/java/org/nuiton/util/PluginConfig.java
===================================================================
--- trunk/src/test/java/org/nuiton/util/PluginConfig.java 2009-09-11 22:06:27 UTC (rev 572)
+++ trunk/src/test/java/org/nuiton/util/PluginConfig.java 2009-09-15 15:44:19 UTC (rev 573)
@@ -25,16 +25,19 @@
import java.lang.annotation.Target;
import java.lang.annotation.ElementType;
import java.lang.annotation.Inherited;
+import org.nuiton.plugin.AbstractMojoTest;
-/** @author chemit */
+/** @author chemit
+ * @deprecated since 1.0.3, prefer use the {@link AbstractMojoTest} which
+ * need no more annotation on each test method.
+ */
@Retention(RetentionPolicy.RUNTIME)
-
@Target(ElementType.METHOD)
@Inherited
+@Deprecated
public @interface PluginConfig {
String goalName();
String pomName();
-
}
1
0
Author: tchemit
Date: 2009-09-12 00:06:27 +0200 (Sat, 12 Sep 2009)
New Revision: 572
Modified:
trunk/pom.xml
Log:
bump maven-plugin-testing-harness (note: the groupId has changed)
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2009-09-09 21:41:40 UTC (rev 571)
+++ trunk/pom.xml 2009-09-11 22:06:27 UTC (rev 572)
@@ -77,9 +77,9 @@
<!-- tests dependencies -->
<dependency>
- <groupId>org.apache.maven.shared</groupId>
+ <groupId>org.apache.maven.plugin-testing</groupId>
<artifactId>maven-plugin-testing-harness</artifactId>
- <version>1.1</version>
+ <version>1.2</version>
<scope>test</scope>
</dependency>
1
0
r571 - in trunk/src: main/java/org/nuiton test/java/org/nuiton/util
by tchemit@users.nuiton.org 09 Sep '09
by tchemit@users.nuiton.org 09 Sep '09
09 Sep '09
Author: tchemit
Date: 2009-09-09 23:41:40 +0200 (Wed, 09 Sep 2009)
New Revision: 571
Added:
trunk/src/main/java/org/nuiton/Plugin.java
Modified:
trunk/src/main/java/org/nuiton/AbstractPlugin.java
trunk/src/test/java/org/nuiton/util/BasePluginTestCase.java
Log:
add a common contract Plugin for mojos and reports
Modified: trunk/src/main/java/org/nuiton/AbstractPlugin.java
===================================================================
--- trunk/src/main/java/org/nuiton/AbstractPlugin.java 2009-09-08 16:02:25 UTC (rev 570)
+++ trunk/src/main/java/org/nuiton/AbstractPlugin.java 2009-09-09 21:41:40 UTC (rev 571)
@@ -49,7 +49,7 @@
*
* @author chemit
*/
-public abstract class AbstractPlugin extends AbstractMojo {
+public abstract class AbstractPlugin extends AbstractMojo implements Plugin {
protected abstract boolean ensurePackaging();
@@ -102,14 +102,6 @@
}
}
- public abstract MavenProject getProject();
-
- public abstract void setProject(MavenProject project);
-
- public abstract boolean isVerbose();
-
- public abstract void setVerbose(boolean verbose);
-
/**
* Does the actual copy of the file and logging.
*
Added: trunk/src/main/java/org/nuiton/Plugin.java
===================================================================
--- trunk/src/main/java/org/nuiton/Plugin.java (rev 0)
+++ trunk/src/main/java/org/nuiton/Plugin.java 2009-09-09 21:41:40 UTC (rev 571)
@@ -0,0 +1,23 @@
+package org.nuiton;
+
+import org.apache.maven.plugin.Mojo;
+import org.apache.maven.project.MavenProject;
+
+/**
+ * A common contract to be implements by our mojo and reports.
+ *
+ * Just expose a {@link #isVerbose()} flag and the maven project {@link #getProject()}.
+ *
+ * @author chemit
+ * @since 1.0.3
+ */
+public interface Plugin extends Mojo {
+
+ MavenProject getProject();
+
+ void setProject(MavenProject project);
+
+ boolean isVerbose();
+
+ void setVerbose(boolean verbose);
+}
Property changes on: trunk/src/main/java/org/nuiton/Plugin.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL
Modified: trunk/src/test/java/org/nuiton/util/BasePluginTestCase.java
===================================================================
--- trunk/src/test/java/org/nuiton/util/BasePluginTestCase.java 2009-09-08 16:02:25 UTC (rev 570)
+++ trunk/src/test/java/org/nuiton/util/BasePluginTestCase.java 2009-09-09 21:41:40 UTC (rev 571)
@@ -35,12 +35,12 @@
import org.codehaus.plexus.PlexusTestCase;
import org.junit.Ignore;
import org.junit.Test;
-import org.nuiton.AbstractPlugin;
+import org.nuiton.Plugin;
/**
* @param <P> le mojo a test
* @author chemit */
-public abstract class BasePluginTestCase<P extends AbstractPlugin> {
+public abstract class BasePluginTestCase<P extends Plugin> {
protected static SystemStreamLog log;
protected static File basedir;
@@ -64,7 +64,7 @@
return testDir;
}
- protected static <P extends AbstractPlugin> void initConfigs(Class<? extends BasePluginTestCase<P>> klass, String... testNames) throws Exception {
+ protected static <P extends Plugin> void initConfigs(Class<? extends BasePluginTestCase<P>> klass, String... testNames) throws Exception {
log = new SystemStreamLog();
List<PluginConfig> configs = new ArrayList<PluginConfig>();
String rep = klass.getName();
@@ -73,7 +73,7 @@
File f = new File(getBaseDir(), "target" + File.separator + "test-classes");
//File f = new File(getBaseDir(), "src" + File.separator + "test" + File.separator + "resources");
testDir = new File(f, rep);
- log.info("test dir : " + testDir.getAbsolutePath().substring(getBaseDir().getAbsolutePath().length()+1));
+ log.info("test dir : " + testDir.getAbsolutePath().substring(getBaseDir().getAbsolutePath().length() + 1));
if (testNames.length == 0) {
1
0
r570 - in trunk/src: main/java/org/nuiton/io/xpp3 test/java/org/nuiton/util
by tchemit@users.nuiton.org 08 Sep '09
by tchemit@users.nuiton.org 08 Sep '09
08 Sep '09
Author: tchemit
Date: 2009-09-08 18:02:25 +0200 (Tue, 08 Sep 2009)
New Revision: 570
Modified:
trunk/src/main/java/org/nuiton/io/xpp3/AbstractXpp3Reader.java
trunk/src/main/java/org/nuiton/io/xpp3/PropertyMapper.java
trunk/src/main/java/org/nuiton/io/xpp3/Xpp3Helper.java
trunk/src/main/java/org/nuiton/io/xpp3/Xpp3Reader.java
trunk/src/test/java/org/nuiton/util/BasePluginTestCase.java
Log:
[FEATURE #46] ajout d'un contrat pour faire des parseurs xpp3
Modified: trunk/src/main/java/org/nuiton/io/xpp3/AbstractXpp3Reader.java
===================================================================
--- trunk/src/main/java/org/nuiton/io/xpp3/AbstractXpp3Reader.java 2009-09-07 22:54:20 UTC (rev 569)
+++ trunk/src/main/java/org/nuiton/io/xpp3/AbstractXpp3Reader.java 2009-09-08 16:02:25 UTC (rev 570)
@@ -3,10 +3,12 @@
import java.beans.IntrospectionException;
import java.io.IOException;
import java.io.Reader;
+import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
+import java.util.Set;
import java.util.TreeMap;
import org.codehaus.plexus.util.xml.pull.MXParser;
import org.codehaus.plexus.util.xml.pull.XmlPullParser;
@@ -22,20 +24,22 @@
* The logic of setting properties from xml (tag and attributes) is done in
*
* <ul>
- * <li>{@link #read(org.codehaus.plexus.util.xml.pull.XmlPullParser, boolean)} </li>
- * <li>{@link #readArray(org.codehaus.plexus.util.xml.pull.XmlPullParser, boolean)} </li>
+ * <li>{@link #read(String, Class, org.codehaus.plexus.util.xml.pull.XmlPullParser, boolean)} </li>
+ * <li>{@link #readArray(String, String, Class, org.codehaus.plexus.util.xml.pull.XmlPullParser, boolean)}</li>
* </ul>
*
* The default implementation is to map tag text to a pojo's property.
*
* If you want to do something more complex, override these methods.
*
+ * @param <O> the type of object to be build by the reader
+ *
* @author chemit
* @since 1.0.0
* @see PropertyMapper
* @see Xpp3Reader
*/
-public abstract class AbstractXpp3Reader implements Xpp3Reader {
+public abstract class AbstractXpp3Reader<O> implements Xpp3Reader<O> {
/**
* If set the parser will be loaded with all single characters
@@ -51,13 +55,17 @@
/**
* the type of the object to produce from the xml streams.
*/
- protected final Class<?> type;
+ protected final Class<O> type;
/**
* the root tag of an object to retreave from xml streams.
*
*/
- protected final String rootTagName;
+ protected String rootTagName;
/**
+ * the root tag of an array of objets to retreave from xml streams.
+ */
+ protected String arrayRootTagName;
+ /**
* the univers of mappers availables, initialized in {@link #initMappers()}.
*
* Each mapper of the dictionary is associated to the fully qualified name
@@ -69,18 +77,22 @@
* org.nuiton.util.MyPojo#my-attribute
* </pre>
*/
- protected final Map<String, PropertyMapper> allMappers;
- /**
- * a flag to display in console the generated code :
- * an easy way to build to generate java pojos mocks from xml file (to test the parser for example :)
- */
- protected boolean showGeneratedCode;
+ protected Map<String, PropertyMapper> allMappers;
protected abstract void initMappers() throws IntrospectionException;
- protected AbstractXpp3Reader(Class<?> type, String rootTagName) {
+ protected AbstractXpp3Reader(Class<O> type) {
+ this(type, null, null);
+ }
+
+ protected AbstractXpp3Reader(Class<O> type, String rootTagName) {
+ this(type, null, rootTagName);
+ }
+
+ protected AbstractXpp3Reader(Class<O> type, String arrayRootTagName, String rootTagName) {
this.type = type;
this.rootTagName = rootTagName;
+ this.arrayRootTagName = arrayRootTagName;
this.allMappers = new TreeMap<String, PropertyMapper>();
try {
initMappers();
@@ -90,29 +102,33 @@
}
@Override
- public Class<?> getType() {
+ public Class<O> getType() {
return type;
}
+ @Override
public String getRootTagName() {
return rootTagName;
}
- public String getArrayRootTagName() {
- return rootTagName + "s";
+ @Override
+ public void setRootTagName(String rootTagName) {
+ this.rootTagName = rootTagName;
}
@Override
- public boolean isAddDefaultEntities() {
- return addDefaultEntities;
+ public String getArrayRootTagName() {
+ return arrayRootTagName;
}
- public boolean isShowGeneratedCode() {
- return showGeneratedCode;
+ @Override
+ public void setParentRootTagName(String parentRootTagName) {
+ this.arrayRootTagName = parentRootTagName;
}
- public void setShowGeneratedCode(boolean showGeneratedCode) {
- this.showGeneratedCode = showGeneratedCode;
+ @Override
+ public boolean isAddDefaultEntities() {
+ return addDefaultEntities;
}
@Override
@@ -121,12 +137,12 @@
}
@Override
- public Object read(Reader reader) throws IOException, XmlPullParserException {
+ public O read(Reader reader) throws IOException, XmlPullParserException {
return read(reader, true);
}
@Override
- public Object read(Reader reader, boolean strict) throws IOException, XmlPullParserException {
+ public O read(Reader reader, boolean strict) throws IOException, XmlPullParserException {
XmlPullParser parser = new MXParser();
parser.setInput(reader);
@@ -138,16 +154,26 @@
}
parser.next();
- return read(parser, strict);
+
+ // read the first open tag getRootTagName() and consume the matching ending tag
+ O result = read(getRootTagName(), getType(), parser, strict);
+
+ // go after the ending tag getRootTagName()
+ parser.next();
+
+ // must be at the end of the document
+ checkEndOfXml(parser);
+
+ return result;
}
@Override
- public Object[] readArray(Reader reader) throws IOException, XmlPullParserException {
+ public O[] readArray(Reader reader) throws IOException, XmlPullParserException {
return readArray(reader, true);
}
@Override
- public Object[] readArray(Reader reader, boolean strict) throws IOException, XmlPullParserException {
+ public O[] readArray(Reader reader, boolean strict) throws IOException, XmlPullParserException {
XmlPullParser parser = new MXParser();
parser.setInput(reader);
@@ -155,11 +181,19 @@
if (addDefaultEntities) {
Xpp3Helper.addDefaultEntities(parser);
-
}
parser.next();
- return readArray(parser, strict);
+
+ parser.getEventType();
+
+ O[] result = readArray(getArrayRootTagName(), getRootTagName(), getType(), parser, strict);
+
+ parser.next();
+
+ checkEndOfXml(parser);
+
+ return result;
}
/**
@@ -194,57 +228,78 @@
*
* No work is done on attribute values here.
*
- * Note: The xml stream must contains one object to build on the root node.
- *
- * the root node name is given by <code>getRootTagName()</code>
+ * Note: The parser must accept as a next open tag the required one .
*
+ * the next node name is given by <code>getRootTagName()</code>
+ *
* Example :
* <pre>
+ * ...
* <my-pojo>
* <my-property>myValue</my-property>
* </my-pojo>
* </pre>
- *
+ *
+ * @param <T> the type of object to build
+ * @param rootTagName the name of the root tag matching the object to build
+ * @param type the type of object to build
* @param parser the xpp3 parser
* @param strict flag to indicate if should fail if a unknown tag (or attribute ?) is scanned
* @return the single object build from the xml stream.
* @throws IOException if any io pb
* @throws XmlPullParserException if any parsing pb
*/
- protected Object read(XmlPullParser parser, boolean strict) throws IOException, XmlPullParserException {
+ protected <T> T read(String rootTagName, Class<T> type, XmlPullParser parser, boolean strict) throws XmlPullParserException, IOException {
- Object result;
+ // search open tag rootTagName
+ gotoNextOpenTag(rootTagName, parser);
+
+ // can init result
+ T result = null;
try {
- result = getType().newInstance();
+ result = type.newInstance();
} catch (Exception ex) {
// should never happens!
throw new RuntimeException("could not instanciate a new " + getType().getName() + " for reason : " + ex.getMessage(), ex);
}
- java.util.Set<String> parsed = new java.util.HashSet<String>();
- int eventType = parser.getEventType();
- boolean foundRoot = false;
+ // prepare alvailable mappers for the given type
+ Map<String, PropertyMapper> mappers = getMappers(type);
- Map<String, PropertyMapper> mappers = getMappers(getType());
- if (showGeneratedCode) {
- System.out.println(getType().getName() + " i = new " + getType().getSimpleName() + "();");
- }
- while (eventType != XmlPullParser.END_DOCUMENT) {
- if (eventType == XmlPullParser.START_TAG) {
- if (parser.getName().equals(rootTagName)) {
- foundRoot = true;
- } else {
+ Set<String> parsed = parsed = new java.util.HashSet<String>();
+ try {
+ // go to next tag
+ int eventType = parser.next();
+
+ while (true) {
+
+ checkNotEndOfXml(parser, rootTagName);
+
+ if (eventType == XmlPullParser.START_TAG) {
+// System.out.println("reading tag " + parser.getName());
PropertyMapper mapper = mappers.get(parser.getName());
if (mapper != null) {
mapper.setProperty(result, parser, parsed, strict);
} else if (strict) {
throw new XmlPullParserException("Unrecognised tag: '" + parser.getName() + "'", parser, null);
}
+ } else if (eventType == XmlPullParser.END_TAG) {
+ if (parser.getName().equals(rootTagName)) {
+ // have reach the end of the object
+ break;
+ }
}
+
+ // try next event
+ eventType = parser.next();
}
- eventType = parser.next();
+ return result;
+ } finally {
+ parsed.clear();
+ if (mappers != null) {
+ mappers.clear();
+ }
}
- return result;
}
/**
@@ -254,14 +309,12 @@
*
* No work is done on attribute values here.
*
- * Note: The xml stream must contains a root node.
+ * Note: The next node of the parser must be the one given by
+ * {@code parentRootTagName} and sub nodes with names {@code rootTagName}.
*
- * the root node name is given by <code>getArrayRootTagName()</code>
- *
- * and sub nodes with names <code>getRootTagName()</code>
- *
* Example :
* <pre>
+ * ...
* <my-pojos>
* <my-pojo>
* <my-property>myValue</my-property>
@@ -272,67 +325,117 @@
* </my-pojos>
* </pre>
*
+ * @param <T> the type of objects to build
+ * @param parentRootTagName the tag's name of the array container
+ * @param rootTagName the tag's name of each object to build
+ * @param type the type of objects to build
* @param parser the xpp3 parser
* @param strict flag to indicate if should fail if a unknown tag (or attribute ?) is scanned
* @return the single object build from the xml stream.
* @throws IOException if any io pb
* @throws XmlPullParserException if any parsing pb
*/
- protected Object[] readArray(XmlPullParser parser, boolean strict) throws IOException, XmlPullParserException {
+ protected <T> T[] readArray(String parentRootTagName, String rootTagName, Class<T> type, XmlPullParser parser, boolean strict) throws XmlPullParserException, IOException {
- List<Object> results = new ArrayList<Object>();
+ // search open tag parentRootTagName
+ // if not found, will raise an parsing exception
+ gotoNextOpenTag(parentRootTagName, parser);
+ // can init result
+ List<T> results = new ArrayList<T>();
- java.util.Set<String> parsed = new java.util.HashSet<String>();
- int eventType = parser.getEventType();
- boolean foundRoot = false;
+ boolean addChild = false;
+ boolean quit = false;
- Map<String, PropertyMapper> mappers = getMappers(getType());
- Object result = null;
- String root = getArrayRootTagName();
- if (showGeneratedCode) {
- System.out.println(getType().getSimpleName() + " i = null;");
- }
- while (eventType != XmlPullParser.END_DOCUMENT) {
- if (eventType == XmlPullParser.START_TAG) {
- if (parser.getName().equals(root)) {
- foundRoot = true;
- if (showGeneratedCode) {
- System.out.println("List<" + getType().getSimpleName() + "> list = new ArrayList<" + getType().getSimpleName() + ">();");
- }
- } else if (parser.getName().equals(this.rootTagName)) {
- try {
- result = getType().newInstance();
- if (showGeneratedCode) {
- System.out.println("i = new " + getType().getSimpleName() + "();");
- }
- } catch (Exception ex) {
- // should never happens!
- throw new RuntimeException("could not instanciate a new " + getType().getName() + " for reason : " + ex.getMessage(), ex);
- }
+ while (!quit) {
- } else {
- PropertyMapper mapper = mappers.get(parser.getName());
- if (mapper != null) {
- mapper.setProperty(result, parser, parsed, strict);
+ addChild = false;
+ quit = false;
- } else if (strict) {
- throw new XmlPullParserException("Unrecognised tag: '" + parser.getName() + "'", parser, null);
- }
+ // search next opening tag (rootTagName) or ending tag (parentRootTagName)
+
+ while (true) {
+
+ checkNotEndOfXml(parser, parentRootTagName);
+
+ int eventType = parser.getEventType();
+
+ if (eventType == XmlPullParser.START_TAG && rootTagName.equals(parser.getName())) {
+ // there is a child to read
+ addChild = true;
+ break;
}
- } else if (eventType == XmlPullParser.END_TAG) {
- if (parser.getName().equals(this.rootTagName)) {
- // save it
- results.add(result);
- // clear parsed attributes
- parsed.clear();
- if (showGeneratedCode) {
- System.out.println("list.add(i);");
- }
+
+ if (eventType == XmlPullParser.END_TAG && parentRootTagName.equals(parser.getName())) {
+ // can quit main loop, end of work
+ quit = true;
+ break;
}
+
+ eventType = parser.next();
}
+
+ if (addChild) {
+
+ // find an object to add
+ T result = read(rootTagName, type, parser, strict);
+
+ results.add(result);
+
+ // go for another round
+ continue;
+ }
+
+ // no more child
+ // must be at the end of tag
+ if (!quit) {
+ throw new XmlPullParserException("should be on " + parentRootTagName + " but was not : " + parser.getName());
+ }
+ }
+
+ // can not directly instanciate a generic array (or don't known how ?)
+ return results.toArray((T[]) Array.newInstance(type, results.size()));
+ }
+
+ protected int gotoNextOpenTag(String tagName, XmlPullParser parser) throws XmlPullParserException, IOException {
+ // search next open tag tagName
+
+ int eventType = parser.getEventType();
+
+ while (eventType != XmlPullParser.START_TAG || !parser.getName().equals(tagName)) {
+
+ checkNotEndOfXml(parser, tagName);
+
eventType = parser.next();
}
- return results.toArray(new Object[results.size()]);
+
+ return eventType;
}
+
+ /**
+ * Checks that a given parser is not at the end of the xml document.
+ *
+ * @param parser the parser to check
+ * @param tagName the endign tag's name
+ * @throws XmlPullParserException if the parser is at the end of the xml stream, instead of the {@code tagName} ending tag
+ */
+ protected void checkNotEndOfXml(XmlPullParser parser, String tagName) throws XmlPullParserException {
+ if (parser.getEventType() == XmlPullParser.END_DOCUMENT) {
+ // can not be here ?
+ throw new XmlPullParserException("end of document found... but required at least the ending tag " + tagName);
+ }
+ }
+
+ /**
+ * Checks that a given parser is at the end of the xml document.
+ *
+ * @param parser the parser to check
+ * @throws XmlPullParserException if the parser is not at the end of the xml stream.
+ */
+ protected void checkEndOfXml(XmlPullParser parser) throws XmlPullParserException {
+ // must be at the end of the document
+ if (parser.getEventType() != XmlPullParser.END_DOCUMENT) {
+ throw new XmlPullParserException("should be at the end of document but was not... : " + parser.getName());
+ }
+ }
}
Modified: trunk/src/main/java/org/nuiton/io/xpp3/PropertyMapper.java
===================================================================
--- trunk/src/main/java/org/nuiton/io/xpp3/PropertyMapper.java 2009-09-07 22:54:20 UTC (rev 569)
+++ trunk/src/main/java/org/nuiton/io/xpp3/PropertyMapper.java 2009-09-08 16:02:25 UTC (rev 570)
@@ -4,6 +4,7 @@
import java.io.IOException;
import java.text.ParseException;
import java.util.Set;
+import org.apache.commons.lang.builder.ToStringBuilder;
import org.codehaus.plexus.util.xml.pull.XmlPullParser;
import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
@@ -16,6 +17,13 @@
* <li>{@link TagTextContentToProperty} to map the text content of a tag to a pojo's property</li>
* <li>{@link AttributeValueToProperty} to map the text content of a tag to a pojo's property</li>
* </ul>
+ *
+ * There is two convinient factory methods in {@link Xpp3Helper} to add some new mappers into a given
+ * dictionnary of mappers.
+ * <ul>
+ * <li> {@link Xpp3Helper#addTagTextContentMappers(Class, org.nuiton.io.xpp3.DataConverter, boolean, java.util.Map, String[])}</li>
+ * <li>{@link Xpp3Helper#addAttributeValueMappers(Class, org.nuiton.io.xpp3.DataConverter, boolean, java.util.Map, String[])}</li>
+ * </ul>
*
* @author chemit
* @since 1.0.3
@@ -24,8 +32,8 @@
public static class TagTextContentToProperty extends PropertyMapper {
- public TagTextContentToProperty(String tagName, String propertyName, DataConverter type, boolean onlyOne, PropertyDescriptor descriptor) {
- super(tagName, propertyName, type, onlyOne, descriptor);
+ public TagTextContentToProperty(String tagName, String propertyName, Class<?> containerType, DataConverter type, boolean onlyOne, PropertyDescriptor descriptor) {
+ super(tagName, propertyName, containerType, type, onlyOne, descriptor);
}
@Override
@@ -41,8 +49,8 @@
public static class AttributeValueToProperty extends PropertyMapper {
- public AttributeValueToProperty(String tagName, String propertyName, DataConverter type, boolean onlyOne, PropertyDescriptor descriptor) {
- super(tagName, propertyName, type, onlyOne, descriptor);
+ public AttributeValueToProperty(String tagName, String propertyName, Class<?> containerType, DataConverter type, boolean onlyOne, PropertyDescriptor descriptor) {
+ super(tagName, propertyName, containerType, type, onlyOne, descriptor);
}
@Override
@@ -68,6 +76,10 @@
*/
protected final DataConverter type;
/**
+ * the type of the pojo container of the property
+ */
+ protected final Class<?> containerType;
+ /**
* the pojo's property descriptor
*/
protected final PropertyDescriptor descriptor;
@@ -77,11 +89,12 @@
*/
protected final boolean onlyOne;
- protected PropertyMapper(String tagName, String propertyName, DataConverter type, boolean onlyOne, PropertyDescriptor descriptor) {
+ protected PropertyMapper(String tagName, String propertyName, Class<?> containerType, DataConverter type, boolean onlyOne, PropertyDescriptor descriptor) {
this.name = tagName;
this.propertyName = propertyName;
this.type = type;
this.onlyOne = onlyOne;
+ this.containerType = containerType;
this.descriptor = descriptor;
}
@@ -131,4 +144,23 @@
public DataConverter getType() {
return type;
}
+
+ public Class<?> getContainerType() {
+ return containerType;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ @Override
+ public String toString() {
+ ToStringBuilder toStringBuilder = new ToStringBuilder(this);
+ toStringBuilder.append("name", name);
+ toStringBuilder.append("propertyName", propertyName);
+ toStringBuilder.append("onlyOne", onlyOne);
+ toStringBuilder.append("type", type);
+ toStringBuilder.append("containerType", containerType);
+ return toStringBuilder.toString();
+ }
}
Modified: trunk/src/main/java/org/nuiton/io/xpp3/Xpp3Helper.java
===================================================================
--- trunk/src/main/java/org/nuiton/io/xpp3/Xpp3Helper.java 2009-09-07 22:54:20 UTC (rev 569)
+++ trunk/src/main/java/org/nuiton/io/xpp3/Xpp3Helper.java 2009-09-08 16:02:25 UTC (rev 570)
@@ -1,5 +1,9 @@
package org.nuiton.io.xpp3;
+import java.beans.BeanInfo;
+import java.beans.IntrospectionException;
+import java.beans.Introspector;
+import java.beans.PropertyDescriptor;
import org.codehaus.plexus.util.IOUtil;
import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
@@ -7,11 +11,16 @@
import java.io.Reader;
import java.io.StringReader;
import java.io.StringWriter;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.ServiceLoader;
+import org.apache.commons.lang.StringUtils;
import org.codehaus.plexus.util.xml.pull.XmlPullParser;
+import org.nuiton.io.xpp3.PropertyMapper.AttributeValueToProperty;
+import org.nuiton.io.xpp3.PropertyMapper.TagTextContentToProperty;
/**
* A Helper to read some data stored in xml with a {@link Xpp3Reader}.
@@ -29,20 +38,21 @@
* les readers enregistres via un {@link ServiceLoader}
* sur le contrat {@link Xpp3Reader}.
*/
- protected static Map<Class<?>, Xpp3Reader> readers;
+ protected static Map<Class<?>, Xpp3Reader<?>> readers;
/**
* Read a single object from a xml stream.
*
+ * @param <O> the type of object to read
* @param klass the type of object to read
* @param reader the reader where to parse the xml
* @return the loaded object
* @throws IOException if any io pb
* @throws XmlPullParserException if any parsing pb
*/
- public static Object readObject(Class<?> klass, Reader reader) throws IOException, XmlPullParserException {
+ public static <O> O readObject(Class<O> klass, Reader reader) throws IOException, XmlPullParserException {
- Object result = null;
+ O result = null;
try {
@@ -54,7 +64,7 @@
StringReader sReader = new StringReader(rawInput);
- Xpp3Reader modelReader = getReader(klass);
+ Xpp3Reader<O> modelReader = getReader(klass);
result = modelReader.read(sReader);
@@ -68,15 +78,16 @@
/**
* Read an array of objects from a xml stream.
*
+ * @param <O> the type of objects to return
* @param klass the type of object to read
* @param reader the reader where to parse the xml
* @return the loaded objects
* @throws IOException if any io pb
* @throws XmlPullParserException if any parsing pb
*/
- public static Object[] readObjects(Class<?> klass, Reader reader) throws IOException, XmlPullParserException {
+ public static <O> O[] readObjects(Class<O> klass, Reader reader) throws IOException, XmlPullParserException {
- Object[] result = null;
+ O[] result = null;
try {
@@ -88,7 +99,7 @@
StringReader sReader = new StringReader(rawInput);
- Xpp3Reader modelReader = getReader(klass);
+ Xpp3Reader<O> modelReader = getReader(klass);
result = modelReader.readArray(sReader);
@@ -103,7 +114,7 @@
*
* @return an iterator on all registred {@link Xpp3Reader}.
*/
- public static Iterator<Xpp3Reader> getReaderItetator() {
+ public static Iterator<Xpp3Reader<?>> getReaderItetator() {
return getReaders().values().iterator();
}
@@ -115,8 +126,8 @@
* @param klass the type of the data which should be parsed by the researched parser
* @return the parser for the given type
*/
- public static <T> Xpp3Reader getReader(Class<?> klass) {
- Xpp3Reader reader = getReaders().get(klass);
+ public static <T> Xpp3Reader<T> getReader(Class<T> klass) {
+ Xpp3Reader<T> reader = (Xpp3Reader<T>) getReaders().get(klass);
return reader;
}
@@ -405,17 +416,72 @@
parser.defineEntityReplacementText("diams", "\u2666");
}
+ public static void addTagTextContentMappers(Class<?> containerType, DataConverter type, boolean onlyOne, Map<String, PropertyMapper> allMappers, String... tagNames) throws IntrospectionException {
+ try {
+ addMappers(TagTextContentToProperty.class, containerType, type, onlyOne, allMappers, tagNames);
+ } catch (Exception ex) {
+ throw new RuntimeException("could not addMappers for reason : " + ex.getMessage(), ex);
+ }
+ }
+
+ public static void addAttributeValueMappers(Class<?> containerType, DataConverter type, boolean onlyOne, Map<String, PropertyMapper> allMappers, String... tagNames) throws IntrospectionException {
+ try {
+ addMappers(AttributeValueToProperty.class, containerType, type, onlyOne, allMappers, tagNames);
+ } catch (Exception ex) {
+ throw new RuntimeException("could not addMappers for reason : " + ex.getMessage(), ex);
+ }
+ }
+
+ protected static void addMappers(Class<? extends PropertyMapper> mapperClass, Class<?> containerType, DataConverter type, boolean onlyOne, Map<String, PropertyMapper> allMappers, String... tagNames) throws IntrospectionException, NoSuchMethodException, InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
+ for (String tagName : tagNames) {
+
+ // the tag-name is transformed to tagName
+ String[] parts = tagName.split("-");
+ StringBuilder buffer = new StringBuilder();
+ for (int i = 0, j = parts.length; i < j; i++) {
+ if (i == 0) {
+ buffer.append(parts[i]);
+ } else {
+ buffer.append(StringUtils.capitalize(parts[i]));
+ }
+ }
+ String propertyName = buffer.toString();
+ BeanInfo beanInfo = Introspector.getBeanInfo(containerType);
+ PropertyDescriptor descriptor = null;
+ for (PropertyDescriptor propertyDescriptor : beanInfo.getPropertyDescriptors()) {
+ if (propertyDescriptor.getName().equals(propertyName)) {
+ descriptor = propertyDescriptor;
+ break;
+ }
+ }
+ if (descriptor == null) {
+ throw new IllegalArgumentException("could not find a property descriptor for property " + propertyName + " of " + containerType);
+ }
+ Constructor<? extends PropertyMapper> constructor = mapperClass.getConstructor(String.class, String.class, Class.class, DataConverter.class, boolean.class, PropertyDescriptor.class);
+
+ PropertyMapper mapper = constructor.newInstance(tagName, propertyName, containerType, type, onlyOne, descriptor);
+// System.out.println("adding a mapper " + mapper);
+
+ allMappers.put(containerType.getName() + "#" + tagName, mapper);
+ }
+ }
+
/**
+ * Load (if {@link #readers} is {@code null} the readers via a
+ * {@link ServiceLoader} of contract {@link Xpp3Reader} and returns
+ * the dictionnary of discovered associated to their type
+ * ({@link Xpp3Reader#getType()}).
*
+ *
* @return all the {@link Xpp3Reader} registred via a {@link ServiceLoader}
- * on the contract {@link Xpp3Reader}.
+ * on the contract {@link Xpp3Reader} associated to their type
+ * ({@link Xpp3Reader#getType()}).
*
*/
- protected static Map<Class<?>, Xpp3Reader> getReaders() {
+ protected static Map<Class<?>, Xpp3Reader<?>> getReaders() {
if (readers == null) {
- readers = new HashMap<Class<?>, Xpp3Reader>();
- ServiceLoader<Xpp3Reader> load = ServiceLoader.load(Xpp3Reader.class);
- for (Xpp3Reader r : load) {
+ readers = new HashMap<Class<?>, Xpp3Reader<?>>();
+ for (Xpp3Reader<?> r : ServiceLoader.load(Xpp3Reader.class)) {
readers.put(r.getType(), r);
}
}
Modified: trunk/src/main/java/org/nuiton/io/xpp3/Xpp3Reader.java
===================================================================
--- trunk/src/main/java/org/nuiton/io/xpp3/Xpp3Reader.java 2009-09-07 22:54:20 UTC (rev 569)
+++ trunk/src/main/java/org/nuiton/io/xpp3/Xpp3Reader.java 2009-09-08 16:02:25 UTC (rev 570)
@@ -2,7 +2,6 @@
import java.io.IOException;
import java.io.Reader;
-import org.codehaus.plexus.util.ReaderFactory;
import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
/**
@@ -17,73 +16,147 @@
*
* to make possible auto-discovering of availables reader at runtime.
*
- * See {@link Xpp3Helper#getReader(java.lang.Class)}.
+ * See {@link Xpp3Helper#getReader(java.lang.Class)} and
+ * {@link Xpp3Helper#getReaders()}.
*
*
+ * @param <O> the type of object to be build by the reader.
+ *
* @author chemit
* @since 1.0.3
*/
-public interface Xpp3Reader {
+public interface Xpp3Reader<O> {
/**
*
* @return the type of main object to read
*/
- Class<?> getType();
+ Class<O> getType();
/**
- * @see ReaderFactory#newXmlReader
+ * Read a single instance of the typed object and return it.
*
+ * Note : this is a convinient method to call
+ * {@link #read(java.io.Reader, boolean)} in strict mode.
+ *
+ * In the xml stream, the root tag must be the {@link #getRootTagName()}.
+ *
+ * Example :
+ * <pre>
+ * <issue>:
+ * ...
+ * </issue>:
+ * </pre>
+ *
* @param reader
* @throws IOException
* @throws XmlPullParserException
* @return Settings
*/
- Object read(Reader reader) throws IOException, XmlPullParserException;
+ O read(Reader reader) throws IOException, XmlPullParserException;
/**
- * @see ReaderFactory#newXmlReader
+ * Read a single instance of the typed object and return it.
*
- * @param reader
- * @param strict
- * @throws IOException
- * @throws XmlPullParserException
- * @return Settings
+ * In the xml stream, the root tag must be the {@link #getRootTagName()}.
+ *
+ * Example :
+ * <pre>
+ * <issue>:
+ * ...
+ * </issue>:
+ * </pre>
+ *
+ * @param reader the xml input reader
+ * @param strict flag to be strict while parsing
+ * @throws IOException if any io pb
+ * @throws XmlPullParserException if any parsing pb
+ * @return the
*/
- Object read(Reader reader, boolean strict) throws IOException, XmlPullParserException;
+ O read(Reader reader, boolean strict) throws IOException, XmlPullParserException;
/**
- * @see ReaderFactory#newXmlReader
+ * Read some instances of the typed object and return it.
*
- * @param reader
- * @throws IOException
- * @throws XmlPullParserException
- * @return Settings
+ * In the xml stream, the root tag must be the {@link #getArrayRootTagName()}.
+ *
+ * Note : this is a convinient method to call :
+ * {@link #readArray(java.io.Reader, boolean)} in stritc mode.
+ *
+ * Example :
+ * <pre>
+ * <issues>:
+ * <issue>:
+ * ...
+ * </issue>:
+ * </issues>:
+ * </pre>
+ *
+ * @param reader the xml input reader
+ * @throws IOException if any io pb
+ * @throws XmlPullParserException if any parsing pb
+ * @return the array of read objects.
*/
- Object[] readArray(Reader reader) throws IOException, XmlPullParserException;
+ O[] readArray(Reader reader) throws IOException, XmlPullParserException;
/**
- * @see ReaderFactory#newXmlReader
+ * Read some instances of the typed object and return it.
*
- * @param reader
- * @param strict
- * @throws IOException
- * @throws XmlPullParserException
- * @return Settings
+ * In the xml stream, the root tag must be the {@link #getArrayRootTagName()}.
+ *
+ * Example :
+ * <pre>
+ * <issues>:
+ * <issue>:
+ * ...
+ * </issue>:
+ * </issues>:
+ * </pre>
+ *
+ * @param reader the xml input reader
+ * @param strict flag to be strict while parsing
+ * @throws IOException if any io pb
+ * @throws XmlPullParserException if any parsing pb
+ * @return the array of read objects.
*/
- Object[] readArray(Reader reader, boolean strict) throws IOException, XmlPullParserException;
+ O[] readArray(Reader reader, boolean strict) throws IOException, XmlPullParserException;
/**
- * Returns the state of the "add default entities" flag.
*
- * @return boolean
+ * @return the name of the root tag of a object to read
*/
+ String getRootTagName();
+
+ /**
+ * Set the name of the root tag of an object to read.
+ *
+ * @param rootTagName the name of the tag
+ */
+ void setRootTagName(String rootTagName);
+
+ /**
+ *
+ * @return the name of the root tag of an array of objets to read
+ */
+ String getArrayRootTagName();
+
+ /**
+ * Set the name of the root tag for an array of object to read.
+ *
+ * @param parentRootTagName the name of the tag
+ */
+ void setParentRootTagName(String parentRootTagName);
+
+ /**
+ * @return <code>true</code> if parser will load the default entities,
+ * <code>false</code> otherwise.
+ */
boolean isAddDefaultEntities();
/**
- * Sets the state of the "add default entities" flag.
+ * Set the new value of the {@code defaultEntities} flag.
*
- * @param addDefaultEntities
+ * @param addDefaultEntities the new value.
*/
void setAddDefaultEntities(boolean addDefaultEntities);
}
Modified: trunk/src/test/java/org/nuiton/util/BasePluginTestCase.java
===================================================================
--- trunk/src/test/java/org/nuiton/util/BasePluginTestCase.java 2009-09-07 22:54:20 UTC (rev 569)
+++ trunk/src/test/java/org/nuiton/util/BasePluginTestCase.java 2009-09-08 16:02:25 UTC (rev 570)
@@ -30,6 +30,7 @@
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
+import org.apache.maven.plugin.logging.SystemStreamLog;
import org.apache.maven.project.MavenProject;
import org.codehaus.plexus.PlexusTestCase;
import org.junit.Ignore;
@@ -41,6 +42,7 @@
* @author chemit */
public abstract class BasePluginTestCase<P extends AbstractPlugin> {
+ protected static SystemStreamLog log;
protected static File basedir;
protected static File testDir;
protected static Iterator<PluginConfig> configItr;
@@ -63,6 +65,7 @@
}
protected static <P extends AbstractPlugin> void initConfigs(Class<? extends BasePluginTestCase<P>> klass, String... testNames) throws Exception {
+ log = new SystemStreamLog();
List<PluginConfig> configs = new ArrayList<PluginConfig>();
String rep = klass.getName();
rep = rep.replaceAll("\\.", File.separator);
@@ -70,7 +73,7 @@
File f = new File(getBaseDir(), "target" + File.separator + "test-classes");
//File f = new File(getBaseDir(), "src" + File.separator + "test" + File.separator + "resources");
testDir = new File(f, rep);
- System.out.println("test dir : " + testDir);
+ log.info("test dir : " + testDir.getAbsolutePath().substring(getBaseDir().getAbsolutePath().length()+1));
if (testNames.length == 0) {
@@ -85,8 +88,8 @@
if (annotation != null) {
Test t = m.getAnnotation(Test.class);
if (t != null) {
- Ignore i = m.getAnnotation(Ignore.class);
- if (i==null) {
+ Ignore i = m.getAnnotation(Ignore.class);
+ if (i == null) {
testNamesList.add(m.getName());
}
}
1
0
r569 - in trunk: . src/main/java/org/nuiton src/main/java/org/nuiton/io src/main/java/org/nuiton/io/xpp3
by tchemit@users.nuiton.org 07 Sep '09
by tchemit@users.nuiton.org 07 Sep '09
07 Sep '09
Author: tchemit
Date: 2009-09-08 00:54:20 +0200 (Tue, 08 Sep 2009)
New Revision: 569
Added:
trunk/src/main/java/org/nuiton/io/
trunk/src/main/java/org/nuiton/io/xpp3/
trunk/src/main/java/org/nuiton/io/xpp3/AbstractXpp3Reader.java
trunk/src/main/java/org/nuiton/io/xpp3/DataConverter.java
trunk/src/main/java/org/nuiton/io/xpp3/PropertyMapper.java
trunk/src/main/java/org/nuiton/io/xpp3/Xpp3Helper.java
trunk/src/main/java/org/nuiton/io/xpp3/Xpp3Reader.java
Modified:
trunk/changelog.txt
Log:
[FEATURE #46] ajout d'un contrat pour faire des parseurs xpp3
Modified: trunk/changelog.txt
===================================================================
--- trunk/changelog.txt 2009-09-06 20:27:59 UTC (rev 568)
+++ trunk/changelog.txt 2009-09-07 22:54:20 UTC (rev 569)
@@ -1,5 +1,6 @@
maven-helper-plugin (1.0.3) stable; urgency=high
+ * [FEATURE #46] ajout d'un contrat pour faire des parseurs xpp3
* [FEATURE #45] utiliser des generics dans le framework de test de mojos
-- chemit --
Added: trunk/src/main/java/org/nuiton/io/xpp3/AbstractXpp3Reader.java
===================================================================
--- trunk/src/main/java/org/nuiton/io/xpp3/AbstractXpp3Reader.java (rev 0)
+++ trunk/src/main/java/org/nuiton/io/xpp3/AbstractXpp3Reader.java 2009-09-07 22:54:20 UTC (rev 569)
@@ -0,0 +1,338 @@
+package org.nuiton.io.xpp3;
+
+import java.beans.IntrospectionException;
+import java.io.IOException;
+import java.io.Reader;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.TreeMap;
+import org.codehaus.plexus.util.xml.pull.MXParser;
+import org.codehaus.plexus.util.xml.pull.XmlPullParser;
+import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
+
+/**
+ * An abstract xpp3Reader based on {@link PropertyMapper} to set properties of
+ * the objects to build.
+ *
+ * To implements a new parser, just implements method {@link #initMappers()} to
+ * see authorized mapping from tag to pojo properties.
+ *
+ * The logic of setting properties from xml (tag and attributes) is done in
+ *
+ * <ul>
+ * <li>{@link #read(org.codehaus.plexus.util.xml.pull.XmlPullParser, boolean)} </li>
+ * <li>{@link #readArray(org.codehaus.plexus.util.xml.pull.XmlPullParser, boolean)} </li>
+ * </ul>
+ *
+ * The default implementation is to map tag text to a pojo's property.
+ *
+ * If you want to do something more complex, override these methods.
+ *
+ * @author chemit
+ * @since 1.0.0
+ * @see PropertyMapper
+ * @see Xpp3Reader
+ */
+public abstract class AbstractXpp3Reader implements Xpp3Reader {
+
+ /**
+ * If set the parser will be loaded with all single characters
+ * from the XHTML specification.
+ * The entities used:
+ * <ul>
+ * <li>http://www.w3.org/TR/xhtml1/DTD/xhtml-lat1.ent</li>
+ * <li>http://www.w3.org/TR/xhtml1/DTD/xhtml-special.ent</li>
+ * <li>http://www.w3.org/TR/xhtml1/DTD/xhtml-symbol.ent</li>
+ * </ul>
+ */
+ protected boolean addDefaultEntities = true;
+ /**
+ * the type of the object to produce from the xml streams.
+ */
+ protected final Class<?> type;
+ /**
+ * the root tag of an object to retreave from xml streams.
+ *
+ */
+ protected final String rootTagName;
+ /**
+ * the univers of mappers availables, initialized in {@link #initMappers()}.
+ *
+ * Each mapper of the dictionary is associated to the fully qualified name
+ * of the target class # the tag name or attribute name.
+ *
+ * Example :
+ * <pre>
+ * org.nuiton.util.MyPojo#my-tag
+ * org.nuiton.util.MyPojo#my-attribute
+ * </pre>
+ */
+ protected final Map<String, PropertyMapper> allMappers;
+ /**
+ * a flag to display in console the generated code :
+ * an easy way to build to generate java pojos mocks from xml file (to test the parser for example :)
+ */
+ protected boolean showGeneratedCode;
+
+ protected abstract void initMappers() throws IntrospectionException;
+
+ protected AbstractXpp3Reader(Class<?> type, String rootTagName) {
+ this.type = type;
+ this.rootTagName = rootTagName;
+ this.allMappers = new TreeMap<String, PropertyMapper>();
+ try {
+ initMappers();
+ } catch (IntrospectionException e) {
+ throw new IllegalStateException("could not init " + this + " for reason " + e.getMessage(), e);
+ }
+ }
+
+ @Override
+ public Class<?> getType() {
+ return type;
+ }
+
+ public String getRootTagName() {
+ return rootTagName;
+ }
+
+ public String getArrayRootTagName() {
+ return rootTagName + "s";
+ }
+
+ @Override
+ public boolean isAddDefaultEntities() {
+ return addDefaultEntities;
+ }
+
+ public boolean isShowGeneratedCode() {
+ return showGeneratedCode;
+ }
+
+ public void setShowGeneratedCode(boolean showGeneratedCode) {
+ this.showGeneratedCode = showGeneratedCode;
+ }
+
+ @Override
+ public void setAddDefaultEntities(boolean addDefaultEntities) {
+ this.addDefaultEntities = addDefaultEntities;
+ }
+
+ @Override
+ public Object read(Reader reader) throws IOException, XmlPullParserException {
+ return read(reader, true);
+ }
+
+ @Override
+ public Object read(Reader reader, boolean strict) throws IOException, XmlPullParserException {
+ XmlPullParser parser = new MXParser();
+
+ parser.setInput(reader);
+
+ if (addDefaultEntities) {
+
+ Xpp3Helper.addDefaultEntities(parser);
+
+ }
+
+ parser.next();
+ return read(parser, strict);
+ }
+
+ @Override
+ public Object[] readArray(Reader reader) throws IOException, XmlPullParserException {
+ return readArray(reader, true);
+ }
+
+ @Override
+ public Object[] readArray(Reader reader, boolean strict) throws IOException, XmlPullParserException {
+ XmlPullParser parser = new MXParser();
+
+ parser.setInput(reader);
+
+ if (addDefaultEntities) {
+
+ Xpp3Helper.addDefaultEntities(parser);
+
+ }
+
+ parser.next();
+ return readArray(parser, strict);
+ }
+
+ /**
+ * Obtain all mappers for a given type.
+ *
+ * In the result, the keys are now the tag-name of attribute-name.
+ *
+ * Example :
+ * <pre>
+ * my-tag
+ * my-attribute
+ * </pre>
+ *
+ * @param srcType the target type of the searched mappers
+ * @return the dictionnary of mappers for the given type.
+ */
+ public Map<String, PropertyMapper> getMappers(Class<?> srcType) {
+ Map<String, PropertyMapper> result = new TreeMap<String, PropertyMapper>();
+ String prefix = srcType.getName() + "#";
+ for (Entry<String, PropertyMapper> e : this.allMappers.entrySet()) {
+ if (e.getKey().startsWith(prefix)) {
+ result.put(e.getValue().getTagName(), e.getValue());
+ }
+ }
+ return result;
+ }
+
+ /**
+ * Parse the xml stream from the given parser and a build the associated object.
+ *
+ * This default implementation just match a tag text content to a pojo property.
+ *
+ * No work is done on attribute values here.
+ *
+ * Note: The xml stream must contains one object to build on the root node.
+ *
+ * the root node name is given by <code>getRootTagName()</code>
+ *
+ * Example :
+ * <pre>
+ * <my-pojo>
+ * <my-property>myValue</my-property>
+ * </my-pojo>
+ * </pre>
+ *
+ * @param parser the xpp3 parser
+ * @param strict flag to indicate if should fail if a unknown tag (or attribute ?) is scanned
+ * @return the single object build from the xml stream.
+ * @throws IOException if any io pb
+ * @throws XmlPullParserException if any parsing pb
+ */
+ protected Object read(XmlPullParser parser, boolean strict) throws IOException, XmlPullParserException {
+
+ Object result;
+ try {
+ result = getType().newInstance();
+ } catch (Exception ex) {
+ // should never happens!
+ throw new RuntimeException("could not instanciate a new " + getType().getName() + " for reason : " + ex.getMessage(), ex);
+ }
+
+ java.util.Set<String> parsed = new java.util.HashSet<String>();
+ int eventType = parser.getEventType();
+ boolean foundRoot = false;
+
+ Map<String, PropertyMapper> mappers = getMappers(getType());
+ if (showGeneratedCode) {
+ System.out.println(getType().getName() + " i = new " + getType().getSimpleName() + "();");
+ }
+ while (eventType != XmlPullParser.END_DOCUMENT) {
+ if (eventType == XmlPullParser.START_TAG) {
+ if (parser.getName().equals(rootTagName)) {
+ foundRoot = true;
+ } else {
+ PropertyMapper mapper = mappers.get(parser.getName());
+ if (mapper != null) {
+ mapper.setProperty(result, parser, parsed, strict);
+ } else if (strict) {
+ throw new XmlPullParserException("Unrecognised tag: '" + parser.getName() + "'", parser, null);
+ }
+ }
+ }
+ eventType = parser.next();
+ }
+ return result;
+ }
+
+ /**
+ * Parse the xml stream from the given parser and a build an array of associated object.
+ *
+ * This default implementation just match a tag text content to a pojo property.
+ *
+ * No work is done on attribute values here.
+ *
+ * Note: The xml stream must contains a root node.
+ *
+ * the root node name is given by <code>getArrayRootTagName()</code>
+ *
+ * and sub nodes with names <code>getRootTagName()</code>
+ *
+ * Example :
+ * <pre>
+ * <my-pojos>
+ * <my-pojo>
+ * <my-property>myValue</my-property>
+ * </my-pojo>
+ * <my-pojo>
+ * <my-property>myValue2</my-property>
+ * </my-pojo>
+ * </my-pojos>
+ * </pre>
+ *
+ * @param parser the xpp3 parser
+ * @param strict flag to indicate if should fail if a unknown tag (or attribute ?) is scanned
+ * @return the single object build from the xml stream.
+ * @throws IOException if any io pb
+ * @throws XmlPullParserException if any parsing pb
+ */
+ protected Object[] readArray(XmlPullParser parser, boolean strict) throws IOException, XmlPullParserException {
+
+ List<Object> results = new ArrayList<Object>();
+
+
+ java.util.Set<String> parsed = new java.util.HashSet<String>();
+ int eventType = parser.getEventType();
+ boolean foundRoot = false;
+
+ Map<String, PropertyMapper> mappers = getMappers(getType());
+ Object result = null;
+ String root = getArrayRootTagName();
+ if (showGeneratedCode) {
+ System.out.println(getType().getSimpleName() + " i = null;");
+ }
+ while (eventType != XmlPullParser.END_DOCUMENT) {
+ if (eventType == XmlPullParser.START_TAG) {
+ if (parser.getName().equals(root)) {
+ foundRoot = true;
+ if (showGeneratedCode) {
+ System.out.println("List<" + getType().getSimpleName() + "> list = new ArrayList<" + getType().getSimpleName() + ">();");
+ }
+ } else if (parser.getName().equals(this.rootTagName)) {
+ try {
+ result = getType().newInstance();
+ if (showGeneratedCode) {
+ System.out.println("i = new " + getType().getSimpleName() + "();");
+ }
+ } catch (Exception ex) {
+ // should never happens!
+ throw new RuntimeException("could not instanciate a new " + getType().getName() + " for reason : " + ex.getMessage(), ex);
+ }
+
+ } else {
+ PropertyMapper mapper = mappers.get(parser.getName());
+ if (mapper != null) {
+ mapper.setProperty(result, parser, parsed, strict);
+
+ } else if (strict) {
+ throw new XmlPullParserException("Unrecognised tag: '" + parser.getName() + "'", parser, null);
+ }
+ }
+ } else if (eventType == XmlPullParser.END_TAG) {
+ if (parser.getName().equals(this.rootTagName)) {
+ // save it
+ results.add(result);
+ // clear parsed attributes
+ parsed.clear();
+ if (showGeneratedCode) {
+ System.out.println("list.add(i);");
+ }
+ }
+ }
+ eventType = parser.next();
+ }
+ return results.toArray(new Object[results.size()]);
+ }
+}
Property changes on: trunk/src/main/java/org/nuiton/io/xpp3/AbstractXpp3Reader.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL
Added: trunk/src/main/java/org/nuiton/io/xpp3/DataConverter.java
===================================================================
--- trunk/src/main/java/org/nuiton/io/xpp3/DataConverter.java (rev 0)
+++ trunk/src/main/java/org/nuiton/io/xpp3/DataConverter.java 2009-09-07 22:54:20 UTC (rev 569)
@@ -0,0 +1,15 @@
+package org.nuiton.io.xpp3;
+
+/**
+ * A contract to a data converter from a text value to a typed value.
+ *
+ * We does not here use the commons-beans classes, since we could have different
+ * types of converter for a same type....
+ *
+ * @author chemit
+ * @since 1.0.3
+ */
+public interface DataConverter {
+
+ Object convert(String t) throws Exception;
+}
Property changes on: trunk/src/main/java/org/nuiton/io/xpp3/DataConverter.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL
Added: trunk/src/main/java/org/nuiton/io/xpp3/PropertyMapper.java
===================================================================
--- trunk/src/main/java/org/nuiton/io/xpp3/PropertyMapper.java (rev 0)
+++ trunk/src/main/java/org/nuiton/io/xpp3/PropertyMapper.java 2009-09-07 22:54:20 UTC (rev 569)
@@ -0,0 +1,134 @@
+package org.nuiton.io.xpp3;
+
+import java.beans.PropertyDescriptor;
+import java.io.IOException;
+import java.text.ParseException;
+import java.util.Set;
+import org.codehaus.plexus.util.xml.pull.XmlPullParser;
+import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
+
+/**
+ * A abstract object to map an xml value (tag or attribute, or esle?) to a pojo property.
+ *
+ * Two implementations are given :
+ *
+ * <ul>
+ * <li>{@link TagTextContentToProperty} to map the text content of a tag to a pojo's property</li>
+ * <li>{@link AttributeValueToProperty} to map the text content of a tag to a pojo's property</li>
+ * </ul>
+ *
+ * @author chemit
+ * @since 1.0.3
+ */
+public abstract class PropertyMapper {
+
+ public static class TagTextContentToProperty extends PropertyMapper {
+
+ public TagTextContentToProperty(String tagName, String propertyName, DataConverter type, boolean onlyOne, PropertyDescriptor descriptor) {
+ super(tagName, propertyName, type, onlyOne, descriptor);
+ }
+
+ @Override
+ protected Object getDataFromXml(XmlPullParser parser) throws XmlPullParserException, Exception {
+ String t = parser.nextText();
+ Object result = null;
+ if (t != null && !(t = t.trim()).isEmpty()) {
+ result = type.convert(t);
+ }
+ return result;
+ }
+ }
+
+ public static class AttributeValueToProperty extends PropertyMapper {
+
+ public AttributeValueToProperty(String tagName, String propertyName, DataConverter type, boolean onlyOne, PropertyDescriptor descriptor) {
+ super(tagName, propertyName, type, onlyOne, descriptor);
+ }
+
+ @Override
+ protected Object getDataFromXml(XmlPullParser parser) throws XmlPullParserException, Exception {
+ String t = parser.getAttributeValue("", name);
+ Object result = null;
+ if (t != null && !(t = t.trim()).isEmpty()) {
+ result = type.convert(t);
+ }
+ return result;
+ }
+ }
+ /**
+ * name of tag (or attribute to deal with)
+ */
+ protected final String name;
+ /**
+ * the pojo's property to set
+ */
+ protected final String propertyName;
+ /**
+ * the converter from xml to pojo's property type
+ */
+ protected final DataConverter type;
+ /**
+ * the pojo's property descriptor
+ */
+ protected final PropertyDescriptor descriptor;
+ /**
+ * a flag to check to use only once the mapper. (should not be used for
+ * attributes implementations).
+ */
+ protected final boolean onlyOne;
+
+ protected PropertyMapper(String tagName, String propertyName, DataConverter type, boolean onlyOne, PropertyDescriptor descriptor) {
+ this.name = tagName;
+ this.propertyName = propertyName;
+ this.type = type;
+ this.onlyOne = onlyOne;
+ this.descriptor = descriptor;
+ }
+
+ protected abstract Object getDataFromXml(XmlPullParser parser) throws XmlPullParserException, Exception;
+
+ public void setProperty(Object src, XmlPullParser parser, Set<String> parsed, boolean strict) throws XmlPullParserException, IOException, IOException {
+ if (onlyOne && parsed.contains(name)) {
+ throw new XmlPullParserException("Duplicated tag: \'" + parser.getName() + "\'", parser, null);
+ }
+ parsed.add(name);
+ try {
+ Object r = getDataFromXml(parser);
+ if (r != null) {
+ descriptor.getWriteMethod().invoke(src, r);
+ }
+ } catch (XmlPullParserException e) {
+ throw e;
+ } catch (NumberFormatException e) {
+ if (strict) {
+ throw new XmlPullParserException(e.getMessage());
+ }
+ } catch (ParseException e) {
+ if (strict) {
+ throw new XmlPullParserException(e.getMessage());
+ }
+ } catch (Exception e) {
+ throw new XmlPullParserException(e.getMessage());
+ }
+ }
+
+ public PropertyDescriptor getDescriptor() {
+ return descriptor;
+ }
+
+ public boolean isOnlyOne() {
+ return onlyOne;
+ }
+
+ public String getPropertyName() {
+ return propertyName;
+ }
+
+ public String getTagName() {
+ return name;
+ }
+
+ public DataConverter getType() {
+ return type;
+ }
+}
Property changes on: trunk/src/main/java/org/nuiton/io/xpp3/PropertyMapper.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL
Added: trunk/src/main/java/org/nuiton/io/xpp3/Xpp3Helper.java
===================================================================
--- trunk/src/main/java/org/nuiton/io/xpp3/Xpp3Helper.java (rev 0)
+++ trunk/src/main/java/org/nuiton/io/xpp3/Xpp3Helper.java 2009-09-07 22:54:20 UTC (rev 569)
@@ -0,0 +1,424 @@
+package org.nuiton.io.xpp3;
+
+import org.codehaus.plexus.util.IOUtil;
+import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
+
+import java.io.IOException;
+import java.io.Reader;
+import java.io.StringReader;
+import java.io.StringWriter;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.ServiceLoader;
+import org.codehaus.plexus.util.xml.pull.XmlPullParser;
+
+/**
+ * A Helper to read some data stored in xml with a {@link Xpp3Reader}.
+ *
+ * In this class, there is some methods to obtain a discovered {@link Xpp3Reader}
+ * registred by a {@link ServiceLoader} mecanism.
+ *
+ * @author chemit
+ * @since 1.0.3
+ * @see Xpp3Reader
+ */
+public class Xpp3Helper {
+
+ /**
+ * les readers enregistres via un {@link ServiceLoader}
+ * sur le contrat {@link Xpp3Reader}.
+ */
+ protected static Map<Class<?>, Xpp3Reader> readers;
+
+ /**
+ * Read a single object from a xml stream.
+ *
+ * @param klass the type of object to read
+ * @param reader the reader where to parse the xml
+ * @return the loaded object
+ * @throws IOException if any io pb
+ * @throws XmlPullParserException if any parsing pb
+ */
+ public static Object readObject(Class<?> klass, Reader reader) throws IOException, XmlPullParserException {
+
+ Object result = null;
+
+ try {
+
+ StringWriter sWriter = new StringWriter();
+
+ IOUtil.copy(reader, sWriter);
+
+ String rawInput = sWriter.toString();
+
+ StringReader sReader = new StringReader(rawInput);
+
+ Xpp3Reader modelReader = getReader(klass);
+
+ result = modelReader.read(sReader);
+
+ } finally {
+ IOUtil.close(reader);
+ }
+
+ return result;
+ }
+
+ /**
+ * Read an array of objects from a xml stream.
+ *
+ * @param klass the type of object to read
+ * @param reader the reader where to parse the xml
+ * @return the loaded objects
+ * @throws IOException if any io pb
+ * @throws XmlPullParserException if any parsing pb
+ */
+ public static Object[] readObjects(Class<?> klass, Reader reader) throws IOException, XmlPullParserException {
+
+ Object[] result = null;
+
+ try {
+
+ StringWriter sWriter = new StringWriter();
+
+ IOUtil.copy(reader, sWriter);
+
+ String rawInput = sWriter.toString();
+
+ StringReader sReader = new StringReader(rawInput);
+
+ Xpp3Reader modelReader = getReader(klass);
+
+ result = modelReader.readArray(sReader);
+
+ } finally {
+ IOUtil.close(reader);
+ }
+
+ return result;
+ }
+
+ /**
+ *
+ * @return an iterator on all registred {@link Xpp3Reader}.
+ */
+ public static Iterator<Xpp3Reader> getReaderItetator() {
+ return getReaders().values().iterator();
+ }
+
+ /**
+ * Obtain the loaded reader which match his {@link Xpp3Reader#getType()} whith
+ * the given type.
+ *
+ * @param <T> the type of the data which should be parsed by the researched parser
+ * @param klass the type of the data which should be parsed by the researched parser
+ * @return the parser for the given type
+ */
+ public static <T> Xpp3Reader getReader(Class<?> klass) {
+ Xpp3Reader reader = getReaders().get(klass);
+ return reader;
+ }
+
+ /**
+ * Clean all the registred readers.
+ *
+ * To reload them, just call a {@link #getReader(java.lang.Class)}.
+ *
+ */
+ public static void clearReaders() {
+ if (readers != null) {
+ readers.clear();
+ readers = null;
+ }
+ }
+
+ /**
+ * Add to the parser, the default replacers for all single characters
+ * from the XHTML specification.
+ * The entities used:
+ * <ul>
+ * <li>http://www.w3.org/TR/xhtml1/DTD/xhtml-lat1.ent</li>
+ * <li>http://www.w3.org/TR/xhtml1/DTD/xhtml-special.ent</li>
+ * <li>http://www.w3.org/TR/xhtml1/DTD/xhtml-symbol.ent</li>
+ * </ul>
+ * @param parser the parser to configure
+ * @throws XmlPullParserException if any pb
+ */
+ public static void addDefaultEntities(XmlPullParser parser) throws XmlPullParserException {
+ // ----------------------------------------------------------------------
+ // Latin 1 entities
+ // ----------------------------------------------------------------------
+ parser.defineEntityReplacementText("nbsp", "\u00a0");
+ parser.defineEntityReplacementText("iexcl", "\u00a1");
+ parser.defineEntityReplacementText("cent", "\u00a2");
+ parser.defineEntityReplacementText("pound", "\u00a3");
+ parser.defineEntityReplacementText("curren", "\u00a4");
+ parser.defineEntityReplacementText("yen", "\u00a5");
+ parser.defineEntityReplacementText("brvbar", "\u00a6");
+ parser.defineEntityReplacementText("sect", "\u00a7");
+ parser.defineEntityReplacementText("uml", "\u00a8");
+ parser.defineEntityReplacementText("copy", "\u00a9");
+ parser.defineEntityReplacementText("ordf", "\u00aa");
+ parser.defineEntityReplacementText("laquo", "\u00ab");
+ parser.defineEntityReplacementText("not", "\u00ac");
+ parser.defineEntityReplacementText("shy", "\u00ad");
+ parser.defineEntityReplacementText("reg", "\u00ae");
+ parser.defineEntityReplacementText("macr", "\u00af");
+ parser.defineEntityReplacementText("deg", "\u00b0");
+ parser.defineEntityReplacementText("plusmn", "\u00b1");
+ parser.defineEntityReplacementText("sup2", "\u00b2");
+ parser.defineEntityReplacementText("sup3", "\u00b3");
+ parser.defineEntityReplacementText("acute", "\u00b4");
+ parser.defineEntityReplacementText("micro", "\u00b5");
+ parser.defineEntityReplacementText("para", "\u00b6");
+ parser.defineEntityReplacementText("middot", "\u00b7");
+ parser.defineEntityReplacementText("cedil", "\u00b8");
+ parser.defineEntityReplacementText("sup1", "\u00b9");
+ parser.defineEntityReplacementText("ordm", "\u00ba");
+ parser.defineEntityReplacementText("raquo", "\u00bb");
+ parser.defineEntityReplacementText("frac14", "\u00bc");
+ parser.defineEntityReplacementText("frac12", "\u00bd");
+ parser.defineEntityReplacementText("frac34", "\u00be");
+ parser.defineEntityReplacementText("iquest", "\u00bf");
+ parser.defineEntityReplacementText("Agrave", "\u00c0");
+ parser.defineEntityReplacementText("Aacute", "\u00c1");
+ parser.defineEntityReplacementText("Acirc", "\u00c2");
+ parser.defineEntityReplacementText("Atilde", "\u00c3");
+ parser.defineEntityReplacementText("Auml", "\u00c4");
+ parser.defineEntityReplacementText("Aring", "\u00c5");
+ parser.defineEntityReplacementText("AElig", "\u00c6");
+ parser.defineEntityReplacementText("Ccedil", "\u00c7");
+ parser.defineEntityReplacementText("Egrave", "\u00c8");
+ parser.defineEntityReplacementText("Eacute", "\u00c9");
+ parser.defineEntityReplacementText("Ecirc", "\u00ca");
+ parser.defineEntityReplacementText("Euml", "\u00cb");
+ parser.defineEntityReplacementText("Igrave", "\u00cc");
+ parser.defineEntityReplacementText("Iacute", "\u00cd");
+ parser.defineEntityReplacementText("Icirc", "\u00ce");
+ parser.defineEntityReplacementText("Iuml", "\u00cf");
+ parser.defineEntityReplacementText("ETH", "\u00d0");
+ parser.defineEntityReplacementText("Ntilde", "\u00d1");
+ parser.defineEntityReplacementText("Ograve", "\u00d2");
+ parser.defineEntityReplacementText("Oacute", "\u00d3");
+ parser.defineEntityReplacementText("Ocirc", "\u00d4");
+ parser.defineEntityReplacementText("Otilde", "\u00d5");
+ parser.defineEntityReplacementText("Ouml", "\u00d6");
+ parser.defineEntityReplacementText("times", "\u00d7");
+ parser.defineEntityReplacementText("Oslash", "\u00d8");
+ parser.defineEntityReplacementText("Ugrave", "\u00d9");
+ parser.defineEntityReplacementText("Uacute", "\u00da");
+ parser.defineEntityReplacementText("Ucirc", "\u00db");
+ parser.defineEntityReplacementText("Uuml", "\u00dc");
+ parser.defineEntityReplacementText("Yacute", "\u00dd");
+ parser.defineEntityReplacementText("THORN", "\u00de");
+ parser.defineEntityReplacementText("szlig", "\u00df");
+ parser.defineEntityReplacementText("agrave", "\u00e0");
+ parser.defineEntityReplacementText("aacute", "\u00e1");
+ parser.defineEntityReplacementText("acirc", "\u00e2");
+ parser.defineEntityReplacementText("atilde", "\u00e3");
+ parser.defineEntityReplacementText("auml", "\u00e4");
+ parser.defineEntityReplacementText("aring", "\u00e5");
+ parser.defineEntityReplacementText("aelig", "\u00e6");
+ parser.defineEntityReplacementText("ccedil", "\u00e7");
+ parser.defineEntityReplacementText("egrave", "\u00e8");
+ parser.defineEntityReplacementText("eacute", "\u00e9");
+ parser.defineEntityReplacementText("ecirc", "\u00ea");
+ parser.defineEntityReplacementText("euml", "\u00eb");
+ parser.defineEntityReplacementText("igrave", "\u00ec");
+ parser.defineEntityReplacementText("iacute", "\u00ed");
+ parser.defineEntityReplacementText("icirc", "\u00ee");
+ parser.defineEntityReplacementText("iuml", "\u00ef");
+ parser.defineEntityReplacementText("eth", "\u00f0");
+ parser.defineEntityReplacementText("ntilde", "\u00f1");
+ parser.defineEntityReplacementText("ograve", "\u00f2");
+ parser.defineEntityReplacementText("oacute", "\u00f3");
+ parser.defineEntityReplacementText("ocirc", "\u00f4");
+ parser.defineEntityReplacementText("otilde", "\u00f5");
+ parser.defineEntityReplacementText("ouml", "\u00f6");
+ parser.defineEntityReplacementText("divide", "\u00f7");
+ parser.defineEntityReplacementText("oslash", "\u00f8");
+ parser.defineEntityReplacementText("ugrave", "\u00f9");
+ parser.defineEntityReplacementText("uacute", "\u00fa");
+ parser.defineEntityReplacementText("ucirc", "\u00fb");
+ parser.defineEntityReplacementText("uuml", "\u00fc");
+ parser.defineEntityReplacementText("yacute", "\u00fd");
+ parser.defineEntityReplacementText("thorn", "\u00fe");
+ parser.defineEntityReplacementText("yuml", "\u00ff");
+ // ----------------------------------------------------------------------
+ // Special entities
+ // ----------------------------------------------------------------------
+ parser.defineEntityReplacementText("OElig", "\u0152");
+ parser.defineEntityReplacementText("oelig", "\u0153");
+ parser.defineEntityReplacementText("Scaron", "\u0160");
+ parser.defineEntityReplacementText("scaron", "\u0161");
+ parser.defineEntityReplacementText("Yuml", "\u0178");
+ parser.defineEntityReplacementText("circ", "\u02c6");
+ parser.defineEntityReplacementText("tilde", "\u02dc");
+ parser.defineEntityReplacementText("ensp", "\u2002");
+ parser.defineEntityReplacementText("emsp", "\u2003");
+ parser.defineEntityReplacementText("thinsp", "\u2009");
+ parser.defineEntityReplacementText("zwnj", "\u200c");
+ parser.defineEntityReplacementText("zwj", "\u200d");
+ parser.defineEntityReplacementText("lrm", "\u200e");
+ parser.defineEntityReplacementText("rlm", "\u200f");
+ parser.defineEntityReplacementText("ndash", "\u2013");
+ parser.defineEntityReplacementText("mdash", "\u2014");
+ parser.defineEntityReplacementText("lsquo", "\u2018");
+ parser.defineEntityReplacementText("rsquo", "\u2019");
+ parser.defineEntityReplacementText("sbquo", "\u201a");
+ parser.defineEntityReplacementText("ldquo", "\u201c");
+ parser.defineEntityReplacementText("rdquo", "\u201d");
+ parser.defineEntityReplacementText("bdquo", "\u201e");
+ parser.defineEntityReplacementText("dagger", "\u2020");
+ parser.defineEntityReplacementText("Dagger", "\u2021");
+ parser.defineEntityReplacementText("permil", "\u2030");
+ parser.defineEntityReplacementText("lsaquo", "\u2039");
+ parser.defineEntityReplacementText("rsaquo", "\u203a");
+ parser.defineEntityReplacementText("euro", "\u20ac");
+ // ----------------------------------------------------------------------
+ // Symbol entities
+ // ----------------------------------------------------------------------
+ parser.defineEntityReplacementText("fnof", "\u0192");
+ parser.defineEntityReplacementText("Alpha", "\u0391");
+ parser.defineEntityReplacementText("Beta", "\u0392");
+ parser.defineEntityReplacementText("Gamma", "\u0393");
+ parser.defineEntityReplacementText("Delta", "\u0394");
+ parser.defineEntityReplacementText("Epsilon", "\u0395");
+ parser.defineEntityReplacementText("Zeta", "\u0396");
+ parser.defineEntityReplacementText("Eta", "\u0397");
+ parser.defineEntityReplacementText("Theta", "\u0398");
+ parser.defineEntityReplacementText("Iota", "\u0399");
+ parser.defineEntityReplacementText("Kappa", "\u039a");
+ parser.defineEntityReplacementText("Lambda", "\u039b");
+ parser.defineEntityReplacementText("Mu", "\u039c");
+ parser.defineEntityReplacementText("Nu", "\u039d");
+ parser.defineEntityReplacementText("Xi", "\u039e");
+ parser.defineEntityReplacementText("Omicron", "\u039f");
+ parser.defineEntityReplacementText("Pi", "\u03a0");
+ parser.defineEntityReplacementText("Rho", "\u03a1");
+ parser.defineEntityReplacementText("Sigma", "\u03a3");
+ parser.defineEntityReplacementText("Tau", "\u03a4");
+ parser.defineEntityReplacementText("Upsilon", "\u03a5");
+ parser.defineEntityReplacementText("Phi", "\u03a6");
+ parser.defineEntityReplacementText("Chi", "\u03a7");
+ parser.defineEntityReplacementText("Psi", "\u03a8");
+ parser.defineEntityReplacementText("Omega", "\u03a9");
+ parser.defineEntityReplacementText("alpha", "\u03b1");
+ parser.defineEntityReplacementText("beta", "\u03b2");
+ parser.defineEntityReplacementText("gamma", "\u03b3");
+ parser.defineEntityReplacementText("delta", "\u03b4");
+ parser.defineEntityReplacementText("epsilon", "\u03b5");
+ parser.defineEntityReplacementText("zeta", "\u03b6");
+ parser.defineEntityReplacementText("eta", "\u03b7");
+ parser.defineEntityReplacementText("theta", "\u03b8");
+ parser.defineEntityReplacementText("iota", "\u03b9");
+ parser.defineEntityReplacementText("kappa", "\u03ba");
+ parser.defineEntityReplacementText("lambda", "\u03bb");
+ parser.defineEntityReplacementText("mu", "\u03bc");
+ parser.defineEntityReplacementText("nu", "\u03bd");
+ parser.defineEntityReplacementText("xi", "\u03be");
+ parser.defineEntityReplacementText("omicron", "\u03bf");
+ parser.defineEntityReplacementText("pi", "\u03c0");
+ parser.defineEntityReplacementText("rho", "\u03c1");
+ parser.defineEntityReplacementText("sigmaf", "\u03c2");
+ parser.defineEntityReplacementText("sigma", "\u03c3");
+ parser.defineEntityReplacementText("tau", "\u03c4");
+ parser.defineEntityReplacementText("upsilon", "\u03c5");
+ parser.defineEntityReplacementText("phi", "\u03c6");
+ parser.defineEntityReplacementText("chi", "\u03c7");
+ parser.defineEntityReplacementText("psi", "\u03c8");
+ parser.defineEntityReplacementText("omega", "\u03c9");
+ parser.defineEntityReplacementText("thetasym", "\u03d1");
+ parser.defineEntityReplacementText("upsih", "\u03d2");
+ parser.defineEntityReplacementText("piv", "\u03d6");
+ parser.defineEntityReplacementText("bull", "\u2022");
+ parser.defineEntityReplacementText("hellip", "\u2026");
+ parser.defineEntityReplacementText("prime", "\u2032");
+ parser.defineEntityReplacementText("Prime", "\u2033");
+ parser.defineEntityReplacementText("oline", "\u203e");
+ parser.defineEntityReplacementText("frasl", "\u2044");
+ parser.defineEntityReplacementText("weierp", "\u2118");
+ parser.defineEntityReplacementText("image", "\u2111");
+ parser.defineEntityReplacementText("real", "\u211c");
+ parser.defineEntityReplacementText("trade", "\u2122");
+ parser.defineEntityReplacementText("alefsym", "\u2135");
+ parser.defineEntityReplacementText("larr", "\u2190");
+ parser.defineEntityReplacementText("uarr", "\u2191");
+ parser.defineEntityReplacementText("rarr", "\u2192");
+ parser.defineEntityReplacementText("darr", "\u2193");
+ parser.defineEntityReplacementText("harr", "\u2194");
+ parser.defineEntityReplacementText("crarr", "\u21b5");
+ parser.defineEntityReplacementText("lArr", "\u21d0");
+ parser.defineEntityReplacementText("uArr", "\u21d1");
+ parser.defineEntityReplacementText("rArr", "\u21d2");
+ parser.defineEntityReplacementText("dArr", "\u21d3");
+ parser.defineEntityReplacementText("hArr", "\u21d4");
+ parser.defineEntityReplacementText("forall", "\u2200");
+ parser.defineEntityReplacementText("part", "\u2202");
+ parser.defineEntityReplacementText("exist", "\u2203");
+ parser.defineEntityReplacementText("empty", "\u2205");
+ parser.defineEntityReplacementText("nabla", "\u2207");
+ parser.defineEntityReplacementText("isin", "\u2208");
+ parser.defineEntityReplacementText("notin", "\u2209");
+ parser.defineEntityReplacementText("ni", "\u220b");
+ parser.defineEntityReplacementText("prod", "\u220f");
+ parser.defineEntityReplacementText("sum", "\u2211");
+ parser.defineEntityReplacementText("minus", "\u2212");
+ parser.defineEntityReplacementText("lowast", "\u2217");
+ parser.defineEntityReplacementText("radic", "\u221a");
+ parser.defineEntityReplacementText("prop", "\u221d");
+ parser.defineEntityReplacementText("infin", "\u221e");
+ parser.defineEntityReplacementText("ang", "\u2220");
+ parser.defineEntityReplacementText("and", "\u2227");
+ parser.defineEntityReplacementText("or", "\u2228");
+ parser.defineEntityReplacementText("cap", "\u2229");
+ parser.defineEntityReplacementText("cup", "\u222a");
+ parser.defineEntityReplacementText("int", "\u222b");
+ parser.defineEntityReplacementText("there4", "\u2234");
+ parser.defineEntityReplacementText("sim", "\u223c");
+ parser.defineEntityReplacementText("cong", "\u2245");
+ parser.defineEntityReplacementText("asymp", "\u2248");
+ parser.defineEntityReplacementText("ne", "\u2260");
+ parser.defineEntityReplacementText("equiv", "\u2261");
+ parser.defineEntityReplacementText("le", "\u2264");
+ parser.defineEntityReplacementText("ge", "\u2265");
+ parser.defineEntityReplacementText("sub", "\u2282");
+ parser.defineEntityReplacementText("sup", "\u2283");
+ parser.defineEntityReplacementText("nsub", "\u2284");
+ parser.defineEntityReplacementText("sube", "\u2286");
+ parser.defineEntityReplacementText("supe", "\u2287");
+ parser.defineEntityReplacementText("oplus", "\u2295");
+ parser.defineEntityReplacementText("otimes", "\u2297");
+ parser.defineEntityReplacementText("perp", "\u22a5");
+ parser.defineEntityReplacementText("sdot", "\u22c5");
+ parser.defineEntityReplacementText("lceil", "\u2308");
+ parser.defineEntityReplacementText("rceil", "\u2309");
+ parser.defineEntityReplacementText("lfloor", "\u230a");
+ parser.defineEntityReplacementText("rfloor", "\u230b");
+ parser.defineEntityReplacementText("lang", "\u2329");
+ parser.defineEntityReplacementText("rang", "\u232a");
+ parser.defineEntityReplacementText("loz", "\u25ca");
+ parser.defineEntityReplacementText("spades", "\u2660");
+ parser.defineEntityReplacementText("clubs", "\u2663");
+ parser.defineEntityReplacementText("hearts", "\u2665");
+ parser.defineEntityReplacementText("diams", "\u2666");
+ }
+
+ /**
+ *
+ * @return all the {@link Xpp3Reader} registred via a {@link ServiceLoader}
+ * on the contract {@link Xpp3Reader}.
+ *
+ */
+ protected static Map<Class<?>, Xpp3Reader> getReaders() {
+ if (readers == null) {
+ readers = new HashMap<Class<?>, Xpp3Reader>();
+ ServiceLoader<Xpp3Reader> load = ServiceLoader.load(Xpp3Reader.class);
+ for (Xpp3Reader r : load) {
+ readers.put(r.getType(), r);
+ }
+ }
+ return readers;
+ }
+}
Property changes on: trunk/src/main/java/org/nuiton/io/xpp3/Xpp3Helper.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL
Added: trunk/src/main/java/org/nuiton/io/xpp3/Xpp3Reader.java
===================================================================
--- trunk/src/main/java/org/nuiton/io/xpp3/Xpp3Reader.java (rev 0)
+++ trunk/src/main/java/org/nuiton/io/xpp3/Xpp3Reader.java 2009-09-07 22:54:20 UTC (rev 569)
@@ -0,0 +1,89 @@
+package org.nuiton.io.xpp3;
+
+import java.io.IOException;
+import java.io.Reader;
+import org.codehaus.plexus.util.ReaderFactory;
+import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
+
+/**
+ * A simple contract to mark all xpp readers.
+ *
+ * a such reader is associated to a {@link #getType()}.
+ *
+ * The implementations of such readers must be register in a file
+ * <pre>
+ * META-INF/services.org.nuiton.io.xpp3.Xpp3Reader
+ * </pre>
+ *
+ * to make possible auto-discovering of availables reader at runtime.
+ *
+ * See {@link Xpp3Helper#getReader(java.lang.Class)}.
+ *
+ *
+ * @author chemit
+ * @since 1.0.3
+ */
+public interface Xpp3Reader {
+
+ /**
+ *
+ * @return the type of main object to read
+ */
+ Class<?> getType();
+
+ /**
+ * @see ReaderFactory#newXmlReader
+ *
+ * @param reader
+ * @throws IOException
+ * @throws XmlPullParserException
+ * @return Settings
+ */
+ Object read(Reader reader) throws IOException, XmlPullParserException;
+
+ /**
+ * @see ReaderFactory#newXmlReader
+ *
+ * @param reader
+ * @param strict
+ * @throws IOException
+ * @throws XmlPullParserException
+ * @return Settings
+ */
+ Object read(Reader reader, boolean strict) throws IOException, XmlPullParserException;
+
+ /**
+ * @see ReaderFactory#newXmlReader
+ *
+ * @param reader
+ * @throws IOException
+ * @throws XmlPullParserException
+ * @return Settings
+ */
+ Object[] readArray(Reader reader) throws IOException, XmlPullParserException;
+
+ /**
+ * @see ReaderFactory#newXmlReader
+ *
+ * @param reader
+ * @param strict
+ * @throws IOException
+ * @throws XmlPullParserException
+ * @return Settings
+ */
+ Object[] readArray(Reader reader, boolean strict) throws IOException, XmlPullParserException;
+
+ /**
+ * Returns the state of the "add default entities" flag.
+ *
+ * @return boolean
+ */
+ boolean isAddDefaultEntities();
+
+ /**
+ * Sets the state of the "add default entities" flag.
+ *
+ * @param addDefaultEntities
+ */
+ void setAddDefaultEntities(boolean addDefaultEntities);
+}
Property changes on: trunk/src/main/java/org/nuiton/io/xpp3/Xpp3Reader.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL
1
0
Author: tchemit
Date: 2009-09-06 22:27:59 +0200 (Sun, 06 Sep 2009)
New Revision: 568
Modified:
trunk/src/test/java/org/nuiton/util/BasePluginTestCase.java
Log:
automatic tests discovering
Modified: trunk/src/test/java/org/nuiton/util/BasePluginTestCase.java
===================================================================
--- trunk/src/test/java/org/nuiton/util/BasePluginTestCase.java 2009-09-06 13:31:48 UTC (rev 567)
+++ trunk/src/test/java/org/nuiton/util/BasePluginTestCase.java 2009-09-06 20:27:59 UTC (rev 568)
@@ -32,6 +32,8 @@
import java.util.List;
import org.apache.maven.project.MavenProject;
import org.codehaus.plexus.PlexusTestCase;
+import org.junit.Ignore;
+import org.junit.Test;
import org.nuiton.AbstractPlugin;
/**
@@ -70,6 +72,29 @@
testDir = new File(f, rep);
System.out.println("test dir : " + testDir);
+ if (testNames.length == 0) {
+
+ // auto looking up for tests names, methods which respect
+ // with @PluginConfig
+ // with @Test
+ // without @Ignore
+
+ List<String> testNamesList = new ArrayList<String>();
+ for (Method m : klass.getMethods()) {
+ PluginConfig annotation = m.getAnnotation(PluginConfig.class);
+ if (annotation != null) {
+ Test t = m.getAnnotation(Test.class);
+ if (t != null) {
+ Ignore i = m.getAnnotation(Ignore.class);
+ if (i==null) {
+ testNamesList.add(m.getName());
+ }
+ }
+ }
+ }
+ testNames = testNamesList.toArray(new String[testNamesList.size()]);
+ }
+
for (String testName : testNames) {
Method m = klass.getMethod(testName);
if (m == null) {
1
0
r567 - in trunk: . src/test/java/org/nuiton/license/plugin src/test/java/org/nuiton/util
by tchemit@users.nuiton.org 06 Sep '09
by tchemit@users.nuiton.org 06 Sep '09
06 Sep '09
Author: tchemit
Date: 2009-09-06 15:31:48 +0200 (Sun, 06 Sep 2009)
New Revision: 567
Modified:
trunk/changelog.txt
trunk/src/test/java/org/nuiton/license/plugin/LicensePluginTest.java
trunk/src/test/java/org/nuiton/util/BasePluginTestCase.java
Log:
[FEATURE #45] utiliser des generics dans le framework de test de mojos
Modified: trunk/changelog.txt
===================================================================
--- trunk/changelog.txt 2009-08-29 21:37:23 UTC (rev 566)
+++ trunk/changelog.txt 2009-09-06 13:31:48 UTC (rev 567)
@@ -1,10 +1,16 @@
+maven-helper-plugin (1.0.3) stable; urgency=high
+
+ * [FEATURE #45] utiliser des generics dans le framework de test de mojos
+
+ -- chemit --
+
maven-helper-plugin (1.0.2) stable; urgency=high
- * [FIX] #36 protect emails
+ * [FIX #36] protect emails
* [FEATURE] use maven.file.license
* [FEATURE] improve code + add some usefull methods for plugin
* [FEATURE] add some documentation on site + use apt format (no deps to jrst)
- * [FEATURE] #26 add a check-project-files goal to detect existence of the changelog.txt file for root module of project.
+ * [FEATURE #26] add a check-project-files goal to detect existence of the changelog.txt file for root module of project.
-- chemit -- Sat, 29 Aug 2009 19:45:05 +0200
Modified: trunk/src/test/java/org/nuiton/license/plugin/LicensePluginTest.java
===================================================================
--- trunk/src/test/java/org/nuiton/license/plugin/LicensePluginTest.java 2009-08-29 21:37:23 UTC (rev 566)
+++ trunk/src/test/java/org/nuiton/license/plugin/LicensePluginTest.java 2009-09-06 13:31:48 UTC (rev 567)
@@ -34,7 +34,7 @@
import org.nuiton.util.BasePluginTestCase;
/** @author chemit */
-public class LicensePluginTest extends BasePluginTestCase {
+public class LicensePluginTest extends BasePluginTestCase<LicensePlugin> {
@BeforeClass
public static void initClass() throws Exception {
@@ -51,14 +51,13 @@
@Override
public void setUp() throws Exception {
super.setUp();
- LicensePlugin plugin = (LicensePlugin) mojo;
- plugin.setOutputDirectory(new File(getBaseDir(), plugin.getOutputDirectory().toString()));
- if (!plugin.getOutputDirectory().exists()) {
- if (!plugin.getOutputDirectory().mkdirs()) {
- throw new IOException("could not create directory : " + plugin.getOutputDirectory());
+ mojo.setOutputDirectory(new File(getBaseDir(), mojo.getOutputDirectory().toString()));
+ if (!mojo.getOutputDirectory().exists()) {
+ if (!mojo.getOutputDirectory().mkdirs()) {
+ throw new IOException("could not create directory : " + mojo.getOutputDirectory());
}
}
- plugin.setLicenseFile(new File(pomFile.getParentFile(), plugin.getLicenseFile().toString()));
+ mojo.setLicenseFile(new File(pomFile.getParentFile(), mojo.getLicenseFile().toString()));
}
@Test
@@ -66,24 +65,22 @@
public void testOne() throws MojoExecutionException, MojoFailureException {
assertNotNull(mojo);
- LicensePlugin p = (LicensePlugin) mojo;
+ long t0 = mojo.getLicenseFile().lastModified();
- long t0 = p.getLicenseFile().lastModified();
-
// always assume pom is older than any file
// since we can not ensure order of copy test resources
- p.getProject().getFile().setLastModified(0);
+ mojo.getProject().getFile().setLastModified(0);
- p.execute();
+ mojo.execute();
- long t1 = p.getLicenseFile().lastModified();
+ long t1 = mojo.getLicenseFile().lastModified();
assertEquals(t0, t1);
- p.setForce(true);
+ mojo.setForce(true);
- p.execute();
- t1 = p.getLicenseFile().lastModified();
+ mojo.execute();
+ t1 = mojo.getLicenseFile().lastModified();
assertTrue(t1 > t0);
}
Modified: trunk/src/test/java/org/nuiton/util/BasePluginTestCase.java
===================================================================
--- trunk/src/test/java/org/nuiton/util/BasePluginTestCase.java 2009-08-29 21:37:23 UTC (rev 566)
+++ trunk/src/test/java/org/nuiton/util/BasePluginTestCase.java 2009-09-06 13:31:48 UTC (rev 567)
@@ -34,8 +34,10 @@
import org.codehaus.plexus.PlexusTestCase;
import org.nuiton.AbstractPlugin;
-/** @author chemit */
-public abstract class BasePluginTestCase {
+/**
+ * @param <P> le mojo a test
+ * @author chemit */
+public abstract class BasePluginTestCase<P extends AbstractPlugin> {
protected static File basedir;
protected static File testDir;
@@ -43,7 +45,7 @@
protected static MyAbstractMojoTestCase delegate;
protected String goalName;
protected File pomFile;
- protected AbstractPlugin mojo;
+ protected P mojo;
protected static File getBaseDir() {
if (basedir == null) {
@@ -58,7 +60,7 @@
return testDir;
}
- protected static void initConfigs(Class<? extends BasePluginTestCase> klass, String... testNames) throws Exception {
+ protected static <P extends AbstractPlugin> void initConfigs(Class<? extends BasePluginTestCase<P>> klass, String... testNames) throws Exception {
List<PluginConfig> configs = new ArrayList<PluginConfig>();
String rep = klass.getName();
rep = rep.replaceAll("\\.", File.separator);
@@ -94,7 +96,7 @@
protected void initPomFile(PluginConfig pluginConfig) throws Exception {
this.goalName = pluginConfig.goalName();
this.pomFile = new File(getTestDir(), pluginConfig.pomName());
- this.mojo = (AbstractPlugin) delegate.lookupMojo(goalName, pomFile);
+ this.mojo = (P) delegate.lookupMojo(goalName, pomFile);
MavenProject project = mojo.getProject();
if (project == null) {
1
0
Author: tchemit
Date: 2009-08-29 23:37:23 +0200 (Sat, 29 Aug 2009)
New Revision: 566
Modified:
trunk/pom.xml
Log:
[maven-release-plugin] prepare for next development iteration
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2009-08-29 21:37:21 UTC (rev 565)
+++ trunk/pom.xml 2009-08-29 21:37:23 UTC (rev 566)
@@ -10,7 +10,7 @@
<groupId>org.nuiton</groupId>
<artifactId>maven-helper-plugin</artifactId>
- <version>1.0.2</version>
+ <version>1.0.3-SNAPSHOT</version>
<dependencies>
@@ -441,9 +441,9 @@
<!--Source control management-->
<scm>
- <connection>scm:svn:http://svn.nuiton.org/svn/maven-helper-plugin/tags/maven-helper-plu…</connection>
- <developerConnection>scm:svn:http://svn.nuiton.org/svn/maven-helper-plugin/tags/maven-helper-plu…</developerConnection>
- <url>http://www.nuiton.org/repositories/browse/maven-helper-plugin/tags/maven-he…</url>
+ <connection>scm:svn:http://svn.nuiton.org/svn/maven-helper-plugin/trunk</connection>
+ <developerConnection>scm:svn:http://svn.nuiton.org/svn/maven-helper-plugin/trunk</developerConnection>
+ <url>http://www.nuiton.org/repositories/browse/maven-helper-plugin/trunk</url>
</scm>
<issueManagement>
1
0
Author: tchemit
Date: 2009-08-29 23:37:21 +0200 (Sat, 29 Aug 2009)
New Revision: 565
Added:
tags/maven-helper-plugin-1.0.2/
Log:
[maven-scm] copy for tag maven-helper-plugin-1.0.2
Property changes on: tags/maven-helper-plugin-1.0.2
___________________________________________________________________
Added: svn:ignore
+ target
Added: svn:mergeinfo
+
1
0