r902 - trunk/helper-maven-plugin-api/src/main/java/org/nuiton/plugin
Author: tchemit Date: 2013-08-07 19:07:33 +0200 (Wed, 07 Aug 2013) New Revision: 902 Url: http://nuiton.org/projects/maven-helper-plugin/repository/revisions/902 Log: improve api Modified: trunk/helper-maven-plugin-api/src/main/java/org/nuiton/plugin/AbstractPlugin.java Modified: trunk/helper-maven-plugin-api/src/main/java/org/nuiton/plugin/AbstractPlugin.java =================================================================== --- trunk/helper-maven-plugin-api/src/main/java/org/nuiton/plugin/AbstractPlugin.java 2013-08-07 16:49:04 UTC (rev 901) +++ trunk/helper-maven-plugin-api/src/main/java/org/nuiton/plugin/AbstractPlugin.java 2013-08-07 17:07:33 UTC (rev 902) @@ -237,7 +237,9 @@ * @param newStartTime the current build start time * @return {@code true} if the goal was already invoked, {@code false} * otherwise (means should run it now!). + * @deprecated since 2.1, prefer use now {@link #needInvoke(boolean, boolean, Date, Date)} */ + @Deprecated protected boolean checkRunOnceDone(boolean runOnce, boolean onlyForRoot, Date buildStartTime, @@ -283,6 +285,60 @@ /** * Check if an execution should be done or not according to the * given parameters. + * + * @param runOnce the flag + * @param onlyForRoot a flag to + * @param buildStartTime the build statrt time (if none means must do it) + * @param newStartTime the current build start time + * {@code true} if the goal should be invoked, {@code false} + * otherwise. + * @since 2.1 + */ + protected boolean needInvoke(boolean runOnce, + boolean onlyForRoot, + Date buildStartTime, + Date newStartTime) { + + if (!runOnce) { + // will run each time + return true; + } + + if (onlyForRoot && !isExecutionRoot()) { + + // never do it for a child + return false; + } + + if (buildStartTime == null) { + // no build start time, so must run + return true; + } + + if (newStartTime == null) { + + // must run + return true; + } + + if (isVerbose()) { + getLog().info("build timestamp : " + buildStartTime); + getLog().info("plugin timestamp : " + newStartTime); + } + + if (newStartTime.getTime() > buildStartTime.getTime()) { + + // was already generated + return false; + } + + // must run + return true; + } + + /** + * Check if an execution should be done or not according to the + * given parameters. * <p/> * Will search if the given {@code key} is found in project, if not then * means that the plugin was not invoked.
participants (1)
-
tchemit@users.nuiton.org