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
12 Jul '12
Author: tchemit
Date: 2012-07-12 18:53:52 +0200 (Thu, 12 Jul 2012)
New Revision: 844
Url: http://nuiton.org/repositories/revision/maven-helper-plugin/844
Log:
fixes #925: Use maven-plugin-plugin 3 api
Modified:
trunk/src/main/java/org/nuiton/helper/plugin/CheckAutoContainerPlugin.java
trunk/src/main/java/org/nuiton/helper/plugin/CollectFilesMojo.java
trunk/src/main/java/org/nuiton/helper/plugin/ExecuteRemoteCommandMojo.java
trunk/src/main/java/org/nuiton/helper/plugin/SendEmailMojo.java
trunk/src/main/java/org/nuiton/helper/plugin/ShareServerSecretPlugin.java
Modified: trunk/src/main/java/org/nuiton/helper/plugin/CheckAutoContainerPlugin.java
===================================================================
--- trunk/src/main/java/org/nuiton/helper/plugin/CheckAutoContainerPlugin.java 2012-07-09 10:20:16 UTC (rev 843)
+++ trunk/src/main/java/org/nuiton/helper/plugin/CheckAutoContainerPlugin.java 2012-07-12 16:53:52 UTC (rev 844)
@@ -37,6 +37,11 @@
import org.apache.maven.artifact.resolver.ArtifactResolver;
import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.plugin.logging.Log;
+import org.apache.maven.plugins.annotations.Component;
+import org.apache.maven.plugins.annotations.LifecyclePhase;
+import org.apache.maven.plugins.annotations.Mojo;
+import org.apache.maven.plugins.annotations.Parameter;
+import org.apache.maven.plugins.annotations.ResolutionScope;
import org.apache.maven.project.MavenProject;
import org.apache.maven.settings.Proxy;
import org.apache.maven.wagon.ConnectionException;
@@ -59,13 +64,9 @@
*
* @author tchemit <chemit(a)codelutin.com>
* @version $Id$
- * @goal check-auto-container
- * @phase validate
- * @requiresProject true
- * @requiresOnline true
- * @requiresDependencyResolution runtime
* @since 1.2.5
*/
+@Mojo(name = "check-auto-container", defaultPhase = LifecyclePhase.VALIDATE, requiresProject = true, requiresOnline = true, requiresDependencyResolution = ResolutionScope.RUNTIME)
public class CheckAutoContainerPlugin extends AbstractPlugin {
/**
@@ -73,34 +74,34 @@
* <p/>
* Keys are repository id and Values are repository url.
*
- * @parameter
* @since 1.2.5
*/
+ @Parameter
protected Map<String, String> repositories;
/**
* A flag to add the maven central repository http://repo1.maven.org/maven2
* to {@link #repositories}.
*
- * @parameter expression="${addMavenCentral}" default-value="false"
* @since 1.2.5
*/
+ @Parameter(property = "addMavenCentral", defaultValue = "false")
protected boolean addMavenCentral;
/**
* A flag to fail if project is not auto container.
*
- * @parameter expression="${helper.failIfNotSafe}" default-value="false"
* @since 1.2.5
*/
+ @Parameter(property = "helper.failIfNotSafe", defaultValue = "false")
protected boolean failIfNotSafe;
/**
* A flag to activate verbose mode.
*
- * @parameter expression="${helper.verbose}" default-value="${maven.verbose}"
* @since 1.2.5
*/
+ @Parameter(property = "helper.verbose", defaultValue = "${maven.verbose}")
protected boolean verbose;
/**
@@ -109,88 +110,73 @@
* <b>Note:</b> By default, value is {@code true} since it is not necessary
* to check twice for a same artifact.
*
- * @parameter expression="${helper.runOnce}" default-value="true"
* @since 1.2.6
*/
+ @Parameter(property = "helper.runOnce", defaultValue = "true")
protected boolean runOnce;
/**
* Project.
*
- * @parameter default-value="${project}"
- * @required
- * @readonly
* @since 1.2.5
*/
+ @Component
protected MavenProject project;
/**
* The projects in reactor (used to detected sibling dependencies).
*
- * @parameter expression="${reactorProjects}"
- * @readonly
* @since 1.2.5
*/
+ @Parameter(property = "reactorProjects", readonly = true)
protected List<?> reactorProjects;
/**
* Active proxy from settings (if any).
*
- * @parameter default-value="${settings.activeProxy}"
- * @required
- * @readonly
* @since 1.2.5
*/
+ @Parameter(property = "settings.activeProxy", required = true, readonly = true)
protected Proxy proxy;
/**
* Local repository.
*
- * @parameter expression="${localRepository}"
- * @required
- * @readonly
* @since 1.2.5
*/
+ @Parameter(property = "localRepository", required = true, readonly = true)
protected ArtifactRepository localRepository;
/**
* Artifact repository factory component.
*
- * @component
- * @required
- * @readonly
* @since 1.2.5
*/
+ @Component
protected ArtifactRepositoryFactory artifactRepositoryFactory;
/**
* Artifact factory component.
*
- * @component
- * @required
- * @readonly
* @since 1.2.5
*/
+ @Component
protected ArtifactFactory factory;
/**
* Artifact resolver component.
*
- * @component
- * @required
- * @readonly
* @since 1.2.5
*/
+ @Component
protected ArtifactResolver resolver;
/**
* Wagon manager component.
*
- * @component
- * @required
- * @readonly
* @since 1.2.5
*/
+ @Component
protected WagonManager wagonManager;
/**
Modified: trunk/src/main/java/org/nuiton/helper/plugin/CollectFilesMojo.java
===================================================================
--- trunk/src/main/java/org/nuiton/helper/plugin/CollectFilesMojo.java 2012-07-09 10:20:16 UTC (rev 843)
+++ trunk/src/main/java/org/nuiton/helper/plugin/CollectFilesMojo.java 2012-07-12 16:53:52 UTC (rev 844)
@@ -25,11 +25,15 @@
package org.nuiton.helper.plugin;
+import org.apache.commons.lang3.StringUtils;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.metadata.ArtifactMetadata;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
+import org.apache.maven.plugins.annotations.Component;
+import org.apache.maven.plugins.annotations.Mojo;
+import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.project.MavenProject;
import org.nuiton.plugin.AbstractPlugin;
import org.nuiton.plugin.PluginHelper;
@@ -46,69 +50,57 @@
* Collect files some files from a project and copy them into a directory.
*
* @author tchemit <chemit(a)codelutin.com>
- * @goal collect-files
- * @requiresProject true
* @since 1.1.0
*/
+@Mojo(name = "collect-files", requiresProject = true)
public class CollectFilesMojo extends AbstractPlugin implements PluginWithEncoding {
/**
* The projects in the reactor.
*
- * @parameter expression="${reactorProjects}"
- * @readonly
* @since 1.2.4
*/
+ @Parameter(property = "reactorProjects", readonly = true, required = true)
protected List<?> reactorProjects;
/**
* Fallback maven project (for maven 2).
*
- * @parameter default-value="${project}"
- * @required
- * @readonly
* @since 1.0.3
*/
+ @Component
protected MavenProject project;
/**
* The artifacts to publish from the project build.
*
- * @parameter expression="${project.attachedArtifacts}"
- * @required
- * @readonly
* @since 1.0.0
*/
+ @Parameter(property = "project.attachedArtifacts", readonly = true, required = true)
protected List<?> attachedArtifacts;
/**
* The local repository.
*
- * @parameter expression="${localRepository}"
- * @required
- * @readonly
* @since 1.2.2
*/
+ @Parameter(property = "localRepository", readonly = true, required = true)
protected ArtifactRepository localRepository;
/**
* The remote repository.
*
- * @parameter expression="${project.distributionManagementArtifactRepository}"
- * @required
- * @readonly
* @since 1.2.2
*/
+ @Parameter(property = "project.distributionManagementArtifactRepository", readonly = true, required = true)
protected ArtifactRepository deploymentRepository;
/**
* Project artifact.
*
- * @parameter expression="${project.artifact}"
- * @required
- * @readonly
* @since 1.2.2
*/
+ @Parameter(property = "project.artifact", readonly = true, required = true)
protected Artifact artifact;
/**
@@ -116,9 +108,9 @@
* <p/>
* Multi values can be used, separated by comma.
*
- * @parameter expression="${helper.extraFiles}"
* @since 1.0.0
*/
+ @Parameter(property = "helper.extraFiles")
protected String extraFiles;
/**
@@ -126,9 +118,9 @@
* <p/>
* If no Set - no include filter
*
- * @parameter expression="${helper.includes}" default-value=""
* @since 1.0.0
*/
+ @Parameter(property = "helper.includes", defaultValue = "")
protected String includes;
/**
@@ -136,9 +128,9 @@
* <p/>
* If no Set - no exclude filter
*
- * @parameter expression="${helper.excludes}" default-value=""
* @since 1.0.0
*/
+ @Parameter(property = "helper.excludes", defaultValue = "")
protected String excludes;
/**
@@ -148,9 +140,9 @@
* the property of the root module, because we need to push collected files
* to only one place.
*
- * @parameter expression="${helper.outputDirectory}" default-value="target/collect"
* @since 1.0.0
*/
+ @Parameter(property = "helper.outputDirectory", defaultValue = "target/collect")
protected String outputDirectory;
/**
@@ -158,66 +150,65 @@
* <p/>
* <b>Note :</b> If not Set, will not generate the description file.
*
- * @parameter expression="${helper.descriptionFile}"
* @since 1.0.0
*/
+ @Parameter(property = "helper.descriptionFile")
protected String descriptionFile;
/**
* Un flag pour collecter aussi les fichiers attaches au projet.
*
- * @parameter expression="${helper.includeAttached}" default-value="true"
* @since 1.0.0
*/
+ @Parameter(property = "helper.includeAttached", defaultValue = "true")
protected boolean includeAttached;
/**
* Un flag pour collecter aussi les fichiers des sites attaches au projet.
*
- * @parameter expression="${helper.includeSiteAttached}" default-value="false"
* @since 1.2.2
*/
+ @Parameter(property = "helper.includeSiteAttached", defaultValue = "false")
protected boolean includeSiteAttached;
/**
* Un flag pour recopier les fichiers collectés.
*
- * @parameter expression="${helper.copyFiles}" default-value="true"
* @since 1.0.0
*/
+ @Parameter(property = "helper.copyFiles", defaultValue = "true")
protected boolean copyFiles;
/**
* Un flag pour activer le mode verbeux.
*
- * @parameter expression="${helper.verbose}" default-value="${maven.verbose}"
* @since 1.0.0
*/
+ @Parameter(property = "helper.verbose", defaultValue = "${maven.verbose}")
protected boolean verbose;
/**
* A flag to skip the goal.
*
- * @parameter expression="${helper.skip}" default-value="false"
* @since 1.0.0
*/
+ @Parameter(property = "helper.skip", defaultValue = "false")
protected boolean skip;
/**
* Un flag pour activer le mode verbeux.
*
- * @parameter expression="${helper.dryRun}" default-value="false"
* @since 1.0.0
*/
+ @Parameter(property = "helper.dryRun", defaultValue = "false")
protected boolean dryRun;
/**
* Encoding a utiliser pour lire et ecrire les fichiers.
*
- * @parameter expression="${helper.encoding}" default-value="${project.build.sourceEncoding}"
- * @required
* @since 1.0.0
*/
+ @Parameter(property = "helper.encoding", defaultValue = "${project.build.sourceEncoding}", required = true)
protected String encoding;
/** Files to collect */
@@ -293,7 +284,7 @@
boolean withDescriptionFile = false;
- if (descriptionFile != null && !descriptionFile.trim().isEmpty()) {
+ if (StringUtils.isNotBlank(descriptionFile)) {
description = new File(rootProject.getBasedir(), descriptionFile);
@@ -389,11 +380,9 @@
protected List<File> getFiles() {
- Pattern includePattern = includes == null ||
- includes.trim().isEmpty() ? null :
+ Pattern includePattern = StringUtils.isBlank(includes) ? null :
Pattern.compile(includes.trim());
- Pattern excludePattern = excludes == null ||
- excludes.trim().isEmpty() ? null :
+ Pattern excludePattern = StringUtils.isBlank(excludes) ? null :
Pattern.compile(excludes.trim());
List<File> result = new ArrayList<File>();
@@ -423,7 +412,7 @@
// attach extra files
- if (extraFiles != null && !extraFiles.trim().isEmpty()) {
+ if (StringUtils.isNotBlank(extraFiles)) {
File basedir = project.getBasedir();
for (String path : extraFiles.split(",")) {
Modified: trunk/src/main/java/org/nuiton/helper/plugin/ExecuteRemoteCommandMojo.java
===================================================================
--- trunk/src/main/java/org/nuiton/helper/plugin/ExecuteRemoteCommandMojo.java 2012-07-09 10:20:16 UTC (rev 843)
+++ trunk/src/main/java/org/nuiton/helper/plugin/ExecuteRemoteCommandMojo.java 2012-07-12 16:53:52 UTC (rev 844)
@@ -24,10 +24,14 @@
*/
package org.nuiton.helper.plugin;
-import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang3.StringUtils;
import org.apache.maven.artifact.manager.WagonManager;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.logging.Log;
+import org.apache.maven.plugins.annotations.Component;
+import org.apache.maven.plugins.annotations.LifecyclePhase;
+import org.apache.maven.plugins.annotations.Mojo;
+import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.project.MavenProject;
import org.apache.maven.settings.Proxy;
import org.apache.maven.settings.Server;
@@ -45,82 +49,54 @@
* Mojo to execute on a remote server some scripts.
*
* @author tchemit <chemit(a)codelutin.com>
- * @goal execute-remote-command
- * @phase validate
- * @requiresProject true
- * @requiresOnline true
* @since 1.3.1
*/
+@Mojo(name = "execute-remote-command", defaultPhase = LifecyclePhase.VALIDATE,
+ requiresOnline = true, requiresProject = true)
public class ExecuteRemoteCommandMojo extends AbstractPlugin {
- /**
- * A flag to activate verbose mode.
- *
- * @parameter expression="${helper.verbose}" default-value="${maven.verbose}"
- */
+ /** A flag to activate verbose mode. */
+ @Parameter(property = "helper.verbose", defaultValue = "${maven.verbose}")
protected boolean verbose;
- /**
- * Project.
- *
- * @parameter default-value="${project}"
- * @required
- * @readonly
- */
+ /** Project. */
+ @Component
protected MavenProject project;
- /**
- * Active proxy from settings (if any).
- *
- * @parameter default-value="${settings.activeProxy}"
- * @required
- * @readonly
- */
+ /** Active proxy from settings (if any). */
+ @Parameter(defaultValue = "${settings.activeProxy}", required = true, readonly = true)
protected Proxy proxy;
/**
* Settings.
*
- * @parameter default-value="${settings}"
- * @required
- * @readonly
* @since 1.1.0
*/
+ @Component
protected Settings settings;
/**
* Id of the server to use to obtain user login.
* <p/>
* Must be found in your settings.xml.
- *
- * @parameter expression="${helper.repositoryId}"
- * @required
*/
+ @Parameter(property = "helper.repositoryId", required = true)
protected String repositoryId;
/**
* Url where to execute script.
* <p/>
* The url must contains the wagon protocol (says scp:... or scpexe:...).
- *
- * @parameter expression="${helper.repositoryUrl}"
- * @required
*/
+ @Parameter(property = "helper.repositoryUrl", required = true)
protected String repositoryUrl;
- /**
- * Command to execute on remote server.
- *
- * @parameter expression="${helper.command}"
- * @required
- */
+ /** Command to execute on remote server. */
+ @Parameter(property = "helper.command", required = true)
protected String command;
- /**
- * Wagon manager component.
- *
- * @component
- */
+ /** Wagon manager component. */
+ @Component
protected WagonManager wagonManager;
private CommandExecutor commandExecutor;
@@ -145,7 +121,7 @@
if (server == null) {
throw new MojoExecutionException(
"Could not find server with id '" + repositoryId +
- "', check your settings.xml file.");
+ "', check your settings.xml file.");
}
Repository repository = new Repository(repositoryId, repositoryUrl);
@@ -157,7 +133,7 @@
throw new MojoExecutionException(
"The wagon " + wagon + " is not a command executor, " +
- "will not be able to execute command.");
+ "will not be able to execute command.");
}
commandExecutor = (CommandExecutor) wagon;
Modified: trunk/src/main/java/org/nuiton/helper/plugin/SendEmailMojo.java
===================================================================
--- trunk/src/main/java/org/nuiton/helper/plugin/SendEmailMojo.java 2012-07-09 10:20:16 UTC (rev 843)
+++ trunk/src/main/java/org/nuiton/helper/plugin/SendEmailMojo.java 2012-07-12 16:53:52 UTC (rev 844)
@@ -25,9 +25,12 @@
package org.nuiton.helper.plugin;
-import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang3.StringUtils;
import org.apache.maven.model.Developer;
import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugins.annotations.Component;
+import org.apache.maven.plugins.annotations.Mojo;
+import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.project.MavenProject;
import org.codehaus.plexus.logging.Logger;
import org.codehaus.plexus.logging.console.ConsoleLogger;
@@ -46,89 +49,81 @@
* Send a email.
*
* @author tchemit <chemit(a)codelutin.com>
- * @goal send-email
- * @requiresOnline true
- * @requiresProject true
* @since 1.0.3
*/
+@Mojo(name = "send-email", requiresOnline = true, requiresProject = true)
public class SendEmailMojo extends AbstractPlugin implements PluginWithEncoding {
/**
* Dependance du projet.
*
- * @parameter default-value="${project}"
- * @required
- * @readonly
* @since 1.0.3
*/
+ @Component
protected MavenProject project;
/**
* Un flag pour activer le mode verbeux.
*
- * @parameter expression="${helper.verbose}" default-value="${maven.verbose}"
* @since 1.0.3
*/
+ @Parameter(property = "helper.verbose", defaultValue = "${maven.verbose}")
protected boolean verbose;
/**
* The Velocity template used to format the email announcement.
*
- * @parameter expression="${helper.emailContentFile}"
- * @required
* @since 1.0.3
*/
+ @Parameter(property = "helper.emailContentFile", required = true)
protected File emailContentFile;
/**
* The title of the email to send.
*
- * @parameter expression="${helper.emailTitle}"
- * @required
* @since 1.0.3
*/
+ @Parameter(property = "helper.emailTitle", required = true)
protected String emailTitle;
/**
* Smtp Server.
*
- * @parameter expression="${helper.smtpHost}"
- * @required
* @since 1.0.3
*/
+ @Parameter(property = "helper.smtpHost", required = true)
protected String smtpHost;
/**
* Port.
*
- * @parameter default-value="25" expression="${helper.smtpPort}"
- * @required
* @since 1.0.3
*/
+ @Parameter(property = "helper.smtpPort", defaultValue = "25", required = true)
protected int smtpPort;
/**
* The username used to send the email.
*
- * @parameter expression="${helper.username}"
* @since 1.0.3
*/
+ @Parameter(property = "helper.username")
protected String username;
/**
* The password used to send the email.
*
- * @parameter expression="${helper.password}"
* @since 1.0.3
*/
+ @Parameter(property = "helper.password")
protected String password;
/**
* If the email should be sent in SSL mode.
*
- * @parameter default-value="false" expression="${helper.sslMode}"
* @since 1.0.3
*/
+ @Parameter(property = "helper.sslMode", defaultValue = "false")
protected boolean sslMode;
/**
@@ -138,78 +133,74 @@
* developer is not found, then the first developer in the pom will be
* used.
*
- * @parameter expression="${helper.fromDeveloperId}"
* @since 1.0.3
*/
+ @Parameter(property = "helper.fromDeveloperId")
protected String fromDeveloperId;
/**
* Defines the sender of the announcement if the list of developer is empty
* or if the sender is not a member of the development team.
*
- * @parameter expression="${helper.mailSender}"
* @since 1.0.3
*/
+ @Parameter(property = "helper.mailSender")
protected MailSender mailSender;
/**
* Recipient email address.
*
- * @parameter
- * @required
* @since 1.0.3
*/
+ @Parameter(required = true)
protected List<String> toAddresses;
/**
* Possible senders.
*
- * @parameter expression="${project.developers}"
- * @required
- * @readonly
* @since 1.0.3
*/
+ @Parameter(property = "project.developers", required = true, readonly = true)
protected List<Developer> from;
/**
* Mail content type to use.
*
- * @parameter default-value="text/plain"
- * @required
* @since 1.0.3
*/
+ @Parameter(defaultValue = "text/plain", required = true)
protected String mailContentType;
/**
* The encoding used to read and write files.
*
- * @parameter expression="${helper.encoding}" default-value="${project.build.sourceEncoding}"
* @since 1.0.3
*/
+ @Parameter(property = "helper.encoding", defaultValue = "${project.build.sourceEncoding}")
protected String encoding;
/**
* A flag to skip the goal.
*
- * @parameter expression="${helper.skipSendEmail}" default-value="false"
* @since 1.0.3
*/
+ @Parameter(property = "helper.skipSendEmail", defaultValue = "false")
protected boolean skipSendEmail;
/**
* A flag to test plugin but send nothing to redmine.
*
- * @parameter expression="${dryRun}" default-value="false"
* @since 1.0.3
*/
+ @Parameter(property = "dryRun", defaultValue = "false")
protected boolean dryRun;
/**
* A flag to restirct only one run in a build (for multi-module context).
*
- * @parameter expression="${redmine.runOnce}" default-value="true"
* @since 1.0.3
*/
+ @Parameter(property = "redmine.runOnce", defaultValue = "true")
protected boolean runOnce;
/**
Modified: trunk/src/main/java/org/nuiton/helper/plugin/ShareServerSecretPlugin.java
===================================================================
--- trunk/src/main/java/org/nuiton/helper/plugin/ShareServerSecretPlugin.java 2012-07-09 10:20:16 UTC (rev 843)
+++ trunk/src/main/java/org/nuiton/helper/plugin/ShareServerSecretPlugin.java 2012-07-12 16:53:52 UTC (rev 844)
@@ -25,8 +25,12 @@
package org.nuiton.helper.plugin;
-import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang3.StringUtils;
import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugins.annotations.Component;
+import org.apache.maven.plugins.annotations.LifecyclePhase;
+import org.apache.maven.plugins.annotations.Mojo;
+import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.project.MavenProject;
import org.apache.maven.settings.Server;
import org.apache.maven.settings.Settings;
@@ -51,50 +55,47 @@
* </pre>
*
* @author tchemit <chemit(a)codelutin.com>
- * @goal share-server-secret
- * @phase initialize
- * @requiresProject true
* @since 1.1.0
*/
+@Mojo(name = "share-server-secret", defaultPhase = LifecyclePhase.INITIALIZE, requiresProject = true)
public class ShareServerSecretPlugin extends AbstractPlugin {
/**
* Project.
*
- * @parameter default-value="${project}"
- * @required
- * @readonly
* @since 1.1.0
*/
+ @Component
protected MavenProject project;
+
/**
* Settings.
*
- * @parameter default-value="${settings}"
- * @required
- * @readonly
* @since 1.1.0
*/
+ @Component
protected Settings settings;
+
/**
* Server id to use for authentication (must be defined in your setting
* and use the maven >= 2.1.0 password encryption mecanism).
* <p/>
*
- * @parameter expression="${helper.serverId}"
- * @required
* @since 1.1.0
*/
+ @Parameter(property = "helper.serverId", required = true)
protected String serverId;
+
/**
* The name of the property where to export the username of the server.
* <p/>
* <b>Note:</b> If not set - then no export of the username of the server.
*
- * @parameter
* @since 1.1.0
*/
+ @Parameter
protected String usernameOut;
+
/**
* The name of the property where to export the password of the server.
* <p/>
@@ -103,10 +104,11 @@
* <b>Note:</b> If the password is crypted (since maven 2.1.0) then
* decrypt it.
*
- * @parameter
* @since 1.1.0
*/
+ @Parameter
protected String passwordOut;
+
/**
* The name of the property where to export the passphrase of the server.
* <p/>
@@ -115,50 +117,52 @@
* <b>Note:</b> If the passphrase is crypted (since maven 2.1.0) then
* decrypt it.
*
- * @parameter
* @since 1.1.0
*/
+ @Parameter
protected String passphraseOut;
+
/**
* The name of the property where to export the private key of the server.
* <p/>
* <b>Note:</b> If not set - then no export of the private key of the server.
*
- * @parameter
* @since 1.1.0
*/
+ @Parameter
protected String privateKeyOut;
+
/**
* A flag to activate verbose mode.
*
- * @parameter expression="${helper.verbose}" default-value="${maven.verbose}"
* @since 1.1.0
*/
+ @Parameter(property = "helper.verbose", defaultValue = "${maven.verbose}")
protected boolean verbose;
+
/**
* A flag to execute only once the mojo.
* <p/>
* <b>Note:</b> By default, value is {@code true} since it is not necessary
* to inject twice secrets in session.
*
- * @parameter expression="${helper.runOnce}" default-value="true"
* @since 1.1.0
*/
+ @Parameter(property = "helper.runOnce", defaultValue = "true")
protected boolean runOnce;
+
/**
* password decypher
*
- * @component roleHint="maven-helper-plugin"
* @since 1.1.0
*/
+ @Component(hint = "maven-helper-plugin")
protected SecDispatcher sec;
- /**
- * the server to use to obtain secrets
- */
+
+ /** the server to use to obtain secrets */
private Server server;
- /**
- * server secrets to expose
- */
+
+ /** server secrets to expose */
private Map<Property, String> propertiesToTreate;
public enum Property {
1
0
Author: tchemit
Date: 2012-07-09 12:20:16 +0200 (Mon, 09 Jul 2012)
New Revision: 843
Url: http://nuiton.org/repositories/revision/maven-helper-plugin/843
Log:
updates to mavenpom 3.3.4
refs #925: Use maven-plugin-plugin 3 api (change pom)
Modified:
trunk/pom.xml
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2012-05-30 10:15:07 UTC (rev 842)
+++ trunk/pom.xml 2012-07-09 10:20:16 UTC (rev 843)
@@ -34,7 +34,7 @@
<parent>
<groupId>org.nuiton</groupId>
<artifactId>mavenpom4redmineAndCentral</artifactId>
- <version>3.3.2</version>
+ <version>3.3.4</version>
</parent>
<artifactId>helper-maven-plugin</artifactId>
@@ -154,7 +154,15 @@
<scope>provided</scope>
</dependency>
+ <!-- dependencies to mojo annotations -->
<dependency>
+ <groupId>org.apache.maven.plugin-tools</groupId>
+ <artifactId>maven-plugin-annotations</artifactId>
+ <version>${pluginPluginVersion}</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
<groupId>javax.mail</groupId>
<artifactId>mail</artifactId>
<version>1.4.4</version>
@@ -317,6 +325,21 @@
<plugins>
<plugin>
+ <artifactId>maven-plugin-plugin</artifactId>
+ <configuration>
+ <skipErrorNoDescriptorsFound>true</skipErrorNoDescriptorsFound>
+ </configuration>
+ <executions>
+ <execution>
+ <goals>
+ <goal>helpmojo</goal>
+ <goal>descriptor</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+
+ <plugin>
<artifactId>maven-jar-plugin</artifactId>
<executions>
<execution>
@@ -378,6 +401,33 @@
</reportSet>
</reportSets>
</plugin>
+ <plugin>
+ <artifactId>maven-javadoc-plugin</artifactId>
+ <version>${javadocPluginVersion}</version>
+ <configuration>
+ <quiet>true</quiet>
+ <tagletArtifacts>
+ <tagletArtifact>
+ <groupId>org.apache.maven.plugin-tools</groupId>
+ <artifactId>maven-plugin-tools-javadoc</artifactId>
+ <version>${pluginPluginVersion}</version>
+ </tagletArtifact>
+ <tagletArtifact>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-component-javadoc</artifactId>
+ <version>1.5.5</version>
+ </tagletArtifact>
+ </tagletArtifacts>
+ </configuration>
+ <reportSets>
+ <reportSet>
+ <reports>
+ <report>javadoc</report>
+ <report>test-javadoc</report>
+ </reports>
+ </reportSet>
+ </reportSets>
+ </plugin>
</plugins>
</reporting>
</profile>
1
0
Author: ymartel
Date: 2012-05-30 12:15:07 +0200 (Wed, 30 May 2012)
New Revision: 842
Url: http://nuiton.org/repositories/revision/maven-helper-plugin/842
Log:
update to mavenpom 3.3.2
Modified:
trunk/
trunk/pom.xml
trunk/src/site/site_en.xml
Property changes on: trunk
___________________________________________________________________
Modified: svn:ignore
- *.ipr
*.iws
*.iml
*.log
.project
.classpath
.settings
target
+ *.ipr
*.iws
*.iml
*.log
.project
.classpath
.settings
target
.idea
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2012-03-25 14:23:27 UTC (rev 841)
+++ trunk/pom.xml 2012-05-30 10:15:07 UTC (rev 842)
@@ -34,7 +34,7 @@
<parent>
<groupId>org.nuiton</groupId>
<artifactId>mavenpom4redmineAndCentral</artifactId>
- <version>3.2</version>
+ <version>3.3.2</version>
</parent>
<artifactId>helper-maven-plugin</artifactId>
@@ -226,7 +226,7 @@
<!-- ************************************************************* -->
<!-- *** Project Information ************************************* -->
<!-- ************************************************************* -->
- <name>Maven helper plugin</name>
+ <name>Helper Maven Plugin</name>
<description>Plugin d'aide pour les projets nuiton</description>
<inceptionYear>2009</inceptionYear>
<url>http://maven-site.nuiton.org/maven-helper-plugin</url>
@@ -235,7 +235,7 @@
<developer>
<name>Tony Chemit</name>
<id>tchemit</id>
- <email>chemit(a)codelutin.com</email>
+ <email>chemit at codelutin dot com</email>
<organization>CodeLutin</organization>
<timezone>+2</timezone>
<roles>
@@ -243,6 +243,16 @@
<role>Developer</role>
</roles>
</developer>
+ <developer>
+ <name>Yannick Martel</name>
+ <id>ymartel</id>
+ <email>martel at codelutin dot com</email>
+ <organization>CodeLutin</organization>
+ <timezone>+2</timezone>
+ <roles>
+ <role>Developer</role>
+ </roles>
+ </developer>
</developers>
<!-- ************************************************************* -->
@@ -346,6 +356,28 @@
<version>${coberturaPluginVersion}</version>
</plugin>
+ <plugin>
+ <artifactId>maven-project-info-reports-plugin</artifactId>
+ <version>${projectInfoReportsPluginVersion}</version>
+ <reportSets>
+ <reportSet>
+ <reports>
+ <report>project-team</report>
+ <report>mailing-list</report>
+ <report>cim</report>
+ <report>issue-tracking</report>
+ <report>license</report>
+ <report>scm</report>
+ <report>dependencies</report>
+ <report>dependency-convergence</report>
+ <report>plugin-management</report>
+ <report>plugins</report>
+ <report>dependency-management</report>
+ <report>summary</report>
+ </reports>
+ </reportSet>
+ </reportSets>
+ </plugin>
</plugins>
</reporting>
</profile>
Modified: trunk/src/site/site_en.xml
===================================================================
--- trunk/src/site/site_en.xml 2012-03-25 14:23:27 UTC (rev 841)
+++ trunk/src/site/site_en.xml 2012-05-30 10:15:07 UTC (rev 842)
@@ -31,6 +31,30 @@
<href>index.html</href>
</bannerLeft>
+ <bannerRight>
+ <src>http://www.codelutin.com/images/lutinorange-codelutin.png</src>
+ <href>http://www.codelutin.com</href>
+ </bannerRight>
+
+ <skin>
+ <groupId>org.apache.maven.skins</groupId>
+ <artifactId>maven-fluido-skin</artifactId>
+ <version>1.2.1</version>
+ </skin>
+
+ <custom>
+ <fluidoSkin>
+ <topBarEnabled>true</topBarEnabled>
+ <googleSearch/>
+ <sideBarEnabled>false</sideBarEnabled>
+ <searchEnabled>true</searchEnabled>
+ <sourceLineNumbersEnabled>true</sourceLineNumbersEnabled>
+ </fluidoSkin>
+ </custom>
+
+ <publishDate position="right" format="dd/MM/yyyy"/>
+ <version position="right"/>
+
<poweredBy>
<logo href="http://maven.apache.org" name="Maven"
img="images/logos/maven-feather.png"/>
@@ -42,6 +66,12 @@
<item name="${project.name}" href="index.html"/>
</breadcrumbs>
+ <links>
+ <item name="nuiton.org" href="http://www.nuiton.org"/>
+ <item name="CodeLutin" href="http://codelutin.com"/>
+ <item name="Libre-Entreprise" href="http://www.libre-entreprise.org/"/>
+ </links>
+
<menu name="User">
<item name="Introduction" href="index.html"/>
<item name="Goals" href="plugin-info.html">
@@ -86,5 +116,24 @@
<menu ref="reports"/>
+ <footer>
+
+ <script type="text/javascript"
+ src="http://maven-site.nuiton.org/public/js/maven-site-nuiton.org.js">
+ </script>
+
+ <div id='projectMetas'
+ projectversion='${project.version}'
+ platform='${project.platform}'
+ projectid='${project.projectId}'
+ scm='${project.scm.connection}'
+ scmwebeditorenabled='${project.scmwebeditorEnabled}'
+ scmwebeditorurl='${project.scmwebeditorUrl}'
+ siteSourcesType='${project.siteSourcesType}'
+ piwikEnabled='${project.piwikEnabled}'
+ piwikId='${project.piwikId}'>
+ </div>
+ </footer>
+
</body>
</project>
1
0
r841 - in trunk: . src/main/java/org/nuiton/io/xpp3 src/test/java/org/nuiton/io/xpp3 src/test/resources/org/nuiton/io/xpp3
by tchemit@users.nuiton.org 25 Mar '12
by tchemit@users.nuiton.org 25 Mar '12
25 Mar '12
Author: tchemit
Date: 2012-03-25 16:23:27 +0200 (Sun, 25 Mar 2012)
New Revision: 841
Url: http://nuiton.org/repositories/revision/maven-helper-plugin/841
Log:
fixes #2031 (improve the xpp3 reader api)
Added:
trunk/src/main/java/org/nuiton/io/xpp3/AttributeValueToProperty.java
trunk/src/main/java/org/nuiton/io/xpp3/TagContentToProperty.java
trunk/src/main/java/org/nuiton/io/xpp3/TagTextContentToProperty.java
trunk/src/test/java/org/nuiton/io/xpp3/CountryRef.java
trunk/src/test/java/org/nuiton/io/xpp3/CountryRefXpp3Reader.java
Modified:
trunk/pom.xml
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/io/xpp3/Identity.java
trunk/src/test/java/org/nuiton/io/xpp3/IdentityXpp3Reader.java
trunk/src/test/java/org/nuiton/io/xpp3/Xpp3ReaderTest.java
trunk/src/test/resources/org/nuiton/io/xpp3/identities.xml
trunk/src/test/resources/org/nuiton/io/xpp3/identities2.xml
trunk/src/test/resources/org/nuiton/io/xpp3/identity.xml
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2012-02-29 12:55:42 UTC (rev 840)
+++ trunk/pom.xml 2012-03-25 14:23:27 UTC (rev 841)
@@ -34,7 +34,7 @@
<parent>
<groupId>org.nuiton</groupId>
<artifactId>mavenpom4redmineAndCentral</artifactId>
- <version>3.1.1</version>
+ <version>3.2</version>
</parent>
<artifactId>helper-maven-plugin</artifactId>
@@ -46,6 +46,11 @@
<!-- compile dependencies -->
<dependency>
+ <groupId>com.google.guava</groupId>
+ <artifactId>guava</artifactId>
+ </dependency>
+
+ <dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</dependency>
Modified: trunk/src/main/java/org/nuiton/io/xpp3/AbstractXpp3Reader.java
===================================================================
--- trunk/src/main/java/org/nuiton/io/xpp3/AbstractXpp3Reader.java 2012-02-29 12:55:42 UTC (rev 840)
+++ trunk/src/main/java/org/nuiton/io/xpp3/AbstractXpp3Reader.java 2012-03-25 14:23:27 UTC (rev 841)
@@ -25,6 +25,7 @@
package org.nuiton.io.xpp3;
+import com.google.common.collect.Sets;
import org.codehaus.plexus.util.xml.pull.MXParser;
import org.codehaus.plexus.util.xml.pull.XmlPullParser;
import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
@@ -33,8 +34,13 @@
import java.io.IOException;
import java.io.Reader;
import java.lang.reflect.Array;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
import java.util.Map.Entry;
+import java.util.Set;
+import java.util.TreeMap;
/**
* An abstract xpp3Reader based on {@link PropertyMapper} to set properties of
@@ -54,8 +60,8 @@
* <p/>
* If you want to do something more complex, override these methods.
*
+ * @param <O> the type of object to be build by the reader
* @author tchemit <chemit(a)codelutin.com>
- * @param <O> the type of object to be build by the reader
* @see PropertyMapper
* @see Xpp3Reader
* @since 1.0.0
@@ -249,6 +255,34 @@
}
/**
+ * Obtain all mappers for a given type.
+ * <p/>
+ * In the result, the keys are now the tag-name of attribute-name.
+ * <p/>
+ * Example :
+ * <pre>
+ * my-tag
+ * my-attribute
+ * </pre>
+ *
+ * @param srcType the target type of the searched mappers
+ * @param tagName the tag target of the searched mappers
+ * @return the dictionnary of mappers for the given type.
+ */
+ public Map<String, PropertyMapper> getMappers(Class<?> srcType, String tagName) {
+ Map<String, PropertyMapper> result =
+ new TreeMap<String, PropertyMapper>();
+ String prefix = srcType.getName() + "#" + tagName + "#";
+ for (Entry<String, PropertyMapper> e : allMappers.entrySet()) {
+ if (e.getKey().startsWith(prefix)) {
+
+ result.put(((AttributeValueToProperty) e.getValue()).getAttributeName(), e.getValue());
+ }
+ }
+ return result;
+ }
+
+ /**
* Parse the xml stream from the given parser and a build the associated
* object.
* <p/>
@@ -279,17 +313,17 @@
* @throws IOException if any io pb
* @throws XmlPullParserException if any parsing pb
*/
- protected <T> T read(String rootTagName,
- Class<T> type,
- XmlPullParser parser,
- boolean strict)
+ public <T> T read(String rootTagName,
+ Class<T> type,
+ XmlPullParser parser,
+ boolean strict)
throws XmlPullParserException, IOException {
// search open tag rootTagName
gotoNextOpenTag(rootTagName, parser);
// can init result
- T result = null;
+ T result;
try {
result = type.newInstance();
} catch (Exception ex) {
@@ -303,6 +337,20 @@
Map<String, PropertyMapper> mappers = getMappers(type);
Set<String> parsed = new HashSet<String>();
+
+ // deal with all attributes
+ {
+ Set<String> attributeParsed = Sets.newHashSet();
+ Map<String, PropertyMapper> attributeMappers = getMappers(type, rootTagName);
+ int attributeCount = parser.getAttributeCount();
+ for (int i = 0; i < attributeCount; i++) {
+ String attributeName = parser.getAttributeName(i);
+ PropertyMapper mapper = attributeMappers.get(attributeName);
+ if (mapper != null) {
+ mapper.setProperty(result, parser, attributeParsed, strict);
+ }
+ }
+ }
try {
// go to next tag
int eventType = parser.next();
@@ -312,7 +360,6 @@
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);
@@ -321,6 +368,20 @@
"Unrecognised tag: '" + parser.getName()
+ "'", parser, null);
}
+
+ // deal with all attributes
+ {
+ Set<String> attributeParsed = Sets.newHashSet();
+ Map<String, PropertyMapper> attributeMappers = getMappers(type, rootTagName);
+ int attributeCount = parser.getAttributeCount();
+ for (int i = 0; i < attributeCount; i++) {
+ String attributeName = parser.getAttributeName(i);
+ PropertyMapper attributeMapper = attributeMappers.get(attributeName);
+ if (attributeMapper != null) {
+ attributeMapper.setProperty(result, parser, attributeParsed, strict);
+ }
+ }
+ }
} else if (eventType == XmlPullParser.END_TAG) {
if (parser.getName().equals(rootTagName)) {
// have reach the end of the object
@@ -376,11 +437,11 @@
* @throws IOException if any io pb
* @throws XmlPullParserException if any parsing pb
*/
- protected <T> T[] readArray(String parentRootTagName,
- String rootTagName,
- Class<T> type,
- XmlPullParser parser,
- boolean strict)
+ public <T> T[] readArray(String parentRootTagName,
+ String rootTagName,
+ Class<T> type,
+ XmlPullParser parser,
+ boolean strict)
throws XmlPullParserException, IOException {
// search open tag parentRootTagName
@@ -501,4 +562,57 @@
parser.getName());
}
}
+
+ protected void addTagTextContentMappers(DataConverter type,
+ boolean onlyOne,
+ String... tagNames) throws IntrospectionException {
+ TagTextContentToProperty.addMapper(
+ getType(),
+ type,
+ onlyOne,
+ allMappers,
+ tagNames
+ );
+ }
+
+ protected void addAttributeValueMappers(DataConverter type,
+ boolean onlyOne,
+ String... attributeNames) throws IntrospectionException {
+ AttributeValueToProperty.addMapper(
+ getType(),
+ type,
+ onlyOne,
+ allMappers,
+ getRootTagName(),
+ attributeNames
+ );
+ }
+
+ protected <O> void addTagContentMapper(Class<O> type,
+ boolean onlyOne,
+ Xpp3Reader<O> reader) throws IntrospectionException {
+ TagContentToProperty.addMapper(
+ getType(),
+ type,
+ onlyOne,
+ allMappers,
+ reader.getRootTagName(),
+ reader,
+ false
+ );
+ }
+
+ protected <O> void addTagContentsMapper(Class<O> type,
+ boolean onlyOne,
+ Xpp3Reader<O> reader) throws IntrospectionException {
+ TagContentToProperty.addMapper(
+ getType(),
+ type,
+ onlyOne,
+ allMappers,
+ reader.getArrayRootTagName(),
+ reader,
+ true
+ );
+ }
}
Added: trunk/src/main/java/org/nuiton/io/xpp3/AttributeValueToProperty.java
===================================================================
--- trunk/src/main/java/org/nuiton/io/xpp3/AttributeValueToProperty.java (rev 0)
+++ trunk/src/main/java/org/nuiton/io/xpp3/AttributeValueToProperty.java 2012-03-25 14:23:27 UTC (rev 841)
@@ -0,0 +1,109 @@
+/*
+ * #%L
+ * Maven helper plugin
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2009 - 2012 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>.
+ * #L%
+ */
+package org.nuiton.io.xpp3;
+
+import org.codehaus.plexus.util.xml.pull.XmlPullParser;
+
+import java.beans.IntrospectionException;
+import java.beans.PropertyDescriptor;
+import java.util.Map;
+
+/**
+ * Property mapper from a attribute content.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.5
+ */
+public class AttributeValueToProperty extends PropertyMapper {
+
+ protected final String attributeName;
+
+ public AttributeValueToProperty(String tagName,
+ String attributeName,
+ String propertyName,
+ Class<?> containerType,
+ DataConverter type,
+ boolean onlyOne,
+ PropertyDescriptor descriptor) {
+ super(tagName,
+ propertyName,
+ containerType,
+ type,
+ onlyOne,
+ descriptor
+ );
+ this.attributeName = attributeName;
+ }
+
+ public String getAttributeName() {
+ return attributeName;
+ }
+
+ protected String getXmlName() {
+ return attributeName;
+ }
+
+ @Override
+ protected Object getDataFromXml(XmlPullParser parser)
+ throws Exception {
+ String t = parser.getAttributeValue("", attributeName);
+ Object result = null;
+ if (t != null && !(t = t.trim()).isEmpty()) {
+ result = type.convert(t);
+ }
+ return result;
+ }
+
+ public static void addMapper(Class<?> containerType,
+ DataConverter type,
+ boolean onlyOne,
+ Map<String, PropertyMapper> allMappers,
+ String tagName,
+ String... attributeNames) throws IntrospectionException,
+ IllegalArgumentException {
+
+ for (String attributeName : attributeNames) {
+
+ // the tag-name is transformed to tagName
+ String propertyName = TAG_NAME_TRANSFORMER.apply(attributeName);
+
+ PropertyDescriptor descriptor = getDescriptor(containerType,
+ propertyName);
+
+ PropertyMapper mapper = new AttributeValueToProperty(
+ tagName,
+ attributeName,
+ propertyName,
+ containerType,
+ type,
+ onlyOne,
+ descriptor
+ );
+ mapper.registerMapper(allMappers, containerType, tagName, attributeName);
+ }
+
+ }
+
+}
Property changes on: trunk/src/main/java/org/nuiton/io/xpp3/AttributeValueToProperty.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Modified: trunk/src/main/java/org/nuiton/io/xpp3/PropertyMapper.java
===================================================================
--- trunk/src/main/java/org/nuiton/io/xpp3/PropertyMapper.java 2012-02-29 12:55:42 UTC (rev 840)
+++ trunk/src/main/java/org/nuiton/io/xpp3/PropertyMapper.java 2012-03-25 14:23:27 UTC (rev 841)
@@ -25,10 +25,17 @@
package org.nuiton.io.xpp3;
+import com.google.common.base.Function;
+import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.builder.ToStringBuilder;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.codehaus.plexus.util.xml.pull.XmlPullParser;
import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
+import java.beans.BeanInfo;
+import java.beans.IntrospectionException;
+import java.beans.Introspector;
import java.beans.PropertyDescriptor;
import java.io.IOException;
import java.text.ParseException;
@@ -46,78 +53,16 @@
* <li>{@link AttributeValueToProperty} to map the text content of a tag
* to a pojo's property</li>
* </ul>
- * <p/>
- * 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, DataConverter, boolean, Map, String...)}</li>
- * <li>{@link Xpp3Helper#addAttributeValueMappers(Class, DataConverter, boolean, Map, String...)}</li>
- * </ul>
*
* @author tchemit <chemit(a)codelutin.com>
* @since 1.0.3
*/
public abstract class PropertyMapper {
- public static class TagTextContentToProperty extends PropertyMapper {
+ /** Logger. */
+ private static final Log log = LogFactory.getLog(PropertyMapper.class);
- public TagTextContentToProperty(String tagName,
- String propertyName,
- Class<?> containerType,
- DataConverter type,
- boolean onlyOne,
- PropertyDescriptor descriptor) {
- super(tagName,
- propertyName,
- containerType,
- type,
- onlyOne,
- descriptor
- );
- }
-
- @Override
- protected Object getDataFromXml(XmlPullParser parser)
- throws 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,
- Class<?> containerType,
- DataConverter type,
- boolean onlyOne,
- PropertyDescriptor descriptor) {
- super(tagName,
- propertyName,
- containerType,
- type,
- onlyOne,
- descriptor
- );
- }
-
- @Override
- protected Object getDataFromXml(XmlPullParser parser)
- throws 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) */
+ /** name of tag. */
protected final String name;
/** the pojo's property to set */
@@ -152,6 +97,10 @@
this.descriptor = descriptor;
}
+ protected String getXmlName() {
+ return name;
+ }
+
protected abstract Object getDataFromXml(XmlPullParser parser)
throws Exception;
@@ -159,15 +108,18 @@
XmlPullParser parser,
Set<String> parsed, boolean strict)
throws XmlPullParserException, IOException {
- if (onlyOne && parsed.contains(name)) {
+ if (onlyOne && parsed.contains(getXmlName())) {
throw new XmlPullParserException(
"Duplicated tag: \'" + parser.getName() + "\'",
parser,
null
);
}
- parsed.add(name);
+ parsed.add(getXmlName());
try {
+ if (log.isInfoEnabled()) {
+ log.info(getXmlName());
+ }
Object r = getDataFromXml(parser);
if (r != null) {
descriptor.getWriteMethod().invoke(src, r);
@@ -183,7 +135,7 @@
throw new XmlPullParserException(e.getMessage());
}
} catch (Exception e) {
- throw new XmlPullParserException(e.getMessage());
+ throw new XmlPullParserException(e.getMessage(), parser, e);
}
}
@@ -225,4 +177,72 @@
toStringBuilder.append("containerType", containerType);
return toStringBuilder.toString();
}
+
+ public static final Function<String, String> TAG_NAME_TRANSFORMER = new Function<String, String>() {
+ @Override
+ public String apply(String input) {
+ String[] parts = input.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]));
+ }
+ }
+ parts = buffer.toString().split("_");
+ 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 result = buffer.toString();
+ return result;
+ }
+ };
+
+ public static String getMapperForTag(Class<?> type) {
+ return type.getName() + "#";
+ }
+
+ public static String getMapperForAttribute(Class<?> type, String attributeName) {
+ return type.getName() + "#" + attributeName + "#";
+ }
+
+ protected static PropertyDescriptor getDescriptor(Class<?> containerType,
+ String propertyName) throws IntrospectionException {
+ 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);
+ }
+ return descriptor;
+ }
+
+ protected void registerMapper(Map<String, PropertyMapper> allMappers,
+ Class<?> containerType,
+ String tagName,
+ String attributeName) {
+ String key;
+ if (attributeName == null) {
+ // tag scope
+ key = getMapperForTag(containerType) + tagName;
+ } else {
+ // attribute scope
+ key = getMapperForAttribute(containerType, tagName) + attributeName;
+ }
+ allMappers.put(key, this);
+ }
}
Added: trunk/src/main/java/org/nuiton/io/xpp3/TagContentToProperty.java
===================================================================
--- trunk/src/main/java/org/nuiton/io/xpp3/TagContentToProperty.java (rev 0)
+++ trunk/src/main/java/org/nuiton/io/xpp3/TagContentToProperty.java 2012-03-25 14:23:27 UTC (rev 841)
@@ -0,0 +1,118 @@
+/*
+ * #%L
+ * Maven helper plugin
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2009 - 2012 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>.
+ * #L%
+ */
+package org.nuiton.io.xpp3;
+
+import org.codehaus.plexus.util.xml.pull.XmlPullParser;
+
+import java.beans.IntrospectionException;
+import java.beans.PropertyDescriptor;
+import java.util.Map;
+
+/**
+ * Property mapper from a tag content to an object.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.5
+ */
+public class TagContentToProperty<O> extends PropertyMapper {
+
+ private final Xpp3Reader<O> reader;
+
+ private final Class<O> datatype;
+
+ private final boolean multiple;
+
+ public TagContentToProperty(String tagName,
+ String propertyName,
+ Class<?> containerType,
+ Class<O> type,
+ boolean onlyOne,
+ PropertyDescriptor descriptor,
+ Xpp3Reader<O> reader,
+ boolean multiple) {
+ super(tagName,
+ propertyName,
+ containerType,
+ null,
+ onlyOne,
+ descriptor
+ );
+ datatype = type;
+ this.reader = reader;
+ this.multiple = multiple;
+ }
+
+ @Override
+ protected Object getDataFromXml(XmlPullParser parser)
+ throws Exception {
+ Object result;
+ if (multiple) {
+ result = reader.readArray(
+ reader.getArrayRootTagName(),
+ reader.getRootTagName(),
+ datatype,
+ parser,
+ true
+ );
+ } else {
+ result = reader.read(
+ reader.getRootTagName(),
+ datatype,
+ parser,
+ true
+ );
+ }
+ return result;
+ }
+
+ public static <O> void addMapper(Class<?> containerType,
+ Class<O> type,
+ boolean onlyOne,
+ Map<String, PropertyMapper> allMappers,
+ String tagName,
+ Xpp3Reader<O> reader,
+ boolean multiple
+ ) throws IntrospectionException,
+ IllegalArgumentException {
+
+ // the tag-name is transformed to tagName
+ String propertyName = TAG_NAME_TRANSFORMER.apply(tagName);
+
+ PropertyDescriptor descriptor = getDescriptor(containerType,
+ propertyName);
+
+ PropertyMapper mapper = new TagContentToProperty<O>(
+ tagName,
+ propertyName,
+ containerType,
+ type,
+ onlyOne,
+ descriptor,
+ reader,
+ multiple
+ );
+ mapper.registerMapper(allMappers, containerType, tagName, null);
+ }
+}
Property changes on: trunk/src/main/java/org/nuiton/io/xpp3/TagContentToProperty.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/src/main/java/org/nuiton/io/xpp3/TagTextContentToProperty.java
===================================================================
--- trunk/src/main/java/org/nuiton/io/xpp3/TagTextContentToProperty.java (rev 0)
+++ trunk/src/main/java/org/nuiton/io/xpp3/TagTextContentToProperty.java 2012-03-25 14:23:27 UTC (rev 841)
@@ -0,0 +1,92 @@
+/*
+ * #%L
+ * Maven helper plugin
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2009 - 2012 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>.
+ * #L%
+ */
+package org.nuiton.io.xpp3;
+
+import org.codehaus.plexus.util.xml.pull.XmlPullParser;
+
+import java.beans.IntrospectionException;
+import java.beans.PropertyDescriptor;
+import java.util.Map;
+
+/**
+ * Property mapp from a tag text content.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.5
+ */
+public class TagTextContentToProperty extends PropertyMapper {
+
+ public TagTextContentToProperty(String tagName,
+ String propertyName,
+ Class<?> containerType,
+ DataConverter type,
+ boolean onlyOne,
+ PropertyDescriptor descriptor) {
+ super(tagName,
+ propertyName,
+ containerType,
+ type,
+ onlyOne,
+ descriptor
+ );
+ }
+
+ @Override
+ protected Object getDataFromXml(XmlPullParser parser)
+ throws Exception {
+ String t = parser.nextText();
+ Object result = null;
+ if (t != null && !(t = t.trim()).isEmpty()) {
+ result = type.convert(t);
+ }
+ return result;
+ }
+
+ public static void addMapper(Class<?> containerType,
+ DataConverter type,
+ boolean onlyOne,
+ Map<String, PropertyMapper> allMappers,
+ String... tagNames) throws IntrospectionException {
+ for (String tagName : tagNames) {
+
+ // the tag-name is transformed to tagName
+ String propertyName = TAG_NAME_TRANSFORMER.apply(tagName);
+
+ PropertyDescriptor descriptor = getDescriptor(containerType,
+ propertyName);
+
+
+ PropertyMapper mapper = new TagTextContentToProperty(
+ tagName,
+ propertyName,
+ containerType,
+ type,
+ onlyOne,
+ descriptor
+ );
+ mapper.registerMapper(allMappers, containerType, tagName, null);
+ }
+ }
+}
Property changes on: trunk/src/main/java/org/nuiton/io/xpp3/TagTextContentToProperty.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Modified: trunk/src/main/java/org/nuiton/io/xpp3/Xpp3Helper.java
===================================================================
--- trunk/src/main/java/org/nuiton/io/xpp3/Xpp3Helper.java 2012-02-29 12:55:42 UTC (rev 840)
+++ trunk/src/main/java/org/nuiton/io/xpp3/Xpp3Helper.java 2012-03-25 14:23:27 UTC (rev 841)
@@ -25,25 +25,16 @@
package org.nuiton.io.xpp3;
-import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.codehaus.plexus.util.IOUtil;
import org.codehaus.plexus.util.xml.pull.XmlPullParser;
import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
-import org.nuiton.io.xpp3.PropertyMapper.AttributeValueToProperty;
-import org.nuiton.io.xpp3.PropertyMapper.TagTextContentToProperty;
-import java.beans.BeanInfo;
-import java.beans.IntrospectionException;
-import java.beans.Introspector;
-import java.beans.PropertyDescriptor;
import java.io.IOException;
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;
@@ -60,6 +51,7 @@
* @since 1.0.3
*/
public class Xpp3Helper {
+
/** Logger */
private static final Log log = LogFactory.getLog(Xpp3Helper.class);
@@ -194,7 +186,7 @@
/**
* Clean all the registred readers.
* <p/>
- * To reload them, just call a {@link #getReader(java.lang.Class)}.
+ * To reload them, just call a {@link #getReader(Class)}.
*/
public static void clearReaders() {
if (readers != null) {
@@ -477,111 +469,6 @@
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
Modified: trunk/src/main/java/org/nuiton/io/xpp3/Xpp3Reader.java
===================================================================
--- trunk/src/main/java/org/nuiton/io/xpp3/Xpp3Reader.java 2012-02-29 12:55:42 UTC (rev 840)
+++ trunk/src/main/java/org/nuiton/io/xpp3/Xpp3Reader.java 2012-03-25 14:23:27 UTC (rev 841)
@@ -25,6 +25,7 @@
package org.nuiton.io.xpp3;
+import org.codehaus.plexus.util.xml.pull.XmlPullParser;
import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
import java.io.IOException;
@@ -178,4 +179,17 @@
* @param addDefaultEntities the new value.
*/
void setAddDefaultEntities(boolean addDefaultEntities);
+
+ <T> T[] readArray(String parentRootTagName,
+ String rootTagName,
+ Class<T> type,
+ XmlPullParser parser,
+ boolean strict)
+ throws XmlPullParserException, IOException;
+
+ <T> T read(String rootTagName,
+ Class<T> type,
+ XmlPullParser parser,
+ boolean strict)
+ throws XmlPullParserException, IOException;
}
Added: trunk/src/test/java/org/nuiton/io/xpp3/CountryRef.java
===================================================================
--- trunk/src/test/java/org/nuiton/io/xpp3/CountryRef.java (rev 0)
+++ trunk/src/test/java/org/nuiton/io/xpp3/CountryRef.java 2012-03-25 14:23:27 UTC (rev 841)
@@ -0,0 +1,60 @@
+/*
+ * #%L
+ * Maven helper plugin
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2009 - 2012 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>.
+ * #L%
+ */
+package org.nuiton.io.xpp3;
+
+/**
+ * Define a country ref
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.5
+ */
+public class CountryRef {
+
+ protected int id;
+
+ public int getId() {
+ return id;
+ }
+
+ public void setId(int id) {
+ this.id = id;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (!(o instanceof CountryRef)) return false;
+
+ CountryRef that = (CountryRef) o;
+
+ return id == that.id;
+
+ }
+
+ @Override
+ public int hashCode() {
+ return id;
+ }
+}
Property changes on: trunk/src/test/java/org/nuiton/io/xpp3/CountryRef.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/src/test/java/org/nuiton/io/xpp3/CountryRefXpp3Reader.java
===================================================================
--- trunk/src/test/java/org/nuiton/io/xpp3/CountryRefXpp3Reader.java (rev 0)
+++ trunk/src/test/java/org/nuiton/io/xpp3/CountryRefXpp3Reader.java 2012-03-25 14:23:27 UTC (rev 841)
@@ -0,0 +1,51 @@
+/*
+ * #%L
+ * Maven helper plugin
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2009 - 2012 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>.
+ * #L%
+ */
+package org.nuiton.io.xpp3;
+
+import java.beans.IntrospectionException;
+
+/**
+ * To read {@link CountryRef}.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.5
+ */
+public class CountryRefXpp3Reader extends AbstractXpp3Reader<CountryRef> {
+
+ public CountryRefXpp3Reader() {
+ this("countryRefs", "country");
+ }
+
+ public CountryRefXpp3Reader(String root, String tag) {
+ super(CountryRef.class, root, tag);
+ }
+
+ @Override
+ protected void initMappers() throws IntrospectionException {
+
+ addAttributeValueMappers(DefaultDataConverter.Integer, true,
+ "id");
+ }
+}
\ No newline at end of file
Property changes on: trunk/src/test/java/org/nuiton/io/xpp3/CountryRefXpp3Reader.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Modified: trunk/src/test/java/org/nuiton/io/xpp3/Identity.java
===================================================================
--- trunk/src/test/java/org/nuiton/io/xpp3/Identity.java 2012-02-29 12:55:42 UTC (rev 840)
+++ trunk/src/test/java/org/nuiton/io/xpp3/Identity.java 2012-03-25 14:23:27 UTC (rev 841)
@@ -44,7 +44,10 @@
protected int age = 51;
+ protected int id;
+ protected CountryRef country;
+
PropertyChangeSupport p;
public Identity() {
@@ -67,6 +70,9 @@
p.removePropertyChangeListener(propertyName, listener);
}
+ public int getId() {
+ return id;
+ }
public String getFirstName() {
return firstName;
@@ -84,6 +90,17 @@
return age;
}
+ public CountryRef getCountry() {
+ return country;
+ }
+
+ public void setId(int id) {
+ int oldId = this.id;
+ this.id = id;
+ p.firePropertyChange("id", oldId, firstName);
+
+ }
+
public void setFirstName(String firstName) {
String oldFirstName = this.firstName;
this.firstName = firstName;
@@ -107,4 +124,8 @@
this.age = age;
p.firePropertyChange("age", oldAge, age);
}
+
+ public void setCountry(CountryRef country) {
+ this.country = country;
+ }
}
Modified: trunk/src/test/java/org/nuiton/io/xpp3/IdentityXpp3Reader.java
===================================================================
--- trunk/src/test/java/org/nuiton/io/xpp3/IdentityXpp3Reader.java 2012-02-29 12:55:42 UTC (rev 840)
+++ trunk/src/test/java/org/nuiton/io/xpp3/IdentityXpp3Reader.java 2012-03-25 14:23:27 UTC (rev 841)
@@ -33,7 +33,7 @@
* Time: 20:37:56
*/
public class IdentityXpp3Reader extends AbstractXpp3Reader<Identity> {
-
+
public IdentityXpp3Reader() {
this("identities");
}
@@ -45,13 +45,20 @@
@Override
protected void initMappers() throws IntrospectionException {
- org.nuiton.io.xpp3.Xpp3Helper.addTagTextContentMappers(Identity.class, DefaultDataConverter.Text, true, allMappers,
- "firstName",
- "lastName",
- "email");
+ addAttributeValueMappers(DefaultDataConverter.Integer, true,
+ "id");
- org.nuiton.io.xpp3.Xpp3Helper.addTagTextContentMappers(Identity.class, DefaultDataConverter.Integer, true, allMappers,
- "age");
+ addTagTextContentMappers(DefaultDataConverter.Text, true,
+ "firstName",
+ "lastName",
+ "email");
+ addTagTextContentMappers(DefaultDataConverter.Integer, true,
+ "age");
+
+ addTagContentMapper(CountryRef.class, true,
+ new CountryRefXpp3Reader(null, "country"));
+
}
+
}
Modified: trunk/src/test/java/org/nuiton/io/xpp3/Xpp3ReaderTest.java
===================================================================
--- trunk/src/test/java/org/nuiton/io/xpp3/Xpp3ReaderTest.java 2012-02-29 12:55:42 UTC (rev 840)
+++ trunk/src/test/java/org/nuiton/io/xpp3/Xpp3ReaderTest.java 2012-03-25 14:23:27 UTC (rev 841)
@@ -44,7 +44,6 @@
*/
public class Xpp3ReaderTest {
-
protected static File dir;
protected Xpp3Reader<Identity> r = new IdentityXpp3Reader("identities");
@@ -75,10 +74,14 @@
}
Assert.assertNotNull(result);
Identity expected = new Identity();
+ expected.setId(1);
expected.setFirstName("first name");
expected.setLastName("last name");
expected.setEmail("noway(a)bishop.uk");
expected.setAge(29);
+ CountryRef country = new CountryRef();
+ country.setId(1);
+ expected.setCountry(country);
assertEqualsIdentity(result, expected);
}
@@ -156,16 +159,21 @@
Assert.assertEquals(expected.getLastName(), result.getLastName());
Assert.assertEquals(expected.getEmail(), result.getEmail());
Assert.assertEquals(expected.getAge(), result.getAge());
+ Assert.assertEquals(expected.getCountry(), result.getCountry());
}
protected static void assertEqualsSimpleIdentity(Identity result) {
Assert.assertNotNull(result);
Identity expected = new Identity();
+ expected.setId(1);
expected.setFirstName("first name");
expected.setLastName("last name");
expected.setEmail("noway(a)bishop.uk");
expected.setAge(29);
+ CountryRef country = new CountryRef();
+ country.setId(1);
+ expected.setCountry(country);
assertEqualsIdentity(result, expected);
}
@@ -174,18 +182,26 @@
Assert.assertNotNull(result);
Assert.assertEquals(2, result.length);
Identity expected = new Identity();
+ expected.setId(1);
expected.setFirstName("first name");
expected.setLastName("last name");
expected.setEmail("noway(a)bishop.uk");
expected.setAge(29);
+ CountryRef country = new CountryRef();
+ country.setId(1);
+ expected.setCountry(country);
assertEqualsIdentity(result[0], expected);
expected = new Identity();
+ expected.setId(2);
expected.setFirstName("first name2");
expected.setLastName("last name2");
expected.setEmail("noway2(a)bishop.uk");
expected.setAge(31);
+ country = new CountryRef();
+ country.setId(2);
+ expected.setCountry(country);
assertEqualsIdentity(result[1], expected);
}
Modified: trunk/src/test/resources/org/nuiton/io/xpp3/identities.xml
===================================================================
--- trunk/src/test/resources/org/nuiton/io/xpp3/identities.xml 2012-02-29 12:55:42 UTC (rev 840)
+++ trunk/src/test/resources/org/nuiton/io/xpp3/identities.xml 2012-03-25 14:23:27 UTC (rev 841)
@@ -23,16 +23,18 @@
#L%
-->
<identities>
- <identity>
- <firstName>first name</firstName>
- <lastName>last name</lastName>
- <email>noway(a)bishop.uk</email>
- <age>29</age>
- </identity>
- <identity>
- <firstName>first name2</firstName>
- <lastName>last name2</lastName>
- <email>noway2(a)bishop.uk</email>
- <age>31</age>
- </identity>
+ <identity id="1">
+ <country id="1"/>
+ <firstName>first name</firstName>
+ <lastName>last name</lastName>
+ <email>noway(a)bishop.uk</email>
+ <age>29</age>
+ </identity>
+ <identity id="2">
+ <country id="2"/>
+ <firstName>first name2</firstName>
+ <lastName>last name2</lastName>
+ <email>noway2(a)bishop.uk</email>
+ <age>31</age>
+ </identity>
</identities>
\ No newline at end of file
Modified: trunk/src/test/resources/org/nuiton/io/xpp3/identities2.xml
===================================================================
--- trunk/src/test/resources/org/nuiton/io/xpp3/identities2.xml 2012-02-29 12:55:42 UTC (rev 840)
+++ trunk/src/test/resources/org/nuiton/io/xpp3/identities2.xml 2012-03-25 14:23:27 UTC (rev 841)
@@ -23,16 +23,18 @@
#L%
-->
<identity>
- <identity>
- <firstName>first name</firstName>
- <lastName>last name</lastName>
- <email>noway(a)bishop.uk</email>
- <age>29</age>
- </identity>
- <identity>
- <firstName>first name2</firstName>
- <lastName>last name2</lastName>
- <email>noway2(a)bishop.uk</email>
- <age>31</age>
- </identity>
+ <identity id="1">
+ <country id="1"/>
+ <firstName>first name</firstName>
+ <lastName>last name</lastName>
+ <email>noway(a)bishop.uk</email>
+ <age>29</age>
+ </identity>
+ <identity id="2">
+ <country id="2"/>
+ <firstName>first name2</firstName>
+ <lastName>last name2</lastName>
+ <email>noway2(a)bishop.uk</email>
+ <age>31</age>
+ </identity>
</identity>
\ No newline at end of file
Modified: trunk/src/test/resources/org/nuiton/io/xpp3/identity.xml
===================================================================
--- trunk/src/test/resources/org/nuiton/io/xpp3/identity.xml 2012-02-29 12:55:42 UTC (rev 840)
+++ trunk/src/test/resources/org/nuiton/io/xpp3/identity.xml 2012-03-25 14:23:27 UTC (rev 841)
@@ -22,9 +22,10 @@
<http://www.gnu.org/licenses/lgpl-3.0.html>.
#L%
-->
-<identity>
- <firstName>first name</firstName>
- <lastName>last name</lastName>
- <email>noway(a)bishop.uk</email>
- <age>29</age>
+<identity id="1">
+ <country id="1"/>
+ <firstName>first name</firstName>
+ <lastName>last name</lastName>
+ <email>noway(a)bishop.uk</email>
+ <age>29</age>
</identity>
\ No newline at end of file
1
0
Author: tchemit
Date: 2012-02-29 13:55:42 +0100 (Wed, 29 Feb 2012)
New Revision: 840
Url: http://nuiton.org/repositories/revision/maven-helper-plugin/840
Log:
updates to mavenpom 3.1.1
Modified:
trunk/pom.xml
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2012-01-13 14:09:34 UTC (rev 839)
+++ trunk/pom.xml 2012-02-29 12:55:42 UTC (rev 840)
@@ -34,7 +34,7 @@
<parent>
<groupId>org.nuiton</groupId>
<artifactId>mavenpom4redmineAndCentral</artifactId>
- <version>3.0.7</version>
+ <version>3.1.1</version>
</parent>
<artifactId>helper-maven-plugin</artifactId>
1
0
Author: maven-release
Date: 2012-01-13 15:09:34 +0100 (Fri, 13 Jan 2012)
New Revision: 839
Url: http://nuiton.org/repositories/revision/maven-helper-plugin/839
Log:
[maven-release-plugin] prepare for next development iteration
Modified:
trunk/pom.xml
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2012-01-13 14:09:34 UTC (rev 838)
+++ trunk/pom.xml 2012-01-13 14:09:34 UTC (rev 839)
@@ -39,7 +39,7 @@
<artifactId>helper-maven-plugin</artifactId>
- <version>1.4</version>
+ <version>1.5-SNAPSHOT</version>
<dependencies>
@@ -245,9 +245,9 @@
<!-- ************************************************************* -->
<scm>
- <connection>scm:svn:http://svn.nuiton.org/svn/maven-helper-plugin/tags/helper-maven-plu…</connection>
- <developerConnection>scm:svn:http://svn.nuiton.org/svn/maven-helper-plugin/tags/helper-maven-plu…</developerConnection>
- <url>http://www.nuiton.org/repositories/browse/maven-helper-plugin/tags/helper-m…</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>
<distributionManagement>
1
0
Author: maven-release
Date: 2012-01-13 15:09:34 +0100 (Fri, 13 Jan 2012)
New Revision: 838
Url: http://nuiton.org/repositories/revision/maven-helper-plugin/838
Log:
[maven-release-plugin] copy for tag helper-maven-plugin-1.4
Added:
tags/helper-maven-plugin-1.4/
Property changes on: tags/helper-maven-plugin-1.4
___________________________________________________________________
Added: svn:ignore
+ *.ipr
*.iws
*.iml
*.log
.project
.classpath
.settings
target
Added: svn:mergeinfo
+
1
0
Author: maven-release
Date: 2012-01-13 15:09:33 +0100 (Fri, 13 Jan 2012)
New Revision: 837
Url: http://nuiton.org/repositories/revision/maven-helper-plugin/837
Log:
[maven-release-plugin] prepare release helper-maven-plugin-1.4
Modified:
trunk/pom.xml
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2012-01-13 11:14:23 UTC (rev 836)
+++ trunk/pom.xml 2012-01-13 14:09:33 UTC (rev 837)
@@ -39,7 +39,7 @@
<artifactId>helper-maven-plugin</artifactId>
- <version>1.4-SNAPSHOT</version>
+ <version>1.4</version>
<dependencies>
@@ -245,9 +245,9 @@
<!-- ************************************************************* -->
<scm>
- <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>
+ <connection>scm:svn:http://svn.nuiton.org/svn/maven-helper-plugin/tags/helper-maven-plu…</connection>
+ <developerConnection>scm:svn:http://svn.nuiton.org/svn/maven-helper-plugin/tags/helper-maven-plu…</developerConnection>
+ <url>http://www.nuiton.org/repositories/browse/maven-helper-plugin/tags/helper-m…</url>
</scm>
<distributionManagement>
1
0
Author: tchemit
Date: 2012-01-13 12:14:23 +0100 (Fri, 13 Jan 2012)
New Revision: 836
Url: http://nuiton.org/repositories/revision/maven-helper-plugin/836
Log:
T?\195?\162che #1902: Updates to javax.mail 1.4.4
Modified:
trunk/pom.xml
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2012-01-13 10:15:01 UTC (rev 835)
+++ trunk/pom.xml 2012-01-13 11:14:23 UTC (rev 836)
@@ -152,9 +152,7 @@
<dependency>
<groupId>javax.mail</groupId>
<artifactId>mail</artifactId>
- <version>1.4.1</version>
- <!--Use this version when available on central -->
- <!--<version>1.4.3</version>-->
+ <version>1.4.4</version>
</dependency>
<dependency>
1
0
Author: tchemit
Date: 2012-01-13 11:15:01 +0100 (Fri, 13 Jan 2012)
New Revision: 835
Url: http://nuiton.org/repositories/revision/maven-helper-plugin/835
Log:
back to snapshot...
Modified:
trunk/pom.xml
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2012-01-13 10:13:19 UTC (rev 834)
+++ trunk/pom.xml 2012-01-13 10:15:01 UTC (rev 835)
@@ -39,7 +39,7 @@
<artifactId>helper-maven-plugin</artifactId>
- <version>1.4</version>
+ <version>1.4-SNAPSHOT</version>
<dependencies>
1
0