Skip to content

Commit

Permalink
Pull project directory configuration to abstract class
Browse files Browse the repository at this point in the history
  • Loading branch information
lacasseio committed Oct 10, 2019
1 parent b5150dc commit 55fdd1c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,16 @@ private boolean hasSettingsFile(TestFile directory) {
}
//endregion

//region Flag `--project-dir` configuration
private File projectDirectory = null;

@Override
public GradleExecuter usingProjectDirectory(File projectDirectory) {
this.projectDirectory = projectDirectory;
return this;
}
//endregion

//region Flag `--build-cache` configuration
@Override
public GradleExecuter withBuildCacheEnabled() {
Expand Down Expand Up @@ -116,6 +126,7 @@ protected void reset() {
workingDirectory = null;
userHomeDirectory = null;
settingsFile = null;
projectDirectory = null;

showStacktrace = true;
}
Expand All @@ -133,6 +144,10 @@ protected List<String> getAllArguments() {
allArguments.add("--settings-file");
allArguments.add(settingsFile.getAbsolutePath());
}
if (projectDirectory != null) {
allArguments.add("--project-dir");
allArguments.add(projectDirectory.getAbsolutePath());
}
if (showStacktrace) {
allArguments.add("--stacktrace");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,20 +37,13 @@ public class GradleRunnerExecuter extends AbstractGradleExecuter {
private boolean debuggerAttached = false;

private String gradleVersion = null;
private File projectDirectory = null;
private boolean usePluginClasspath = false;
private Map<String, Object> environment = null;

public GradleRunnerExecuter(TestDirectoryProvider testDirectoryProvider) {
super(testDirectoryProvider);
}

@Override
public GradleExecuter usingProjectDirectory(File projectDirectory) {
this.projectDirectory = projectDirectory;
return this;
}

@Override
public GradleExecuter withDebuggerAttached() {
debuggerAttached = true;
Expand Down Expand Up @@ -114,7 +107,6 @@ protected void reset() {
tasks.clear();
debuggerAttached = false;
gradleVersion = null;
projectDirectory = null;
usePluginClasspath = false;
environment = null;
}
Expand Down Expand Up @@ -142,10 +134,6 @@ private GradleRunner configureExecuter() {
}

List<String> allArguments = new ArrayList<>(getAllArguments());
if (projectDirectory != null) {
allArguments.add("--project-dir");
allArguments.add(projectDirectory.getAbsolutePath());
}

allArguments.addAll(tasks);

Expand Down

0 comments on commit 55fdd1c

Please sign in to comment.