Interface JavaProject

All Superinterfaces:
FileProject, Project
All Known Subinterfaces:
KotlinProject

public interface JavaProject extends FileProject
Extends @link FileProject} with functionality for building Java applications and libraries.

Utility methods are provided for

  • Method Details

    • java

      default void java(String... args)
      Runs a Java process.
      Parameters:
      args - arguments to be supplied to the Java runtime
      See Also:
    • javac

      default Fileset javac(String path, Fileset sources, String... args)
      Compiles Java code.
      Parameters:
      path - the directory path for class files, relative to FileProject.buildPath()
      sources - the source files to compile
      args - the command-line options to be passed to the javac compiler
      Returns:
      a reference to the compiled .class files
      See Also:
    • classpath

      default String classpath(Fileset... filesets)
      Generates a classpath string suitable for the java compiler
      Parameters:
      filesets - a group of filesets
      Returns:
      a colon-delimited list of paths
    • packageResolver

      default PackageResolver packageResolver()
      Gets the package dependency resolver. The default implementation uses Apache Ivy to download packages from the Maven repository.
      Returns:
      the package resolver
    • resolve

      default Fileset resolve(String... identifiers)
      Gets dependencies
      Parameters:
      identifiers - names of dependencies in the format "org:name:revision". If org and name are the same, the format "name:revision" can be used instead.
      Returns:
      a Fileset containing references to the fetched dependencies
    • pkgCachePath

      default String pkgCachePath()
      Gets the location of the package cache
      Returns:
      the path of the package cache directory
    • cleanPkgCache

      default void cleanPkgCache()
      Deletes the package resolver's cache
    • jUnitLib

      default Fileset jUnitLib()
      Specifies the jUnit console and runtime libraries.
      Returns:
      a dependency referencing the jUnit libraries
    • junit

      default Fileset junit(String reportsDir, String... args)
      Runs unit tests using the jUnit console library specified by jUnitLib()
      Parameters:
      reportsDir - the path of generated unit test report, relative to FileProject.buildPath()
      args - command line arguments to the jUnit console runtime
      Returns:
      a fileset referring to the unit test report
      See Also:
    • javadoc

      default Fileset javadoc(String destination, String... args)
      Runs the JavaDoc tool
      Parameters:
      destination - the path of generated unit test report, relative to FileProject.buildPath()
      args - the command-line arguments for the tool
      Returns:
      a reference to the generated documentation
      See Also:
    • jar

      default File jar(String jarPath, Fileset... contents)
      Creates a .jar archive
      Parameters:
      jarPath - the location and name of the generated archive
      contents - references to the files that should be placed in the archive
      Returns:
      a reference to the generated archive