Added saving source files to build/generated directory
This commit is contained in:
parent
878e1033f1
commit
a8d3d7a4ea
1 changed files with 29 additions and 7 deletions
|
@ -3,11 +3,20 @@ package com.example;
|
|||
import rife.bld.BuildCommand;
|
||||
import rife.bld.Project;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
|
||||
import static rife.bld.dependencies.Repository.*;
|
||||
import static rife.bld.dependencies.Scope.compile;
|
||||
|
||||
/**
|
||||
* Example build.
|
||||
*
|
||||
* <ul style="list-style-type:none">
|
||||
* <li>./bld run</li>
|
||||
* <li>./bld runExample</li>
|
||||
* </ul>
|
||||
*/
|
||||
public class ExampleBuild extends Project {
|
||||
public ExampleBuild() {
|
||||
pkg = "com.example";
|
||||
|
@ -20,16 +29,29 @@ public class ExampleBuild extends Project {
|
|||
|
||||
repositories = List.of(MAVEN_LOCAL, MAVEN_CENTRAL);
|
||||
|
||||
scope(compile)
|
||||
.include(dependency("net.thauvin.erik", "semver", version(1, 2, 1, "SNAPSHOT")));
|
||||
}
|
||||
|
||||
@BuildCommand(summary = "Run the example")
|
||||
public void runExample() throws Exception {
|
||||
runOperation().executeOnce(() -> runOperation().fromProject(this).mainClass("com.example.Example"));
|
||||
scope(compile).include(dependency("net.thauvin.erik", "semver", version(1, 2, 1, "SNAPSHOT")));
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
new ExampleBuild().start(args);
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves generated source files in the {@code build/generated} directory.
|
||||
* <p>
|
||||
* To incorporate the generated source code into the source tree, add this directory as an additional source
|
||||
* location in your IDE.
|
||||
*/
|
||||
@Override
|
||||
public void compile() throws Exception {
|
||||
var generated = new File(buildDirectory(), "generated");
|
||||
var ignore = generated.mkdir();
|
||||
this.compileOperation().compileOptions().addAll(List.of("-s", generated.getAbsolutePath()));
|
||||
super.compile();
|
||||
}
|
||||
|
||||
@BuildCommand(summary = "Run the example")
|
||||
public void runExample() throws Exception {
|
||||
runOperation().fromProject(this).mainClass("com.example.Example").execute();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue