Author: tchemit
Date: 2009-10-11 23:06:16 +0200 (Sun, 11 Oct 2009)
New Revision: 23
Modified:
trunk/maven-jredmine-plugin/pom.xml
trunk/maven-jredmine-plugin/src/main/java/org/nuiton/jredmine/plugin/AbstractRedmineMojo.java
trunk/maven-jredmine-plugin/src/main/java/org/nuiton/jredmine/plugin/DisplayDataMojo.java
trunk/maven-jredmine-plugin/src/main/java/org/nuiton/jredmine/plugin/GenerateChangesMojo.java
trunk/maven-jredmine-plugin/src/main/java/org/nuiton/jredmine/plugin/IssueCollectorConfiguration.java
trunk/maven-jredmine-plugin/src/main/java/org/nuiton/jredmine/plugin/IssuesCollector.java
trunk/maven-jredmine-plugin/src/main/java/org/nuiton/jredmine/plugin/NextVersionMojo.java
trunk/maven-jredmine-plugin/src/main/java/org/nuiton/jredmine/plugin/PublishAttachmentsMojo.java
trunk/maven-jredmine-plugin/src/main/java/org/nuiton/jredmine/plugin/PublishNewsMojo.java
trunk/maven-jredmine-plugin/src/main/java/org/nuiton/jredmine/plugin/UpdateVersionMojo.java
trunk/maven-jredmine-plugin/src/main/java/org/nuiton/jredmine/plugin/announcement/AbstractAnnouncementMojo.java
trunk/maven-jredmine-plugin/src/main/java/org/nuiton/jredmine/plugin/report/AbstractIssuesReport.java
trunk/pom.xml
Log:
Evolution #88: am?\195?\169liorer les caches d'appels vers redmine (a finir pour les rapports)
Modified: trunk/maven-jredmine-plugin/pom.xml
===================================================================
--- trunk/maven-jredmine-plugin/pom.xml 2009-10-10 16:16:32 UTC (rev 22)
+++ trunk/maven-jredmine-plugin/pom.xml 2009-10-11 21:06:16 UTC (rev 23)
@@ -58,6 +58,60 @@
</dependency>
<dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-core</artifactId>
+ <exclusions>
+ <exclusion>
+ <groupId>commons-cli</groupId>
+ <artifactId>commons-cli</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.maven.wagon</groupId>
+ <artifactId>wagon-provider-api</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.maven.wagon</groupId>
+ <artifactId>wagon-http</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.maven.wagon</groupId>
+ <artifactId>wagon-http-lightweight</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.maven.wagon</groupId>
+ <artifactId>wagon-ssh</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.maven.wagon</groupId>
+ <artifactId>wagon-file</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.maven.wagon</groupId>
+ <artifactId>wagon-ssh-external</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.maven.wagon</groupId>
+ <artifactId>wagon-webdav-jackrabbit</artifactId>
+ </exclusion>
+
+ <exclusion>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-error-diagnostics</artifactId>
+ </exclusion>
+
+ <exclusion>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-jdk14</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.slf4j</groupId>
+ <artifactId>jcl-over-slf4j</artifactId>
+ </exclusion>
+
+ </exclusions>
+ </dependency>
+
+ <dependency>
<groupId>org.sonatype.plexus</groupId>
<artifactId>plexus-sec-dispatcher</artifactId>
</dependency>
Modified: trunk/maven-jredmine-plugin/src/main/java/org/nuiton/jredmine/plugin/AbstractRedmineMojo.java
===================================================================
--- trunk/maven-jredmine-plugin/src/main/java/org/nuiton/jredmine/plugin/AbstractRedmineMojo.java 2009-10-10 16:16:32 UTC (rev 22)
+++ trunk/maven-jredmine-plugin/src/main/java/org/nuiton/jredmine/plugin/AbstractRedmineMojo.java 2009-10-11 21:06:16 UTC (rev 23)
@@ -24,6 +24,7 @@
import java.text.DateFormat;
import java.text.SimpleDateFormat;
+import org.apache.maven.execution.MavenSession;
import org.apache.maven.model.IssueManagement;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
@@ -132,6 +133,11 @@
*/
protected boolean verbose;
/**
+ * @parameter expression="${session}"
+ * @readonly
+ */
+ protected MavenSession session;
+ /**
* password decypher
*
* @component roleHint="maven-helper-plugin"
@@ -177,6 +183,10 @@
* the date format used to write a date
*/
protected DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
+ /**
+ * flag to mark if a runOnce goal was done
+ */
+ protected boolean runOnceDone;
public AbstractRedmineMojo(boolean requireProject, boolean requireVersion, boolean requireUser) {
super();
@@ -335,9 +345,48 @@
}
@Override
- public void execute() throws MojoExecutionException, MojoFailureException {
+ public final void execute() throws MojoExecutionException, MojoFailureException {
+
+ boolean canContinue = checkPackaging();
+
+ if (!canContinue) {
+ getLog().warn("The goal is skip due to packaging '" + getProject().getPackaging() + "'");
+ return;
+ }
+
+ if (isGoalSkip()) {
+ getLog().warn("The goal is skip due to skipGoal flag on");
+ return;
+ }
+
try {
- super.execute();
+
+ try {
+
+ canContinue = init();
+
+ } catch (MojoExecutionException e) {
+ throw e;
+ } catch (Exception e) {
+ throw new MojoExecutionException("could not init goal " + getClass().getSimpleName() + " for reason : " + e.getMessage(), e);
+ }
+
+ if (!canContinue) {
+
+ getLog().warn(skipAfterInitMessage);
+ return;
+ }
+
+ try {
+
+ doAction();
+
+ } catch (MojoExecutionException e) {
+ throw e;
+ } catch (Exception e) {
+ throw new MojoExecutionException("could not execute goal " + getClass().getSimpleName() + " for reason : " + e.getMessage(), e);
+ }
+
} finally {
// always close service (it will release connections to redmine)
closeService();
@@ -353,9 +402,15 @@
@Override
protected abstract void doAction() throws Exception;
+ protected abstract boolean isGoalSkip();
+
+ protected abstract boolean isRunOnce();
+
+ protected abstract boolean checkRunOnceDone();
///////////////////////////////////////////////////////////////////////////
/// Plugin
///////////////////////////////////////////////////////////////////////////
+
@Override
public MavenProject getProject() {
return project;
@@ -419,6 +474,10 @@
this.encoding = encoding;
}
+ protected boolean isRunOnceDone() {
+ return runOnceDone;
+ }
+
///////////////////////////////////////////////////////////////////////////
/// Others
///////////////////////////////////////////////////////////////////////////
@@ -508,8 +567,4 @@
}
}
}
-
- protected boolean isExecutionRoot() {
- return project.isExecutionRoot();
- }
}
Modified: trunk/maven-jredmine-plugin/src/main/java/org/nuiton/jredmine/plugin/DisplayDataMojo.java
===================================================================
--- trunk/maven-jredmine-plugin/src/main/java/org/nuiton/jredmine/plugin/DisplayDataMojo.java 2009-10-10 16:16:32 UTC (rev 22)
+++ trunk/maven-jredmine-plugin/src/main/java/org/nuiton/jredmine/plugin/DisplayDataMojo.java 2009-10-11 21:06:16 UTC (rev 23)
@@ -68,6 +68,21 @@
}
@Override
+ protected boolean checkRunOnceDone() {
+ return false;
+ }
+
+ @Override
+ protected boolean isGoalSkip() {
+ return false;
+ }
+
+ @Override
+ protected boolean isRunOnce() {
+ return false;
+ }
+
+ @Override
protected boolean init() throws Exception {
boolean init = super.init();
Modified: trunk/maven-jredmine-plugin/src/main/java/org/nuiton/jredmine/plugin/GenerateChangesMojo.java
===================================================================
--- trunk/maven-jredmine-plugin/src/main/java/org/nuiton/jredmine/plugin/GenerateChangesMojo.java 2009-10-10 16:16:32 UTC (rev 22)
+++ trunk/maven-jredmine-plugin/src/main/java/org/nuiton/jredmine/plugin/GenerateChangesMojo.java 2009-10-11 21:06:16 UTC (rev 23)
@@ -36,7 +36,6 @@
import org.apache.maven.plugins.changes.model.Properties;
import org.apache.maven.plugins.changes.model.Release;
import org.apache.maven.plugins.changes.model.io.xpp3.ChangesXpp3Writer;
-import org.codehaus.plexus.util.FileUtils;
import org.codehaus.plexus.util.xml.XmlStreamWriter;
import org.nuiton.jredmine.model.Issue;
import org.nuiton.jredmine.model.IssueCategory;
@@ -176,31 +175,38 @@
super(true, false, true);
}
+ @Override
protected boolean isGoalSkip() {
return skipGenerateChanges;
}
@Override
- protected boolean init() throws Exception {
+ protected boolean isRunOnce() {
+ return generateOnce;
+ }
- if (isGoalSkip()) {
- return true;
+ @Override
+ protected boolean checkRunOnceDone() {
+
+ if (!isRunOnce()) {
+ // will generate each time
+ return false;
}
- if (generateOnce) {
+ if (cacheChangesFile == null || !cacheChangesFile.exists()) {
- if (cacheChangesFile == null || !cacheChangesFile.exists()) {
+ // the changes.xml does not exists, must generate it
+ return false;
+ }
- // the changes.xml does not exists, must generate it
- generateOnce = false;
- } else {
+ // nothing to generate (so no init)
+ // will just copy the already generated changes.xml file
+ return true;
+ }
- // nothing to generate (so no init)
- // will just copy the already generated changes.xml file
- return true;
- }
- }
-
+ @Override
+ protected boolean init() throws Exception {
+
if (xmlPath == null || xmlPath.getAbsolutePath().trim().isEmpty()) {
throw new MojoExecutionException("required a xmlPath parameter");
}
@@ -211,16 +217,20 @@
versionId = PluginHelper.removeSnapshotSuffix(versionId);
+ runOnceDone = false;
+
+ if (isRunOnce()) {
+ runOnceDone = checkRunOnceDone();
+ if (runOnceDone) {
+ return true;
+ }
+ }
+
boolean result = super.init();
if (!result) {
return false;
}
- File xmlParent = xmlPath.getParentFile();
- if (!xmlParent.exists()) {
- xmlParent.mkdirs();
- }
-
try {
// get trackers
@@ -413,18 +423,23 @@
@Override
protected void doAction() throws Exception {
- if (isGoalSkip()) {
- getLog().warn("skipGoal flag is on, the goal is skip.");
- return;
+ File xmlParent = xmlPath.getParentFile();
+ if (!xmlParent.exists()) {
+ xmlParent.mkdirs();
}
- if (generateOnce) {
- // just copy the already generated changes.xml fil
+ if (isRunOnceDone()) {
- getLog().info("Use already generated " + xmlPath.getName() + " (" + cacheChangesFile + ")");
+ if (!xmlPath.exists()) {
+ // just copy the already generated changes.xml fil
- FileUtils.copyFile(cacheChangesFile, xmlPath);
+ getLog().info("Use already generated " + xmlPath.getName() + " (" + cacheChangesFile + ")");
+ copyFile(cacheChangesFile, xmlPath);
+ } else {
+
+ getLog().info("skip goal, work already done.");
+ }
return;
}
Modified: trunk/maven-jredmine-plugin/src/main/java/org/nuiton/jredmine/plugin/IssueCollectorConfiguration.java
===================================================================
--- trunk/maven-jredmine-plugin/src/main/java/org/nuiton/jredmine/plugin/IssueCollectorConfiguration.java 2009-10-10 16:16:32 UTC (rev 22)
+++ trunk/maven-jredmine-plugin/src/main/java/org/nuiton/jredmine/plugin/IssueCollectorConfiguration.java 2009-10-11 21:06:16 UTC (rev 23)
@@ -49,4 +49,6 @@
String getCategoryIds();
String getTrackerIds();
+
+ boolean isVerbose();
}
Modified: trunk/maven-jredmine-plugin/src/main/java/org/nuiton/jredmine/plugin/IssuesCollector.java
===================================================================
--- trunk/maven-jredmine-plugin/src/main/java/org/nuiton/jredmine/plugin/IssuesCollector.java 2009-10-10 16:16:32 UTC (rev 22)
+++ trunk/maven-jredmine-plugin/src/main/java/org/nuiton/jredmine/plugin/IssuesCollector.java 2009-10-11 21:06:16 UTC (rev 23)
@@ -103,7 +103,9 @@
Version[] versions;
String projectId = config.getProjectId();
- log.info("report project : " + projectId);
+ if (config.isVerbose()) {
+ log.info("report project : " + projectId);
+ }
versions = service.getVersions(projectId);
if (versionIds != null) {
@@ -200,7 +202,9 @@
// no limit
maxEntries = null;
} else {
- log.info("limit issues : " + maxEntries);
+ if (config.isVerbose()) {
+ log.info("limit issues : " + maxEntries);
+ }
}
String projectId = config.getProjectId();
@@ -224,7 +228,9 @@
if (svs.contains(v.getName())) {
// keep the version
versionIds.add(v.getId());
- log.info("use version " + v.getName());
+ if (config.isVerbose()) {
+ log.info("use version " + v.getName());
+ }
}
}
}
@@ -248,7 +254,9 @@
if (svs.contains(id)) {
// keep this status
this.statusIds.add(id);
- log.info("use status " + s.getName());
+ if (config.isVerbose()) {
+ log.info("use status " + s.getName());
+ }
}
}
}
@@ -265,7 +273,9 @@
if (svs.contains(id)) {
// keep this status
this.priorityIds.add(id);
- log.info("use priority " + s.getName());
+ if (config.isVerbose()) {
+ log.info("use priority " + s.getName());
+ }
}
}
}
@@ -282,7 +292,9 @@
if (svs.contains(id)) {
// keep this status
this.categoryIds.add(id);
- log.info("use category " + s.getName());
+ if (config.isVerbose()) {
+ log.info("use category " + s.getName());
+ }
}
}
}
@@ -298,7 +310,9 @@
if (svs.contains(id)) {
// keep this status
this.trackerIds.add(id);
- log.info("use tracker " + s.getName());
+ if (config.isVerbose()) {
+ log.info("use tracker " + s.getName());
+ }
}
}
}
Modified: trunk/maven-jredmine-plugin/src/main/java/org/nuiton/jredmine/plugin/NextVersionMojo.java
===================================================================
--- trunk/maven-jredmine-plugin/src/main/java/org/nuiton/jredmine/plugin/NextVersionMojo.java 2009-10-10 16:16:32 UTC (rev 22)
+++ trunk/maven-jredmine-plugin/src/main/java/org/nuiton/jredmine/plugin/NextVersionMojo.java 2009-10-11 21:06:16 UTC (rev 23)
@@ -96,32 +96,29 @@
* effective date to set
*/
private Date date;
- private boolean runOnceDone;
+// private boolean runOnceDone;
public NextVersionMojo() {
super(true, false, true);
}
+ @Override
protected boolean isGoalSkip() {
return skipNextVersion;
}
@Override
- protected boolean init() throws Exception {
+ protected boolean isRunOnce() {
+ return runOnce;
+ }
- if (isGoalSkip()) {
- return true;
- }
- runOnceDone = false;
- if (runOnce) {
- // check
+ @Override
+ protected boolean checkRunOnceDone() {
+ return isRunOnce() && !isExecutionRoot();
+ }
- if (!isExecutionRoot()) {
- getLog().info("runOnce flag is on, will skip the goal");
- runOnceDone = true;
- return true;
- }
- }
+ @Override
+ protected boolean init() throws Exception {
if (versionId == null || versionId.trim().isEmpty()) {
throw new MojoExecutionException("required a versionId parameter");
@@ -129,6 +126,15 @@
versionId = PluginHelper.removeSnapshotSuffix(versionId);
+ runOnceDone = false;
+
+ if (isRunOnce()) {
+ runOnceDone = checkRunOnceDone();
+ if (runOnceDone) {
+ return true;
+ }
+ }
+
if (effectiveDate != null && !effectiveDate.trim().isEmpty()) {
try {
date = dateFormat.parse(effectiveDate);
@@ -141,13 +147,10 @@
@Override
protected void doAction() throws Exception {
- if (runOnce && runOnceDone) {
+ if (isRunOnceDone()) {
+ getLog().info("skip goal, runOnce flag is on, and was already executed.");
return;
}
- if (isGoalSkip()) {
- getLog().info("skipGoal flag is on, the goal is skip.");
- return;
- }
if (dryRun) {
getLog().info("\n dryRun flag is on, no data will be send!\n");
@@ -155,8 +158,6 @@
// get version
- boolean needCreateVersion;
-
Version[] versions = service.getVersions(projectId);
Version v = ModelHelper.byVersionName(versionId, versions);
@@ -173,12 +174,8 @@
if (v == null) {
// version must be created
- needCreateVersion = true;
v = new Version();
v.setName(versionId);
- } else {
-
- needCreateVersion = false;
}
if (versionDescription != null && !versionDescription.trim().isEmpty()) {
Modified: trunk/maven-jredmine-plugin/src/main/java/org/nuiton/jredmine/plugin/PublishAttachmentsMojo.java
===================================================================
--- trunk/maven-jredmine-plugin/src/main/java/org/nuiton/jredmine/plugin/PublishAttachmentsMojo.java 2009-10-10 16:16:32 UTC (rev 22)
+++ trunk/maven-jredmine-plugin/src/main/java/org/nuiton/jredmine/plugin/PublishAttachmentsMojo.java 2009-10-11 21:06:16 UTC (rev 23)
@@ -86,35 +86,39 @@
*/
private boolean runOnce;
protected List<File> allFiles;
- private boolean runOnceDone;
public PublishAttachmentsMojo() {
super(true, true, true);
}
+ @Override
protected boolean isGoalSkip() {
return skipPublishAttachments;
}
@Override
+ protected boolean isRunOnce() {
+ return runOnce;
+ }
+
+ @Override
+ protected boolean checkRunOnceDone() {
+ return isRunOnce() && !isExecutionRoot();
+ }
+
+ @Override
protected boolean init() throws Exception {
- if (isGoalSkip()) {
+ versionId = PluginHelper.removeSnapshotSuffix(versionId);
- return true;
- }
-
runOnceDone = false;
- if (runOnce) {
- // check
- if (!isExecutionRoot()) {
- getLog().info("runOnce flag is on, will skip the goal");
- runOnceDone = true;
+ if (isRunOnce()) {
+ runOnceDone = checkRunOnceDone();
+ if (runOnceDone) {
return true;
}
}
- versionId = PluginHelper.removeSnapshotSuffix(versionId);
if (!super.init()) {
@@ -153,13 +157,10 @@
@Override
protected void doAction() throws Exception {
- if (runOnce && runOnceDone) {
+ if (isRunOnceDone()) {
+ getLog().info("Skipping goal, runOnce flag is on and goal was already executed.");
return;
}
- if (isGoalSkip()) {
- getLog().info("skipGoal flag is on, the goal is skip.");
- return;
- }
if (dryRun) {
getLog().info("\n dryRun flag is on, no data will be send!\n");
Modified: trunk/maven-jredmine-plugin/src/main/java/org/nuiton/jredmine/plugin/PublishNewsMojo.java
===================================================================
--- trunk/maven-jredmine-plugin/src/main/java/org/nuiton/jredmine/plugin/PublishNewsMojo.java 2009-10-10 16:16:32 UTC (rev 22)
+++ trunk/maven-jredmine-plugin/src/main/java/org/nuiton/jredmine/plugin/PublishNewsMojo.java 2009-10-11 21:06:16 UTC (rev 23)
@@ -81,31 +81,34 @@
* @since 1.0.0
*/
private boolean runOnce;
- private boolean runOnceDone;
+ public PublishNewsMojo() {
+ super(true, false, true);
+ }
+
+ @Override
protected boolean isGoalSkip() {
return skipPublishNews;
}
- public PublishNewsMojo() {
- super(true, false, true);
+ @Override
+ protected boolean checkRunOnceDone() {
+ return isRunOnce() && !isExecutionRoot();
}
@Override
+ protected boolean isRunOnce() {
+ return runOnce;
+ }
+
+ @Override
protected boolean init() throws Exception {
- if (isGoalSkip()) {
-
- return true;
- }
-
runOnceDone = false;
- if (runOnce) {
- // check
- if (!isExecutionRoot()) {
- getLog().info("runOnce flag is on, will skip the goal");
- runOnceDone = true;
+ if (isRunOnce()) {
+ runOnceDone = checkRunOnceDone();
+ if (runOnceDone) {
return true;
}
}
@@ -135,13 +138,11 @@
@Override
protected void doAction() throws Exception {
- if (runOnce && runOnceDone) {
+
+ if (isRunOnceDone()) {
+ getLog().info("skip goal, runOnce flag is on, and was already executed.");
return;
}
- if (isGoalSkip()) {
- getLog().info("skipGoal flag is on, the goal is skip.");
- return;
- }
if (dryRun) {
getLog().info("\n dryRun flag is on, no data will be send!\n");
Modified: trunk/maven-jredmine-plugin/src/main/java/org/nuiton/jredmine/plugin/UpdateVersionMojo.java
===================================================================
--- trunk/maven-jredmine-plugin/src/main/java/org/nuiton/jredmine/plugin/UpdateVersionMojo.java 2009-10-10 16:16:32 UTC (rev 22)
+++ trunk/maven-jredmine-plugin/src/main/java/org/nuiton/jredmine/plugin/UpdateVersionMojo.java 2009-10-11 21:06:16 UTC (rev 23)
@@ -92,39 +92,44 @@
* effective date to set
*/
private Date date;
- private boolean runOnceDone;
public UpdateVersionMojo() {
super(true, false, true);
}
+ @Override
protected boolean isGoalSkip() {
return skipUpdateVersion;
}
@Override
+ protected boolean isRunOnce() {
+ return runOnce;
+ }
+
+ @Override
+ protected boolean checkRunOnceDone() {
+ return isRunOnce() && !isExecutionRoot();
+ }
+
+ @Override
protected boolean init() throws Exception {
- if (isGoalSkip()) {
- return true;
+ if (versionId == null || versionId.trim().isEmpty()) {
+ throw new MojoExecutionException("required a versionId parameter");
}
+
+ versionId = PluginHelper.removeSnapshotSuffix(versionId);
+
runOnceDone = false;
- if (runOnce) {
- // check
- if (!isExecutionRoot()) {
- getLog().info("runOnce flag is on, will skip the goal");
- runOnceDone = true;
+ if (isRunOnce()) {
+ runOnceDone = checkRunOnceDone();
+ if (runOnceDone) {
return true;
}
}
- if (versionId == null || versionId.trim().isEmpty()) {
- throw new MojoExecutionException("required a versionId parameter");
- }
-
- versionId = PluginHelper.removeSnapshotSuffix(versionId);
-
if (effectiveDate != null && !effectiveDate.trim().isEmpty()) {
try {
date = dateFormat.parse(effectiveDate);
@@ -140,14 +145,11 @@
@Override
protected void doAction() throws Exception {
- if (runOnce && runOnceDone) {
+ if (isRunOnceDone()) {
+ getLog().info("skip goal, runOnce flag is on, and was already executed.");
return;
}
- if (isGoalSkip()) {
- getLog().info("skipGoal flag is on, the goal is skip.");
- return;
- }
-
+
if (dryRun) {
getLog().info("\n dryRun flag is on, no data will be send!\n");
}
Modified: trunk/maven-jredmine-plugin/src/main/java/org/nuiton/jredmine/plugin/announcement/AbstractAnnouncementMojo.java
===================================================================
--- trunk/maven-jredmine-plugin/src/main/java/org/nuiton/jredmine/plugin/announcement/AbstractAnnouncementMojo.java 2009-10-10 16:16:32 UTC (rev 22)
+++ trunk/maven-jredmine-plugin/src/main/java/org/nuiton/jredmine/plugin/announcement/AbstractAnnouncementMojo.java 2009-10-11 21:06:16 UTC (rev 23)
@@ -22,6 +22,7 @@
import java.io.File;
import java.util.Collections;
+import java.util.Date;
import java.util.List;
import java.util.Map;
import org.apache.maven.plugin.MojoExecutionException;
@@ -177,36 +178,48 @@
* @component roleHint="maven-jredmine-plugin"
*/
private VelocityComponent velocity;
- private boolean runOnceDone;
protected abstract String getAnnouncementTemplate();
- protected abstract boolean isGoalSkip();
-
protected AbstractAnnouncementMojo() {
super(true, false, true);
}
@Override
+ protected boolean isRunOnce() {
+ return runOnce;
+ }
+
+ /**
+ *
+ * @return {@code true} if the goal was already invoked
+ */
+ @Override
+ protected boolean checkRunOnceDone() {
+
+ String template = getAnnouncementTemplate();
+ File out = new File(templateOutputDirectory, template);
+ Date buildStartTime = session == null ? null : session.getStartTime();
+ Date newStartTime = out.exists() ? new Date(out.lastModified()) : null;
+
+ boolean checkRunOnceDone = checkRunOnceDone(runOnce, true, buildStartTime, newStartTime);
+ return checkRunOnceDone;
+ }
+
+ @Override
protected boolean init() throws Exception {
- if (isGoalSkip()) {
- return true;
- }
+ versionId = PluginHelper.removeSnapshotSuffix(versionId);
runOnceDone = false;
- if (runOnce) {
- // check
- if (!isExecutionRoot()) {
- getLog().info("runOnce flag is on, will skip the goal");
- runOnceDone = true;
+ if (isRunOnce()) {
+ runOnceDone = checkRunOnceDone();
+ if (runOnceDone) {
return true;
}
}
- versionId = PluginHelper.removeSnapshotSuffix(versionId);
-
if (!super.init()) {
return false;
}
@@ -232,15 +245,11 @@
@Override
protected void doAction() throws Exception {
- if (isGoalSkip()) {
- getLog().info("skipGoal flag is on, the goal is skip.");
+ if (isRunOnceDone()) {
+ getLog().info("skip goal, runOnce flag is on, and was already executed.");
return;
}
- if (runOnce && runOnceDone) {
- return;
- }
-
// do upload files to redmine,
ChangesXML changesXml = new ChangesXML(xmlPath, getLog());
Modified: trunk/maven-jredmine-plugin/src/main/java/org/nuiton/jredmine/plugin/report/AbstractIssuesReport.java
===================================================================
--- trunk/maven-jredmine-plugin/src/main/java/org/nuiton/jredmine/plugin/report/AbstractIssuesReport.java 2009-10-10 16:16:32 UTC (rev 22)
+++ trunk/maven-jredmine-plugin/src/main/java/org/nuiton/jredmine/plugin/report/AbstractIssuesReport.java 2009-10-11 21:06:16 UTC (rev 23)
@@ -71,6 +71,21 @@
return getBundle(locale).getString("report.description" + (group == null ? "" : "-" + group));
}
+ @Override
+ protected boolean isRunOnce() {
+ return false;
+ }
+
+ @Override
+ protected boolean checkRunOnceDone() {
+ return false;
+ }
+
+ @Override
+ protected boolean isGoalSkip() {
+ return false;
+ }
+
///////////////////////////////////////////////////////////////////////////
/// Plugin
///////////////////////////////////////////////////////////////////////////
@@ -96,13 +111,8 @@
if (isOnlyCurrentVersion()) {
getLog().info(getBundle(locale).getString("report.message.only.for.current.version") + " " + getVersionId());
}
- String projectId = getProjectId();
+ String id = getProjectId();
- if (verbose) {
- getLog().info("report project " + projectId);
-// getLog().info("report version " + getVersionId());
- }
-
// init issues collector
IssuesCollector collector = new IssuesCollector(getLog(), verbose);
@@ -122,7 +132,7 @@
try {
- if (issues==null || issues.length == 0) {
+ if (issues == null || issues.length == 0) {
getLog().warn("no issue to treate, will generate an empty raport.");
IssueReportGenerator reportGenerator = new IssueReportGenerator();
@@ -137,12 +147,12 @@
report.setUrl(redmineUrl.toString());
report.setIssues(issues);
- report.setUsers(service.getUsers(projectId));
- report.setIssueCategories(service.getIssueCategories(projectId));
+ report.setUsers(service.getUsers(id));
+ report.setIssueCategories(service.getIssueCategories(id));
report.setIssueStatuses(service.getIssueStatuses());
report.setIssuePriorities(service.getIssuePriorities());
- report.setTrackers(service.getTrackers(projectId));
- report.setVersions(service.getVersions(projectId));
+ report.setTrackers(service.getTrackers(id));
+ report.setVersions(service.getVersions(id));
report.doGenerateReport(getBundle(locale), getSink(), getLog());
}
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2009-10-10 16:16:32 UTC (rev 22)
+++ trunk/pom.xml 2009-10-11 21:06:16 UTC (rev 23)
@@ -24,6 +24,12 @@
<artifactId>maven-helper-plugin</artifactId>
<version>${helper.version}</version>
<scope>compile</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>org.apache.maven.wagon</groupId>
+ <artifactId>wagon-provider-api</artifactId>
+ </exclusion>
+ </exclusions>
</dependency>
<!-- fix dependency pb in velocity (need at least version > 2.2) -->
@@ -61,6 +67,13 @@
<version>${maven.version}</version>
<scope>provided</scope>
</dependency>
+
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-core</artifactId>
+ <version>${maven.version}</version>
+ <scope>provided</scope>
+ </dependency>
<dependency>
<groupId>org.sonatype.plexus</groupId>