Skip to content

Commit

Permalink
Merge pull request #4417 from paulolieuthier/dev-configurable-cwd
Browse files Browse the repository at this point in the history
Make working directory configurable for Gradle's and Maven's dev tasks
  • Loading branch information
stuartwdouglas authored Oct 8, 2019
2 parents d5f982f + c0a7f31 commit f36cf38
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ public class QuarkusPluginExtension {

private String sourceDir;

private String workingDir;

private String outputConfigDirectory;

public QuarkusPluginExtension(Project project) {
Expand Down Expand Up @@ -80,6 +82,18 @@ public void setSourceDir(String sourceDir) {
this.sourceDir = sourceDir;
}

public File workingDir() {
if (workingDir == null) {
workingDir = outputDirectory().getPath();
}

return new File(workingDir);
}

public void setWorkingDir(String workingDir) {
this.workingDir = workingDir;
}

public File wiringClassesDirectory() {
return new File(project.getBuildDir() + File.separator + wiringClassesDirectory);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ public class QuarkusDev extends QuarkusTask {

private String sourceDir;

private String workingDir;

private String jvmArgs;

private boolean preventnoverify = false;
Expand Down Expand Up @@ -104,6 +106,20 @@ public void setSourceDir(String sourceDir) {
this.sourceDir = sourceDir;
}

@Optional
@InputDirectory
public File getWorkingDir() {
if (workingDir == null)
return extension().workingDir();
else
return new File(workingDir);
}

@Option(description = "Set working directory", option = "working-dir")
public void setWorkingDir(String workingDir) {
this.workingDir = workingDir;
}

@Optional
@Input
public String getJvmArgs() {
Expand Down Expand Up @@ -308,7 +324,7 @@ public void startDev() {
ProcessBuilder pb = new ProcessBuilder(args.toArray(new String[0]));
pb.redirectErrorStream(true);
pb.redirectInput(ProcessBuilder.Redirect.INHERIT);
pb.directory(extension.outputDirectory());
pb.directory(getWorkingDir());
System.out.println("Starting process: ");
pb.command().forEach(System.out::println);
System.out.println("Args: ");
Expand Down
5 changes: 4 additions & 1 deletion devtools/maven/src/main/java/io/quarkus/maven/DevMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,9 @@ public class DevMojo extends AbstractMojo {
@Parameter(defaultValue = "${project.build.sourceDirectory}")
private File sourceDir;

@Parameter(defaultValue = "${project.build.directory}")
private File workingDir;

@Parameter(defaultValue = "${jvm.args}")
private String jvmArgs;

Expand Down Expand Up @@ -404,7 +407,7 @@ public void execute() throws MojoFailureException, MojoExecutionException {
pb.redirectError(ProcessBuilder.Redirect.INHERIT);
pb.redirectOutput(ProcessBuilder.Redirect.INHERIT);
pb.redirectInput(ProcessBuilder.Redirect.INHERIT);
pb.directory(outputDirectory);
pb.directory(workingDir);
Process p = pb.start();

//https://github.com/quarkusio/quarkus/issues/232
Expand Down
8 changes: 8 additions & 0 deletions docs/src/main/asciidoc/gradle-tooling.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,14 @@ redeployed application. If there are any issues with compilation or deployment a

Hit `CTRL+C` to stop the application.

You can change the working directory the development environment runs on:

----
quarkusDev {
workingDir = rootProject.projectDir
}
----

== Debugging

In development mode, Quarkus starts by default with debug mode enabled, listening to port `5005` without suspending the JVM.
Expand Down

0 comments on commit f36cf38

Please sign in to comment.