Skip navigation links
org.jerkar.tool.builtins.javabuild

Class JkJavaBuild

    • Field Detail

      • PROVIDED

        public static final JkScope PROVIDED
        A dependency declared with this scope will be available at compile time but won't be part of the packaged product (similar to Maven scope 'provided'.
      • COMPILE

        public static final JkScope COMPILE
        A dependency declared with this scope will be available in all classpaths (compiling, testing, running and packaging the product).

        A dependency resolution made with this scope will only fetch dependencies declared with COMPILE scope and transitive dependencies declared with COMPILE scope as well.

        > CAUTION : When resolving RUNTIME dependencies, transitive 'runtime' dependencies won't be fetched if it's coming to a 'compile' one. In such it differs to Maven 'compile' scope (resolving 'runtime' in Maven will fetch transitive 'runtime' dependencies coming to 'compile' ones). If you want to have a dependency scope equivalent to Maven 'compile', you need to declare dependencies with two scopes : COMPILE and RUNTIME or their shorthand COMPILE_AND_RUNTIME.

      • RUNTIME

        public static final JkScope RUNTIME
        A dependency declared with this scope will be present in the classpath for packaging or running the module. If it is a library, dependencies will be included in the fat jar. If it is a war, dependencies will be included in war file. If it is a main application, dependencies will be part of the runtime classpath.

        A dependency resolution made with this scope will fetch dependencies declared with COMPILE or RUNTIME plus their transitive dependencies declared with COMPILE or RUNTIME.

      • TEST

        public static final JkScope TEST
        A dependency declared with this scope will be present in testing classpath only. A dependency resolution made with this scope will fetch dependencies declared with COMPILE, RUNTIME or TEST plus their transitive dependencies declared with COMPILE, RUNTIME or TEST.
      • SOURCES

        public static final JkScope SOURCES
        This scope is used for publication purpose
      • JAVADOC

        public static final JkScope JAVADOC
        This scope is used for publication purpose
      • COMPILE_AND_RUNTIME

        public static final JkScope[] COMPILE_AND_RUNTIME
        Shorthand to declare both COMPILE and RUNTIME scope at once. This is the default scope for dependencies. It is equivalent to Maven 'compile'.
      • DEFAULT_SCOPE_MAPPING

        public static final JkScopeMapping DEFAULT_SCOPE_MAPPING
      • RESOURCE_FILTER

        public static final JkPathFilter RESOURCE_FILTER
        Filter to excludes everything in a java source directory which are not resources.
      • pack

        public JkJavaBuild.JkOptionPack pack
        Options about packaging jars. This object will be used to populate the default JkJavaPacker for this build. You can override this default setting or set more detailed setting overriding createPacker() method.
    • Constructor Detail

      • JkJavaBuild

        public JkJavaBuild()
    • Method Detail

      • pluginTemplateClasses

        protected java.util.List<java.lang.Class<java.lang.Object>> pluginTemplateClasses()
        Description copied from class: JkBuild
        Returns the classes accepted as template for plugins. If you override it, do not forget to add the ones to the super class.
        Overrides:
        pluginTemplateClasses in class JkBuild
      • sourceEncoding

        public java.lang.String sourceEncoding()
        Returns the encoding of source files for the compiler.
      • javaSourceVersion

        public java.lang.String javaSourceVersion()
        Returns the Java source version for the compiler (as "1.4", 1.6", "7", "8", ...). You can use constants defined in #JkJavaCompiler.
      • javaTargetVersion

        public java.lang.String javaTargetVersion()
        Returns the Java target version for the compiler (as "1.4", 1.6", "7", "8", ...). By default it returns the same version as javaSourceVersion().
      • editedSources

        public JkFileTreeSet editedSources()
        Returns the location of production source code that has been edited manually (not generated).
      • unitTestEditedSources

        public JkFileTreeSet unitTestEditedSources()
        Returns the location of unit test source code that has been edited manually (not generated).
      • sources

        public JkFileTreeSet sources()
        Returns location of production source code (containing edited + generated sources).
      • editedResources

        public JkFileTreeSet editedResources()
        Returns the location of production resources that has been edited manually (not generated).
      • resources

        public JkFileTreeSet resources()
        Returns location of production resources.
      • unitTestSources

        public JkFileTreeSet unitTestSources()
        Returns location of test source code.
      • unitTestResources

        public JkFileTreeSet unitTestResources()
        Returns location of test resources.
      • generatedSourceDir

        public java.io.File generatedSourceDir()
        Returns location of generated sources.
      • generatedResourceDir

        public java.io.File generatedResourceDir()
        Returns location of generated resources.
      • generatedTestResourceDir

        public java.io.File generatedTestResourceDir()
        Returns location of generated resources for tests.
      • classDir

        public java.io.File classDir()
        Returns location where the java production classes are compiled.
      • testReportDir

        public java.io.File testReportDir()
        Returns location where the test reports are written.
      • testClassDir

        public java.io.File testClassDir()
        Returns location where the java production classes are compiled.
      • productionCompiler

        public JkJavaCompiler productionCompiler()
        Returns the compiler used to compile production code.
      • unitTestCompiler

        public JkJavaCompiler unitTestCompiler()
        Returns the compiler used to compile unit tests.
      • unitTester

        public final JkUnit unitTester()
        Returns the object used to process unit tests.
      • createUnitTester

        protected JkUnit createUnitTester()
        Creates the object used to process unit test (compile + run). You can override this method if you want modify the way to process test (output format, classes to tests, JVM agent, ...)
      • javadocMaker

        public JkJavadocMaker javadocMaker()
        Returns the object used to process Javadoc.
      • packer

        public final JkJavaPacker packer()
        Returns the object that produces deliverable files (jar, war, sources, zip, folder, ...) for this project.
      • createPacker

        protected JkJavaPacker createPacker()
        Override this method if you want to create a packager that behave a different way than the default one.
        This will override setting set through JkJavaBuild.JkOptionPack.
        By providing your own packer, you can be more precise about what you want or not to be produced by the build. For example you can create checksum files or specify actions producing/modifying files to package.
      • resourceProcessor

        protected JkResourceProcessor resourceProcessor()
        Override this method if you want to use a another resource processor than the default one. By returning another resource processor, you can embed extra files as resources and/or modify the way interpolation is done.
      • scaffolder

        protected JkScaffolder scaffolder()
        Description copied from class: JkBuild
        Returns the scaffolder object in charge of doing the scaffolding for this build. Override this method if you write a template class that need to do custom action for scaffolding.
        Overrides:
        scaffolder in class JkBuildDependencySupport
      • compile

        public void compile()
        Generates sources and resources, compiles production sources and process production resources to the class directory.
      • unitTest

        public void unitTest()
        Compiles and runs all unit tests.
      • javadoc

        public void javadoc()
        Produces documents for this project (javadoc, Html site, ...)
      • signIfNeeded

        protected final void signIfNeeded(java.io.File... files)
        Signs the specified files with PGP if the option pack.signWithPgp is true. The signature will be detached in the same folder than the signed file and will have the same name but with the .asc suffix.
      • pack

        public void pack()
        Creates many jar files containing respectively binaries, sources, test binaries and test sources.
      • doDefault

        public void doDefault()
        Method executed by default when none is specified. By default this method equals to #deleteArtifacts + #doPack"
        Overrides:
        doDefault in class JkBuild
      • publish

        public void publish()
        Publishes the produced artifact to the defined repositories.
      • generateSources

        protected void generateSources()
        Override this method if you need to generate some production sources
      • generateUnitTestSources

        protected void generateUnitTestSources()
        Override this method if you need to generate some unit test sources.
      • generateResources

        protected void generateResources()
        Override this method if you need to generate some resources.
      • generateUnitTestResources

        protected void generateUnitTestResources()
        Override this method if you need to generate some resources for running unit tests.
      • processResources

        protected void processResources()
        Copies the generated sources for production into the class dir. If you want to do special processing (as interpolating) you should override this method.
      • processUnitTestResources

        protected void processUnitTestResources()
        Copies the generated resources for test into the test class dir. If you want to do special processing (as interpolating) you should override this method.
      • defaultScope

        protected JkScope[] defaultScope()
        Description copied from class: JkBuildDependencySupport
        The scope that will be used when a dependency has been declared without scope. It can be returns null, meaning that when no scope is mentioned then the dependency is always available.
        Overrides:
        defaultScope in class JkBuildDependencySupport
      • mavenPublication

        protected JkMavenPublication mavenPublication()
        Override this method to redefine what should be published on Maven repositories.
      • ivyPublication

        protected JkIvyPublication ivyPublication()
        Override this method to redefine what should be published on Ivy repositories.
      • includeTestsInPublication

        protected boolean includeTestsInPublication()
        Override to include or not tests classes in the published artifacts of the project. Default is false
      • includeSourcesInPublication

        protected boolean includeSourcesInPublication()
        Override this method to include or not sources of the project in the published artifacts. Default is true.
      • jarManifest

        protected JkManifest jarManifest()
        Returns the manifest that will be inserted in generated jars. Override it if you want to add extra infoString.
      • doCompile

        public void doCompile()
        Lifecycle method :#compile. As doCompile is the first stage, this is equals to #compile
      • doUnitTest

        public void doUnitTest()
        Lifecycle method : #doCompile + #unitTest
      • doPack

        public void doPack()
        Lifecycle method : #doUnitTest + #pack
      • doVerify

        public void doVerify()
        Lifecycle method : #doUnitTest + #pack
      • doPublish

        public void doPublish()
        Lifecycle method : #doVerify + #publish
      • infoString

        public java.lang.String infoString()
        Description copied from class: JkBuild
        Returns a formatted string providing information about this build definition.
        Overrides:
        infoString in class JkBuildDependencySupport