Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable on goals #30

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
89 changes: 88 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,91 @@
*.iml
/tmp
/src/test/resources/template
/src/test/resources/template.zip
/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/

2 changes: 2 additions & 0 deletions src/it/projects/disabled-for-goal/invoker.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
invoker.name = TEST for goal
invoker.goals = -e generate-sources -D partial.disableOnGoal=generate-sources
39 changes: 39 additions & 0 deletions src/it/projects/disabled-for-goal/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<modules>
<module>child1</module>
<module>child2</module>
<module>child3</module>
<module>child4</module>
<module>child5</module>
<module>child6</module>
<module>child7</module>
</modules>

<groupId>parent</groupId>
<artifactId>parent</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>pom</packaging>

<build>
<plugins>
<plugin>
<groupId>com.lesfurets</groupId>
<artifactId>partial-build-plugin</artifactId>
<version>@project.version@</version>
<extensions>true</extensions>
<configuration>
<enabled>true</enabled>
<uncommited>false</uncommited>
<referenceBranch>refs/heads/develop</referenceBranch>
<baseBranch>refs/heads/feature/1</baseBranch>
</configuration>
</plugin>
</plugins>
</build>

</project>
8 changes: 8 additions & 0 deletions src/it/projects/disabled-for-goal/setup.groovy
Original file line number Diff line number Diff line change
@@ -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
23 changes: 23 additions & 0 deletions src/it/projects/disabled-for-goal/verify.groovy
Original file line number Diff line number Diff line change
@@ -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;
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ public class Configuration {
public final boolean ignoreAllReactorProjects;
public final boolean useNativeGit;
public final String rootDirectory;
public final List<String> disabledOnGoals;

@Inject
public Configuration(MavenSession session) throws IOException {
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
public enum Property {

enabled("true"),
disableOnGoal(""),
repositorySshKey(""),
referenceBranch("refs/remotes/origin/develop"),
baseBranch("HEAD"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down