branch develop updated (696960b -> e7fa0db)
This is an automated email from the git hooks/post-receive script. New change to branch develop in repository maven-helper-plugin. See http://git.nuiton.org/maven-helper-plugin.git from 696960b Fixes #3895 Merge branch 'feature/3895' into develop new f355d71 Add new mojo to compute and inject distribution site url (See #3896) new e7fa0db Fixes #3896 Merge branch 'feature/3896' into develop The 2 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "adds" were already present in the repository and have only been added to this reference. Detailed log of new commits: commit e7fa0db4806e076f8bda5979ed4e09696deb30e2 Merge: 696960b f355d71 Author: Tony CHEMIT <chemit@codelutin.com> Date: Sat Feb 27 15:03:33 2016 +0100 Fixes #3896 Merge branch 'feature/3896' into develop commit f355d710a35806d91e3d9ae493a7172378d55b68 Author: Tony CHEMIT <chemit@codelutin.com> Date: Sat Feb 27 15:03:18 2016 +0100 Add new mojo to compute and inject distribution site url (See #3896) Summary of changes: .../plugin/ComputeDistributionSiteUrlMojo.java | 147 +++++++++++++++++++++ 1 file changed, 147 insertions(+) create mode 100644 helper-maven-plugin/src/main/java/org/nuiton/helper/plugin/ComputeDistributionSiteUrlMojo.java -- To stop receiving notification emails like this one, please contact nuiton.org SCM administrator <admin+scm@nuiton.org>.
This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository maven-helper-plugin. See http://git.nuiton.org/maven-helper-plugin.git commit f355d710a35806d91e3d9ae493a7172378d55b68 Author: Tony CHEMIT <chemit@codelutin.com> Date: Sat Feb 27 15:03:18 2016 +0100 Add new mojo to compute and inject distribution site url (See #3896) --- .../plugin/ComputeDistributionSiteUrlMojo.java | 147 +++++++++++++++++++++ 1 file changed, 147 insertions(+) diff --git a/helper-maven-plugin/src/main/java/org/nuiton/helper/plugin/ComputeDistributionSiteUrlMojo.java b/helper-maven-plugin/src/main/java/org/nuiton/helper/plugin/ComputeDistributionSiteUrlMojo.java new file mode 100644 index 0000000..faac3c0 --- /dev/null +++ b/helper-maven-plugin/src/main/java/org/nuiton/helper/plugin/ComputeDistributionSiteUrlMojo.java @@ -0,0 +1,147 @@ +package org.nuiton.helper.plugin; + +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.nuiton.plugin.AbstractPlugin; + +import java.util.Properties; + +/** + * To compute distribution site url distinguising url when project version is a snapshot. + * + * Created on 27/02/16. + * + * @author Tony Chemit - chemit@codelutin.com + * @since 2.3 + */ +@Mojo(name = "compute-distribution-site-url", + defaultPhase = LifecyclePhase.VALIDATE, + requiresOnline = true, + requiresProject = true) +public class ComputeDistributionSiteUrlMojo extends AbstractPlugin { + + public static final String SNAPSHOT_SUFFIX = "-SNAPSHOT"; + + /** + * Invoking project's version. + */ + @Parameter(defaultValue = "${project}", required = true, readonly = true) + private MavenProject project; + + /** + * Site deploy classifier to use when project's version is a snapshot. + */ + @Parameter(property = "helper.distributionSiteUrlPrefix", defaultValue = "scpexe://forge.nuiton.org/var/lib/doc/maven-site/${platform}/${projectId}", required = true) + private String distributionSiteUrlPrefix; + + /** + * Site deploy classifier to use when project's version is a snapshot. + */ + @Parameter(property = "helper.snapshotSiteDeployClassifier", defaultValue = "develop", required = true) + private String snapshotSiteDeployClassifier; + + /** + * Site deploy classifier to use when project's version is not a snapshot. + */ + @Parameter(property = "helper.releaseSiteDeployClassifier", defaultValue = "${project.version}", required = true) + private String releaseSiteDeployClassifier; + + /** + * A flag to activate verbose mode. + */ + @Parameter(property = "helper.verbose", defaultValue = "${maven.verbose}") + private boolean verbose; + + /** + * A flag to execute only once the mojo. + * + * <b>Note:</b> By default, value is {@code true} since it is not necessary + * to inject twice secrets in session. + */ + @Parameter(property = "helper.runOnce", defaultValue = "true") + private boolean runOnce; + + private String siteDeployClassifier; + + private String distributionSiteUrl; + + @Override + public boolean checkSkip() { + + boolean result = true; + if (runOnce) { + + // compute the unique key refering to parameters of plugin + String key = "compute-distribution-site-url##" + project.getVersion(); + + // check if plugin was already done. + + boolean shouldInvoke = needInvoke(true, false, key); + + result = shouldInvoke && super.checkSkip(); + } + + return result; + + } + + @Override + protected void init() throws Exception { + + if (project.getVersion().endsWith(SNAPSHOT_SUFFIX)) { + siteDeployClassifier = snapshotSiteDeployClassifier; + if (isVerbose()) { + getLog().info("Use snapshot siteDeployClassifier: " + siteDeployClassifier); + } + } else { + siteDeployClassifier = releaseSiteDeployClassifier; + if (isVerbose()) { + getLog().info("Use release siteDeployClassifier: " + siteDeployClassifier); + } + } + + distributionSiteUrl = distributionSiteUrlPrefix.trim(); + if (!distributionSiteUrl.endsWith("/")) { + distributionSiteUrl += "/"; + } + distributionSiteUrl += siteDeployClassifier; + if (isVerbose()) { + getLog().info("Use release distributionSiteUrl: " + distributionSiteUrl); + } + + } + + @Override + protected void doAction() throws Exception { + + Properties properties = project.getProperties(); + + getLog().info("export siteDeployClassifier [" + siteDeployClassifier + "]"); + + project.getDistributionManagement().getSite().setUrl(distributionSiteUrl); + properties.setProperty("siteDeployClassifier", siteDeployClassifier); + + } + + @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; + } +} -- To stop receiving notification emails like this one, please contact nuiton.org SCM administrator <admin+scm@nuiton.org>.
This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository maven-helper-plugin. See http://git.nuiton.org/maven-helper-plugin.git commit e7fa0db4806e076f8bda5979ed4e09696deb30e2 Merge: 696960b f355d71 Author: Tony CHEMIT <chemit@codelutin.com> Date: Sat Feb 27 15:03:33 2016 +0100 Fixes #3896 Merge branch 'feature/3896' into develop .../plugin/ComputeDistributionSiteUrlMojo.java | 147 +++++++++++++++++++++ 1 file changed, 147 insertions(+) -- To stop receiving notification emails like this one, please contact nuiton.org SCM administrator <admin+scm@nuiton.org>.
participants (1)
-
nuiton.org scm