From a397fc46bac304787b40539fd061912eccbc1991 Mon Sep 17 00:00:00 2001 From: Marvin Froeder Date: Wed, 17 Jul 2019 17:06:21 +1200 Subject: [PATCH 1/2] Ignoring eclipse IDE files --- .gitignore | 89 +++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 88 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index d9b0e68b..d565491b 100644 --- a/.gitignore +++ b/.gitignore @@ -4,4 +4,91 @@ *.iml /tmp /src/test/resources/template -/src/test/resources/template.zip \ No newline at end of file +/src/test/resources/template.zip + + +# Created by https://www.gitignore.io/api/m2e,maven,eclipse +# Edit at https://www.gitignore.io/?templates=m2e,maven,eclipse + + +### Maven ### +target/ +pom.xml.tag +pom.xml.releaseBackup +pom.xml.versionsBackup +pom.xml.next +release.properties +dependency-reduced-pom.xml +buildNumber.properties +.mvn/timing.properties +.mvn/wrapper/maven-wrapper.jar + +### Eclipse ### +.metadata +bin/ +tmp/ +*.tmp +*.bak +*.swp +*~.nib +local.properties +.settings/ +.loadpath +.recommenders + +# External tool builders +.externalToolBuilders/ + +# Locally stored "Eclipse launch configurations" +*.launch + +# PyDev specific (Python IDE for Eclipse) +*.pydevproject + +# CDT-specific (C/C++ Development Tooling) +.cproject + +# CDT- autotools +.autotools + +# Java annotation processor (APT) +.factorypath + +# PDT-specific (PHP Development Tools) +.buildpath + +# sbteclipse plugin +.target + +# Tern plugin +.tern-project + +# TeXlipse plugin +.texlipse + +# STS (Spring Tool Suite) +.springBeans + +# Code Recommenders +.recommenders/ + +# Annotation Processing +.apt_generated/ + +# Scala IDE specific (Scala & Java development for Eclipse) +.cache-main +.scala_dependencies +.worksheet + +### Eclipse Patch ### +# Eclipse Core +.project + +# JDT-specific (Eclipse Java Development Tools) +.classpath + +# Annotation Processing +.apt_generated + +.sts4-cache/ + From f0d64f80a2953227f66f5a76f05ad242da4397e3 Mon Sep 17 00:00:00 2001 From: Marvin Froeder Date: Wed, 17 Jul 2019 20:39:26 +1200 Subject: [PATCH 2/2] Made possible to disable partial on goal --- .../disabled-for-goal/invoker.properties | 2 + src/it/projects/disabled-for-goal/pom.xml | 39 +++++++++++++++++++ .../projects/disabled-for-goal/setup.groovy | 8 ++++ .../projects/disabled-for-goal/verify.groovy | 23 +++++++++++ .../maven/partial/core/Configuration.java | 2 + .../maven/partial/core/Property.java | 1 + .../extension/MavenLifecycleParticipant.java | 4 +- 7 files changed, 78 insertions(+), 1 deletion(-) create mode 100644 src/it/projects/disabled-for-goal/invoker.properties create mode 100644 src/it/projects/disabled-for-goal/pom.xml create mode 100644 src/it/projects/disabled-for-goal/setup.groovy create mode 100644 src/it/projects/disabled-for-goal/verify.groovy diff --git a/src/it/projects/disabled-for-goal/invoker.properties b/src/it/projects/disabled-for-goal/invoker.properties new file mode 100644 index 00000000..a0967a8a --- /dev/null +++ b/src/it/projects/disabled-for-goal/invoker.properties @@ -0,0 +1,2 @@ +invoker.name = TEST for goal +invoker.goals = -e generate-sources -D partial.disableOnGoal=generate-sources diff --git a/src/it/projects/disabled-for-goal/pom.xml b/src/it/projects/disabled-for-goal/pom.xml new file mode 100644 index 00000000..c932c7b9 --- /dev/null +++ b/src/it/projects/disabled-for-goal/pom.xml @@ -0,0 +1,39 @@ + + + 4.0.0 + + + child1 + child2 + child3 + child4 + child5 + child6 + child7 + + + parent + parent + 1.0-SNAPSHOT + pom + + + + + com.lesfurets + partial-build-plugin + @project.version@ + true + + true + false + refs/heads/develop + refs/heads/feature/1 + + + + + + diff --git a/src/it/projects/disabled-for-goal/setup.groovy b/src/it/projects/disabled-for-goal/setup.groovy new file mode 100644 index 00000000..e806c74e --- /dev/null +++ b/src/it/projects/disabled-for-goal/setup.groovy @@ -0,0 +1,8 @@ +import com.lesfurets.maven.partial.mocks.ITHelper + +def testProjectBasedir = basedir as File +def pbpBaseDir = sourceDir as String +def pbpVersion = projectVersion as String +new ITHelper(testProjectBasedir, pbpBaseDir, pbpVersion).setupTest() + +return true \ No newline at end of file diff --git a/src/it/projects/disabled-for-goal/verify.groovy b/src/it/projects/disabled-for-goal/verify.groovy new file mode 100644 index 00000000..f11b881d --- /dev/null +++ b/src/it/projects/disabled-for-goal/verify.groovy @@ -0,0 +1,23 @@ +import org.codehaus.plexus.util.FileUtils + +def file = new File(basedir, "build.log") +String buildLog = FileUtils.fileRead(file) + +boolean verified = true +verified &= buildLog.contains(" subchild2") +verified &= buildLog.contains(" child3") +verified &= buildLog.contains(" child4") +verified &= buildLog.contains(" subchild41") + +verified &= buildLog.contains(" child1") +verified &= buildLog.contains(" child2") +verified &= buildLog.contains(" child5") +verified &= buildLog.contains(" child6") +verified &= buildLog.contains(" child7") +verified &= buildLog.contains(" subchild1") +verified &= buildLog.contains(" subchild42") +verified &= buildLog.contains(" parent") + +verified &= buildLog.contains("Partial build was disable for goal: [generate-sources]") + +return verified; diff --git a/src/main/java/com/lesfurets/maven/partial/core/Configuration.java b/src/main/java/com/lesfurets/maven/partial/core/Configuration.java index 78355e6a..1c037708 100644 --- a/src/main/java/com/lesfurets/maven/partial/core/Configuration.java +++ b/src/main/java/com/lesfurets/maven/partial/core/Configuration.java @@ -49,6 +49,7 @@ public class Configuration { public final boolean ignoreAllReactorProjects; public final boolean useNativeGit; public final String rootDirectory; + public final List disabledOnGoals; @Inject public Configuration(MavenSession session) throws IOException { @@ -83,6 +84,7 @@ public Configuration(MavenSession session) throws IOException { buildAnywaysPattern = Property.buildAnyways.getValue(); buildAnywaysProjects = getBuildAnywaysProjects(session, buildAnywaysPattern); useNativeGit = Boolean.valueOf(Property.useNativeGit.getValue()); + disabledOnGoals = separatePattern(Property.disableOnGoal.getValue()); rootDirectory = session.getExecutionRootDirectory(); } catch (Exception e) { throw new RuntimeException(e); diff --git a/src/main/java/com/lesfurets/maven/partial/core/Property.java b/src/main/java/com/lesfurets/maven/partial/core/Property.java index e9445467..693ef2eb 100644 --- a/src/main/java/com/lesfurets/maven/partial/core/Property.java +++ b/src/main/java/com/lesfurets/maven/partial/core/Property.java @@ -3,6 +3,7 @@ public enum Property { enabled("true"), + disableOnGoal(""), repositorySshKey(""), referenceBranch("refs/remotes/origin/develop"), baseBranch("HEAD"), diff --git a/src/main/java/com/lesfurets/maven/partial/extension/MavenLifecycleParticipant.java b/src/main/java/com/lesfurets/maven/partial/extension/MavenLifecycleParticipant.java index 5d69f9dc..87820ae6 100644 --- a/src/main/java/com/lesfurets/maven/partial/extension/MavenLifecycleParticipant.java +++ b/src/main/java/com/lesfurets/maven/partial/extension/MavenLifecycleParticipant.java @@ -26,7 +26,9 @@ public void afterProjectsRead(MavenSession session) throws MavenExecutionExcepti logger.info(configuration.toString()); try { - if (configuration.enabled) { + if (configuration.disabledOnGoals.stream().anyMatch(disableForGoal -> session.getRequest().getGoals().contains(disableForGoal))) { + logger.info("Partial build was disable for goal: " + configuration.disabledOnGoals); + } else if (configuration.enabled) { logger.info("Starting Partial build..."); injector.getInstance(UnchangedProjectsRemover.class).act(); } else {