public final class JkProject extends java.lang.Object implements JkIdeSupportSupplier, JkBuildable.Supplier
JkProject
consists in 4 main parts : JkProjectCompilation
: responsible to generate compile production sourcesJkProjectTesting
: responsible to compile test sources and run tests JkProjectPackaging
: responsible to creates javadoc, sources and jarsJkMavenPublication
: responsible to publish the artifacts on Maven repositoriespack()
method is supposed to generates the artifacts
(or simply perform actions as deploying docker image) locally. By default, it generates
a regular binary jar, but it can be customized for your needs.
The following represents a tree of the JkProject API.
project
+- baseDir
+- outputDir (generally values to ${baseDir}/jeka-output dir)
+- artifactLocator (define paths of created artifact files -jar files- )
| +- methods: getArtifactPath(), getMainArtifactPath(), ....
+- duplicateDependencyConflictStrategy
+- jvmTargetVersion
+- sourceEncoding
+- javaCompileToolChain
+- dependencyResolver
+- compilation (produce individual binary files from production sources. This includes resource processing, code generation, processing on .class files, ...)
| +- layout (where are located sources, resources and compiled classes)
| +- source generators (plugin mechanism for generating source files)
| +- dependencies (stands for compile dependencies)
| +- preCompileActions (including resources processing)
| +- compileActions (including java sources compilation. Compilation for other languages can be added here)
| +- postCompileActions
| +- methods : resolveDependencies(), run()
+- test
| +- testCompilation (same as for 'prod' compilation but configured for tests purpose)
| +- breakOnFailure (true/false)
| +- skipped (true/false)
| +- testProcessor
| | +- forkedProcess (configured the forked process who will run tests)
| | +- preActions
| | +- postActions
| | +- engineBehavior
| | | +- testReportDir
| | | +- progressDisplayer
| | | +- launcherConfiguration (based on junit5 platform API)
| | +- testSelection
| | | +- includePatterns
| | | +- includeTags
| +- method : run()
+- packaging (produces javadoc and source jar and bin jars)
| +- javadocConfiguration
| +- runtimeDependencies
| +- manifest
| +- fatJar (customize produced fat/uber jar if any)
| +- methods : createJavadocJar(), createSourceJar(), createBinJar(), createFatJar(), resolveRuntimeDependencies()
+- e2eTest
| +- methods : add(), run()
+- qualityCheck
| +- methods : add(), run()
+ methods : toDependency(transitivity), getIdeSupport(), pack(), getDependenciesAsXml(), includeLocalAndTextDependencies()
Modifier and Type | Class and Description |
---|---|
class |
JkProject.JkProjectE2eTest |
static class |
JkProject.JkRunnableContainer |
static class |
JkProject.RuntimeDeps
Flag to indicate if we need to include, or not, runtime dependencies in some scenario.
|
Modifier and Type | Field and Description |
---|---|
JkArtifactLocator |
artifactLocator
Provides conventional path where artifact files are supposed to be generated.
|
JkRunnables |
cleanExtraActions
Defines extra actions to execute when
clean() is invoked. |
JkProjectCompilation |
compilation
Object responsible for generating and compiling production sources.
|
JkJavaCompilerToolChain |
compilerToolChain
Defines the tool for compiling both production and test Java sources for this project.
|
static java.lang.String |
CREATE_JAR_ACTION
Deprecated.
Use
JkProjectPackaging.CREATE_JAR_ACTION instead |
static java.lang.String |
DEPENDENCIES_TXT_FILE |
JkDependencyResolver |
dependencyResolver
Object responsible for resolving dependencies.
|
JkProject.JkProjectE2eTest |
e2eTest
Object responsible for running end-to-end tests.
|
JkProjectFlatFacade |
flatFacade
Convenient facade for configuring the project.
|
java.util.function.Function<JkIdeSupport,JkIdeSupport> |
ideSupportModifier
Function to modify the
JkIdeSupport used for configuring IDEs. |
JkProjectPackaging |
pack
Object responsible for creating binary, fat, javadoc and sources jars.
|
JkRunnables |
packActions
Deprecated.
Use
JkProjectPackaging.actions instead; |
JkProjectPackaging |
packaging
Deprecated.
Use #pack instead
|
static java.lang.String |
PROJECT_LIBS_DIR |
JkProject.JkRunnableContainer |
qualityCheck
Object responsible for running quality checkers.
|
JkProjectTesting |
test
Object responsible for compiling and running tests.
|
JkProjectTesting |
testing
Deprecated.
Use #test instead
|
Modifier and Type | Method and Description |
---|---|
JkProject |
apply(java.util.function.Consumer<JkProject> projectConsumer)
Applies the specified configuration consumer to this project.
|
JkBuildable |
asBuildable() |
JkProject |
clean()
Cleans directories where are generated files output by the project builds
(jars, generated sources, classes, reports, ...)
|
void |
displayDependencyTree()
Displays the resolved dependency tree on the console.
|
java.nio.file.Path |
getBaseDir()
Returns the base directory from where are resolved all relative path concerning this
project (source folder, ...)
|
org.w3c.dom.Document |
getDependenciesAsXml()
Returns an XML document containing the dependency trees of this project.
|
JkCoordinate.ConflictStrategy |
getDuplicateConflictStrategy()
Returns the strategy to use when twi dependencies with distinct versions
are declared in the project dependencies.
|
java.lang.String |
getInfo()
Returns a human-readable text that mentions various settings for this project
(source locations, file count, declared dependencies, ...).
|
JkIdeSupport |
getJavaIdeSupport()
Returns an ideSupport for this project.
|
JkJavaVersion |
getJvmTargetVersion()
Returns the Java JVM version that will be used to compile sources and
generate bytecode.
|
JkModuleId |
getModuleId()
Returns the moduleId of this project.
|
java.nio.file.Path |
getOutputDir()
Returns path of the directory under which are produced build files
|
java.lang.String |
getSourceEncoding()
Returns the source encoding of source files.
|
JkVersion |
getVersion()
Returns the version of the projects.
|
boolean |
isIncludeTextAndLocalDependencies()
Returns if the project dependencies include those mentioned in jeka/project-dependencies.txt flat file.
|
static JkProject |
of()
Creates a new project having the current working directory as base dir.
|
void |
pack()
Deprecated.
Use
JkProjectPackaging.run() instead |
JkJavaProcess |
prepareRunJar(JkProject.RuntimeDeps runtimeDepInclusion)
Creates
JkJavaProcess to execute the jar having the specified artifact name. |
JkJavaProcess |
prepareRunMain()
Creates
JkProcess to execute the main method for this project. |
JkProject |
setBaseDir(java.nio.file.Path baseDir)
Sets the base directory for this project.
|
JkProject |
setDuplicateConflictStrategy(JkCoordinate.ConflictStrategy duplicateConflictStrategy)
Sets the strategy to use when twi dependencies with distinct versions
are declared in the project dependencies.
|
JkProject |
setIncludeTextAndLocalDependencies(boolean includeTextAndLocalDependencies)
Specifies if the project dependencies should include those mentioned in jeka/project-dependencies.txt flat file.
|
JkProject |
setJarMaker(java.util.function.Consumer<java.nio.file.Path> jarMaker)
Deprecated.
Use
JkProjectPackaging.setJarMaker(Consumer) instead |
JkProject |
setJvmTargetVersion(JkJavaVersion jvmTargetVersion)
Sets the Java JVM version that will be used to compile sources and
generate bytecode.
|
JkProject |
setModuleId(JkModuleId moduleId)
Sets the moduleId for this project.
|
JkProject |
setModuleId(java.lang.String moduleId) |
JkProject |
setOutputDir(java.lang.String relativePath)
Sets the output path dir relative to base dir.
|
JkProject |
setSourceEncoding(java.lang.String sourceEncoding)
Sets the source encoding of source files.
|
JkProject |
setVersion(java.lang.String version)
Sets the explicit version of this project.
|
JkProject |
setVersionSupplier(java.util.function.Supplier<JkVersion> versionSupplier)
Sets the supplier for computing the project version.
|
JkLocalProjectDependency |
toDependency()
Creates a dependency o the regular bin jar created by this project.
|
JkLocalProjectDependency |
toDependency(JkTransitivity transitivity)
Creates a dependency o the regular bin jar of this project, with the specified transitivity.
|
JkLocalProjectDependency |
toDependency(java.lang.Runnable artifactMaker,
java.nio.file.Path artifactPath,
JkTransitivity transitivity)
Creates a dependency on an artifact created by this project.
|
java.lang.String |
toString() |
@Deprecated public static final java.lang.String CREATE_JAR_ACTION
JkProjectPackaging.CREATE_JAR_ACTION
insteadpublic static final java.lang.String DEPENDENCIES_TXT_FILE
public static final java.lang.String PROJECT_LIBS_DIR
public final JkArtifactLocator artifactLocator
@Deprecated public final JkRunnables packActions
JkProjectPackaging.actions
instead;public final JkDependencyResolver dependencyResolver
public final JkJavaCompilerToolChain compilerToolChain
public final JkProjectCompilation compilation
@Deprecated public final JkProjectPackaging packaging
public final JkProjectPackaging pack
@Deprecated public final JkProjectTesting testing
public final JkProjectTesting test
public final JkProject.JkProjectE2eTest e2eTest
public final JkProject.JkRunnableContainer qualityCheck
public java.util.function.Function<JkIdeSupport,JkIdeSupport> ideSupportModifier
JkIdeSupport
used for configuring IDEs.public final JkRunnables cleanExtraActions
clean()
is invoked.public final JkProjectFlatFacade flatFacade
public static JkProject of()
public JkProject apply(java.util.function.Consumer<JkProject> projectConsumer)
public java.nio.file.Path getBaseDir()
public JkProject setBaseDir(java.nio.file.Path baseDir)
getBaseDir()
public java.nio.file.Path getOutputDir()
public JkProject setOutputDir(java.lang.String relativePath)
public JkJavaVersion getJvmTargetVersion()
public JkProject setJvmTargetVersion(JkJavaVersion jvmTargetVersion)
public java.lang.String getSourceEncoding()
public JkProject setSourceEncoding(java.lang.String sourceEncoding)
public JkCoordinate.ConflictStrategy getDuplicateConflictStrategy()
public JkProject setDuplicateConflictStrategy(JkCoordinate.ConflictStrategy duplicateConflictStrategy)
@Deprecated public JkProject setJarMaker(java.util.function.Consumer<java.nio.file.Path> jarMaker)
JkProjectPackaging.setJarMaker(Consumer)
insteadpublic JkJavaProcess prepareRunMain()
JkProcess
to execute the main method for this project.public JkJavaProcess prepareRunJar(JkProject.RuntimeDeps runtimeDepInclusion)
JkJavaProcess
to execute the jar having the specified artifact name.
The jar is created on the fly if it is not already present.runtimeDepInclusion
- If INCLUDE
, the runtime dependencies will be added to the classpath. This should
values EXCLUDE
in case of fat jar.public java.lang.String toString()
toString
in class java.lang.Object
public JkProject clean()
public java.lang.String getInfo()
public void displayDependencyTree()
public JkIdeSupport getJavaIdeSupport()
getJavaIdeSupport
in interface JkIdeSupportSupplier
public JkLocalProjectDependency toDependency()
toDependency(JkTransitivity)
public JkLocalProjectDependency toDependency(JkTransitivity transitivity)
toDependency(Runnable, Path, JkTransitivity)
to have more control on the provided dependency artifact.public JkLocalProjectDependency toDependency(java.lang.Runnable artifactMaker, java.nio.file.Path artifactPath, JkTransitivity transitivity)
@Deprecated public void pack()
JkProjectPackaging.run()
insteadpublic boolean isIncludeTextAndLocalDependencies()
public JkProject setIncludeTextAndLocalDependencies(boolean includeTextAndLocalDependencies)
true
by default.public org.w3c.dom.Document getDependenciesAsXml()
public JkModuleId getModuleId()
public JkProject setModuleId(JkModuleId moduleId)
public JkProject setModuleId(java.lang.String moduleId)
public JkVersion getVersion()
setVersion(String)
if one has been set. Otherwise, it uses
the version returned by the version supplier.
The version is used to :
public JkProject setVersionSupplier(java.util.function.Supplier<JkVersion> versionSupplier)
public JkProject setVersion(java.lang.String version)
public JkBuildable asBuildable()
asBuildable
in interface JkBuildable.Supplier