bld Tips & Tricks
Bld
2
Posts
1
Posters
320
Views
-
wrote on Aug 20, 2023, 9:42 PM last edited by ethauvin Nov 8, 2023, 7:26 PM
You can use this code in your build file to generate the project's pom in the project's root directory:
@BuildCommand(value = "pom-root", summary = "Generates the POM file in the root directory") public void pomRoot() throws FileUtilsErrorException { PomBuilder.generateInto(publishOperation().fromProject(this).info(), dependencies(), new File(workDirectory, "pom.xml")); }
Putting the pom in the root directory can help with tools like Snyk, SonarCloud, etc. as they will treat your project as a Maven project.
-
wrote on Aug 21, 2023, 4:12 AM last edited by ethauvin Feb 28, 2025, 4:19 PM
Annotation processors are easy to use with bld. Generally, you'll just need to include the processor as a dependency, for example:
public class ExampleBuild extends Project { public ExampleBuild() { // ... scope(provided) .include(dependency("com.example", "annotator", version(1, 0, 0))); } }
If the processor is generating source files, you can easily specify where they should be saved, using the
sourceOutput
compile option, for example:/** * Saves generated source files in the {@code build/generated} directory. */ @Override public void compile() throws Exception { var generated = new File(buildDirectory(), "generated"); var ignore = generated.mkdir(); compileOperation().compileOptions().process(Processing.FULL).sourceOutput(generated); super.compile(); }
To incorporate the generated source code into the source tree, add this directory as an additional source location in your IDE.