Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
Collapse
Uwyn Logo
  1. Home
  2. Bld
  3. bld Tips & Tricks

bld Tips & Tricks

Scheduled Pinned Locked Moved Bld
tipstricks
2 Posts 1 Posters 267 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • ethauvinE Offline
    ethauvinE Offline
    ethauvin
    wrote on last edited by ethauvin
    #1

    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.

    1 Reply Last reply
    1
    • ethauvinE Offline
      ethauvinE Offline
      ethauvin
      wrote on last edited by ethauvin
      #2

      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.

      Screenshot from 2023-08-20 21-27-10.png

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups