Author: tchemit Date: 2010-01-24 13:45:40 +0100 (Sun, 24 Jan 2010) New Revision: 109 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/DisplayDataMojo.java trunk/pom.xml Log: update pom 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 2010-01-24 11:43:30 UTC (rev 108) +++ trunk/maven-jredmine-plugin/src/main/java/org/nuiton/jredmine/plugin/AbstractRedmineMojo.java 2010-01-24 12:45:40 UTC (rev 109) @@ -144,6 +144,10 @@ */ private final boolean requireUser; /** + * flag to knwon if anonymùous service is required + */ + private final boolean anonymous; + /** * the project loaded in init if {@link #requireProject} flag is on */ protected Project releaseProject; @@ -167,21 +171,22 @@ * flag to mark if a runOnce goal was done */ protected boolean runOnceDone; + /** * flag to mark if service was sucessfull init */ protected boolean serviceInit; - protected boolean initOk = true; - private boolean anonymous; public AbstractRedmineMojo(boolean requireProject, boolean requireVersion, boolean requireUser) { - super(); + this(false,requireProject,requireVersion,requireUser); + } + + public AbstractRedmineMojo(boolean anonymous, boolean requireProject, boolean requireVersion, boolean requireUser) { + this.anonymous = anonymous; this.requireProject = requireProject; this.requireVersion = requireVersion; this.requireUser = requireUser; - // by default, requires to be loggued - this.anonymous = false; } /////////////////////////////////////////////////////////////////////////// @@ -221,9 +226,14 @@ setRestUrl(url); if (verbose) { - getLog().info("Redmine configuration :\n>> host : " + - getRestUrl() + "\n>> username : " + - getRestUsername()); + if (isAnonymous()) { + getLog().info("Redmine anonymous configuration :\n>> host : " + + getRestUrl()); + } else { + getLog().info("Redmine configuration :\n>> host : " + + getRestUrl() + "\n>> username : " + + getRestUsername()); + } } // init Redmine service @@ -233,14 +243,12 @@ ((RedmineServiceImplementor) service).init(this); serviceInit = true; } catch (Exception e) { - if (safe) { + if (isSafe()) { throw e; } serviceInit = false; initOk = false; -// if (verbose) { getLog().error("could not init Redmine service [" + getRestUrl() + "] with user '" + getRestUsername() + "'", e); -// } } // check project exists @@ -248,7 +256,7 @@ if (requireProject) { boolean r = initReleaseProject(); if (!r) { - if (safe) { + if (isSafe()) { throw new MojoExecutionException("the project '" + projectId + "' could not be retrieve from redmine server."); } initOk = false; @@ -261,7 +269,7 @@ if (requireUser) { boolean r = initReleaseUser(); if (!r) { - if (safe) { + if (isSafe()) { throw new MojoExecutionException("the user '" + this.username + "' could not be retrieve from redmine server."); } initOk = false; @@ -274,7 +282,7 @@ if (requireVersion) { boolean r = initReleaseVersion(); if (!r) { - if (safe) { + if (isSafe()) { throw new MojoExecutionException("the version '" + versionId + "' could not be retrieve from redmine server."); } initOk = false; @@ -322,82 +330,6 @@ closeService(); } -// @Override -// 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; -// } -// -// Exception error = null; -// try { -// -// try { -// -// canContinue = init(); -// -// } catch (Exception e) { -// error = e; -// -// // none safe execution, just warn and not failed the build -// canContinue = false; -// } -// -// if (!canContinue) { -// -// -// if (isSafe()) { -// String message; -// if (error != null) { -// message = "safe mode is on and could not init goal [" + getClass().getSimpleName() + "] for reason " + error.getMessage(); -// } else { -// message = "safe mode is on and could not init goal [" + getClass().getSimpleName() + "]"; -// } -// if (isVerbose()) { -// if (error != null) { -// getLog().error(message, error); -// } else { -// getLog().error(message); -// } -// } -// -// if (error != null) { -// if (error instanceof MojoExecutionException) { -// throw (MojoExecutionException) error; -// } -// throw new MojoExecutionException(message, error); -// } -// throw new MojoExecutionException(message); -// } -// -// 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(); -// } -// } - /** * Re-expose the protected method for test purposes... * @@ -486,7 +418,7 @@ @Override public void setAnonymous(boolean anonymous) { - this.anonymous = true; + //this is a final state, can not modify it after init } /////////////////////////////////////////////////////////////////////////// @@ -508,10 +440,7 @@ this.releaseProject = p; return true; } catch (RedmineServiceException e) { -// getLog().warn("could not retreave project '" + projectId + "', goal is skip"); - if (verbose) { - getLog().error(e); - } + getLog().warn("could not retreave project '" + projectId + "', for reason "+e.getMessage(),e); return false; } } @@ -534,10 +463,7 @@ this.releaseVersion = v; return true; } catch (RedmineServiceException e) { -// getLog().warn("could not retreave version " + versionId + ", goal is skip"); - if (verbose) { - getLog().error(e); - } + getLog().warn("could not retreave version '" + versionId + "', for reason "+e.getMessage(),e); return false; } } @@ -557,10 +483,7 @@ this.releaseUser = user; return true; } catch (RedmineServiceException e) { -// getLog().warn("could not retreave user '" + username + "', goal is skip"); - if (verbose) { - getLog().error(e); - } + getLog().warn("could not retreave user '" + username + "', for reason "+e.getMessage(),e); return false; } } 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 2010-01-24 11:43:30 UTC (rev 108) +++ trunk/maven-jredmine-plugin/src/main/java/org/nuiton/jredmine/plugin/DisplayDataMojo.java 2010-01-24 12:45:40 UTC (rev 109) @@ -84,9 +84,8 @@ protected List<RedmineModelEnum> actions; public DisplayDataMojo() { - super(false, false, false); // no need to be loggued to obtain informations from redmine - setAnonymous(true); + super(true,false, false, false); } @Override @@ -167,10 +166,6 @@ for (String dataType : dataTypes.split(",")) { -// if (dataType.endsWith("s")) { -// dataType = dataType.substring(0, dataType.length() - 1); -// } - RedmineModelEnum result; try { result = RedmineModelEnum.valueOf(dataType.trim()); Modified: trunk/pom.xml =================================================================== --- trunk/pom.xml 2010-01-24 11:43:30 UTC (rev 108) +++ trunk/pom.xml 2010-01-24 12:45:40 UTC (rev 109) @@ -501,7 +501,7 @@ </properties> </profile> - <!-- remove this when using mavenpom4redmine > 2.0.3 --> + <!-- TODO remove this when using mavenpom4redmine > 2.0.3 --> <profile> <id>release-sign-artifacts</id> <activation> @@ -541,9 +541,6 @@ <goals> <goal>sign</goal> </goals> - <configuration> - <keyname></keyname> - </configuration> </execution> </executions> </plugin>