java
Submodule
Constructs
JavaProject
Java project.
Initializers
import { java } from 'projen'
new java.JavaProject(options: JavaProjectOptions)
Name | Type | Description |
---|---|---|
|
| No description. |
options
Required
- Type: JavaProjectOptions
Methods
Name | Description |
---|---|
| Returns a string representation of this construct. |
| Exclude the matching files from pre-synth cleanup. |
| Adds a .gitignore pattern. |
| Exclude these files from the bundled package. |
| Adds a new task to this project. |
| Prints a "tip" message during synthesis. |
| Marks the provided file(s) as being generated. |
| Called after all components are synthesized. |
| Called before all components are synthesized. |
| Removes a task from a project. |
| Returns the shell command to execute in order to run a task. |
| Synthesize all project files into outdir . |
| Finds a file at the specified relative path within this project and all its subprojects. |
| Finds a json file by name. |
| Finds an object file (like JsonFile, YamlFile, etc.) by name. |
| Finds a file at the specified relative path within this project and removes it. |
| Adds a runtime dependency. |
| Adds a build plugin to the pom. |
| Adds a test dependency. |
toString
public toString(): string
Returns a string representation of this construct.
addExcludeFromCleanup
public addExcludeFromCleanup(globs: ...string[]): void
Exclude the matching files from pre-synth cleanup.
Can be used when, for example, some source files include the projen marker and we don't want them to be erased during synth.
globs
Required
- Type: ...string[]
The glob patterns to match.
addGitIgnore
public addGitIgnore(pattern: string): void
Adds a .gitignore pattern.
pattern
Required
- Type: string
The glob pattern to ignore.
addPackageIgnore
public addPackageIgnore(_pattern: string): void
Exclude these files from the bundled package.
Implemented by project types based on the
packaging mechanism. For example, NodeProject
delegates this to .npmignore
.
_pattern
Required
- Type: string
The glob pattern to exclude.
addTask
public addTask(name: string, props?: TaskOptions): Task
Adds a new task to this project.
This will fail if the project already has a task with this name.
name
Required
- Type: string
The task name to add.
props
Optional
- Type: projen.TaskOptions
Task properties.
addTip
addTip
public addTip(message: string): void
Prints a "tip" message during synthesis.
message
Required
- Type: string
The message.
annotateGenerated
public annotateGenerated(glob: string): void
Marks the provided file(s) as being generated.
This is achieved using the github-linguist attributes. Generated files do not count against the repository statistics and language breakdown.
https://github.com/github/linguist/blob/master/docs/overrides.md
glob
Required
- Type: string
the glob pattern to match (could be a file path).
postSynthesize
public postSynthesize(): void
Called after all components are synthesized.
Order is not guaranteed.
preSynthesize
public preSynthesize(): void
Called before all components are synthesized.
removeTask
public removeTask(name: string): Task
Removes a task from a project.
name
Required
- Type: string
The name of the task to remove.
runTaskCommand
public runTaskCommand(task: Task): string
Returns the shell command to execute in order to run a task.
By default, this is npx projen@<version> <task>
task
Required
- Type: projen.Task
The task for which the command is required.
synth
public synth(): void
Synthesize all project files into outdir
.
- Call "this.preSynthesize()"
- Delete all generated files
- Synthesize all subprojects
- Synthesize all components of this project
- Call "postSynthesize()" for all components of this project
- Call "this.postSynthesize()"
tryFindFile
public tryFindFile(filePath: string): FileBase
Finds a file at the specified relative path within this project and all its subprojects.
filePath
Required
- Type: string
The file path.
If this path is relative, it will be resolved from the root of this project.
tryFindJsonFile
tryFindJsonFile
public tryFindJsonFile(filePath: string): JsonFile
Finds a json file by name.
filePath
Required
- Type: string
The file path.
tryFindObjectFile
public tryFindObjectFile(filePath: string): ObjectFile
Finds an object file (like JsonFile, YamlFile, etc.) by name.
filePath
Required
- Type: string
The file path.
tryRemoveFile
public tryRemoveFile(filePath: string): FileBase
Finds a file at the specified relative path within this project and removes it.
filePath
Required
- Type: string
The file path.
If this path is relative, it will be resolved from the root of this project.
addDependency
public addDependency(spec: string): void
Adds a runtime dependency.
spec
Required
- Type: string
Format <groupId>/<artifactId>@<semver>
.
addPlugin
public addPlugin(spec: string, options?: PluginOptions): Dependency
Adds a build plugin to the pom.
The plug in is also added as a BUILD dep to the project.
spec
Required
- Type: string
dependency spec (group/artifact@version
).
options
Optional
- Type: PluginOptions
plugin options.
addTestDependency
public addTestDependency(spec: string): void
Adds a test dependency.
spec
Required
- Type: string
Format <groupId>/<artifactId>@<semver>
.
Static Functions
Name | Description |
---|---|
| Checks if x is a construct. |
| Test whether the given construct is a project. |
| Find the closest ancestor project for given construct. |
isConstruct
import { java } from 'projen'
java.JavaProject.isConstruct(x: any)
Checks if x
is a construct.
Use this method instead of instanceof
to properly detect Construct
instances, even when the construct library is symlinked.
Explanation: in JavaScript, multiple copies of the constructs
library on
disk are seen as independent, completely different libraries. As a
consequence, the class Construct
in each copy of the constructs
library
is seen as a different class, and an instance of one class will not test as
instanceof
the other class. npm install
will not create installations
like this, but users may manually symlink construct libraries together or
use a monorepo tool: in those cases, multiple copies of the constructs
library can be accidentally installed, and instanceof
will behave
unpredictably. It is safest to avoid using instanceof
, and using
this type-testing method instead.
x
Required
- Type: any
Any object.
isProject
import { java } from 'projen'
java.JavaProject.isProject(x: any)
Test whether the given construct is a project.
x
Required
- Type: any
of
import { java } from 'projen'
java.JavaProject.of(construct: IConstruct)
Find the closest ancestor project for given construct.
When given a project, this it the project itself.
construct
Required
- Type: constructs.IConstruct
Properties
Name | Type | Description |
---|---|---|
| constructs.Node | The tree node. |
| projen.Task | No description. |
| boolean | Whether to commit the managed files by default. |
| projen.Task | No description. |
| projen.Component[] | Returns all the components within this project. |
| projen.Dependencies | Project dependencies. |
| boolean | Whether or not the project is being ejected. |
| projen.FileBase[] | All files in this project. |
| projen.GitAttributesFile | The .gitattributes file for this repository. |
| projen.IgnoreFile | .gitignore. |
| projen.Logger | Logging utilities. |
| string | Project name. |
| string | Absolute output directory of this project. |
| projen.Task | No description. |
| projen.Task | No description. |
| projen.Task | No description. |
| projen.ProjectBuild | Manages the build process of the project. |
| string | The command to use in order to run the projen CLI. |
| projen.Project | The root project. |
| projen.Project[] | Returns all the subprojects within this project. |
| projen.Tasks | Project tasks. |
| projen.Task | No description. |
| projen.Task | This is the "default" task, the one that executes "projen". |
| projen.InitProject | The options used when this project is bootstrapped via projen new . |
| projen.Project | A parent project. |
| projen.ProjectType | No description. |
| projen.github.AutoApprove | Auto approve set up for this project. |
| projen.vscode.DevContainer | Access for .devcontainer.json (used for GitHub Codespaces). |
| projen.github.GitHub | Access all github components. |
| projen.Gitpod | Access for Gitpod. |
| projen.vscode.VsCode | Access all VSCode components. |
|
| Compile component. |
| string | Maven artifact output directory. |
|
| Packaging component. |
|
| API for managing pom.xml . |
|
| JUnit component. |
|
| Projenrc component. |
node
Required
public readonly node: Node;
- Type: constructs.Node
The tree node.
buildTask
Required
public readonly buildTask: Task;
- Type: projen.Task
commitGenerated
Required
public readonly commitGenerated: boolean;
- Type: boolean
Whether to commit the managed files by default.
compileTask
Required
public readonly compileTask: Task;
- Type: projen.Task
components
Required
public readonly components: Component[];
- Type: projen.Component[]
Returns all the components within this project.
deps
Required
public readonly deps: Dependencies;
- Type: projen.Dependencies
Project dependencies.
ejected
Required
public readonly ejected: boolean;
- Type: boolean
Whether or not the project is being ejected.
files
Required
public readonly files: FileBase[];
- Type: projen.FileBase[]
All files in this project.
gitattributes
Required
public readonly gitattributes: GitAttributesFile;
- Type: projen.GitAttributesFile
The .gitattributes file for this repository.
gitignore
Required
public readonly gitignore: IgnoreFile;
- Type: projen.IgnoreFile
.gitignore.
logger
Required
public readonly logger: Logger;
- Type: projen.Logger
Logging utilities.
name
Required
public readonly name: string;
- Type: string
Project name.
outdir
Required
public readonly outdir: string;
- Type: string
Absolute output directory of this project.
packageTask
Required
public readonly packageTask: Task;
- Type: projen.Task
postCompileTask
Required
public readonly postCompileTask: Task;
- Type: projen.Task
preCompileTask
Required
public readonly preCompileTask: Task;
- Type: projen.Task
projectBuild
Required
public readonly projectBuild: ProjectBuild;
- Type: projen.ProjectBuild
Manages the build process of the project.
projenCommand
Required
public readonly projenCommand: string;
- Type: string
The command to use in order to run the projen CLI.
root
Required
public readonly root: Project;
- Type: projen.Project
The root project.
subprojects
Required
public readonly subprojects: Project[];
- Type: projen.Project[]
Returns all the subprojects within this project.
tasks
Required
public readonly tasks: Tasks;
- Type: projen.Tasks
Project tasks.
testTask
Required
public readonly testTask: Task;
- Type: projen.Task
defaultTask
Optional
public readonly defaultTask: Task;
- Type: projen.Task
This is the "default" task, the one that executes "projen".
Undefined if the project is being ejected.
initProject
Optional
public readonly initProject: InitProject;
- Type: projen.InitProject
The options used when this project is bootstrapped via projen new
.
It includes the original set of options passed to the CLI and also the JSII FQN of the project type.
parent
Optional
public readonly parent: Project;
- Type: projen.Project
A parent project.
If undefined, this is the root project.
projectType
Required
public readonly projectType: ProjectType;
- Type: projen.ProjectType
autoApprove
Optional
public readonly autoApprove: AutoApprove;
- Type: projen.github.AutoApprove
Auto approve set up for this project.
devContainer
Optional
public readonly devContainer: DevContainer;
- Type: projen.vscode.DevContainer
Access for .devcontainer.json (used for GitHub Codespaces).
This will be undefined
if devContainer boolean is false
github
Optional
public readonly github: GitHub;
- Type: projen.github.GitHub
Access all github components.
This will be undefined
for subprojects.
gitpod
Optional
public readonly gitpod: Gitpod;
- Type: projen.Gitpod
Access for Gitpod.
This will be undefined
if gitpod boolean is false
vscode
Optional
public readonly vscode: VsCode;
- Type: projen.vscode.VsCode
Access all VSCode components.
This will be undefined
for subprojects.
compile
Required
public readonly compile: MavenCompile;
- Type: MavenCompile
Compile component.
distdir
Required
public readonly distdir: string;
- Type: string
Maven artifact output directory.
packaging
Required
public readonly packaging: MavenPackaging;
- Type: MavenPackaging
Packaging component.
pom
Required
public readonly pom: Pom;
- Type: Pom
API for managing pom.xml
.
junit
Optional
public readonly junit: Junit;
- Type: Junit
JUnit component.
projenrc
Optional
public readonly projenrc: Projenrc;
- Type: Projenrc
Projenrc component.
Constants
Name | Type | Description |
---|---|---|
| string | The name of the default task (the task executed when projen is run without arguments). |
DEFAULT_TASK
Required
public readonly DEFAULT_TASK: string;
- Type: string
The name of the default task (the task executed when projen
is run without arguments).
Normally this task should synthesize the project files.
Junit
Implements JUnit-based testing.
Initializers
import { java } from 'projen'
new java.Junit(project: Project, options: JunitOptions)
Name | Type | Description |
---|---|---|
| projen.Project | No description. |
|
| No description. |
project
Required
- Type: projen.Project
options
Required
- Type: JunitOptions
Methods
Name | Description |
---|---|
| Returns a string representation of this construct. |
| Called after synthesis. |
| Called before synthesis. |
| Synthesizes files to the project output directory. |
toString
public toString(): string
Returns a string representation of this construct.
postSynthesize
public postSynthesize(): void
Called after synthesis.
Order is not guaranteed.
preSynthesize
public preSynthesize(): void
Called before synthesis.
synthesize
public synthesize(): void
Synthesizes files to the project output directory.
Static Functions
Name | Description |
---|---|
| Checks if x is a construct. |
| Test whether the given construct is a component. |
isConstruct
import { java } from 'projen'
java.Junit.isConstruct(x: any)
Checks if x
is a construct.
Use this method instead of instanceof
to properly detect Construct
instances, even when the construct library is symlinked.
Explanation: in JavaScript, multiple copies of the constructs
library on
disk are seen as independent, completely different libraries. As a
consequence, the class Construct
in each copy of the constructs
library
is seen as a different class, and an instance of one class will not test as
instanceof
the other class. npm install
will not create installations
like this, but users may manually symlink construct libraries together or
use a monorepo tool: in those cases, multiple copies of the constructs
library can be accidentally installed, and instanceof
will behave
unpredictably. It is safest to avoid using instanceof
, and using
this type-testing method instead.
x
Required
- Type: any
Any object.
isComponent
import { java } from 'projen'
java.Junit.isComponent(x: any)
Test whether the given construct is a component.
x
Required
- Type: any
Properties
Name | Type | Description |
---|---|---|
| constructs.Node | The tree node. |
| projen.Project | No description. |
node
Required
public readonly node: Node;
- Type: constructs.Node
The tree node.
project
Required
public readonly project: Project;
- Type: projen.Project
MavenCompile
Adds the maven-compiler plugin to a POM file and the compile
task.
Initializers
import { java } from 'projen'
new java.MavenCompile(project: Project, pom: Pom, options?: MavenCompileOptions)
Name | Type | Description |
---|---|---|
| projen.Project | No description. |
|
| No description. |
|
| No description. |
project
Required
- Type: projen.Project
pom
Required
- Type: Pom
options
Optional
- Type: MavenCompileOptions
Methods
Name | Description |
---|---|
| Returns a string representation of this construct. |
| Called after synthesis. |
| Called before synthesis. |
| Synthesizes files to the project output directory. |
toString
public toString(): string
Returns a string representation of this construct.
postSynthesize
public postSynthesize(): void
Called after synthesis.
Order is not guaranteed.
preSynthesize
public preSynthesize(): void
Called before synthesis.
synthesize
public synthesize(): void
Synthesizes files to the project output directory.
Static Functions
Name | Description |
---|---|
| Checks if x is a construct. |
| Test whether the given construct is a component. |
isConstruct
import { java } from 'projen'
java.MavenCompile.isConstruct(x: any)
Checks if x
is a construct.
Use this method instead of instanceof
to properly detect Construct
instances, even when the construct library is symlinked.
Explanation: in JavaScript, multiple copies of the constructs
library on
disk are seen as independent, completely different libraries. As a
consequence, the class Construct
in each copy of the constructs
library
is seen as a different class, and an instance of one class will not test as
instanceof
the other class. npm install
will not create installations
like this, but users may manually symlink construct libraries together or
use a monorepo tool: in those cases, multiple copies of the constructs
library can be accidentally installed, and instanceof
will behave
unpredictably. It is safest to avoid using instanceof
, and using
this type-testing method instead.
x
Required
- Type: any
Any object.
isComponent
import { java } from 'projen'
java.MavenCompile.isComponent(x: any)
Test whether the given construct is a component.
x
Required
- Type: any
Properties
Name | Type | Description |
---|---|---|
| constructs.Node | The tree node. |
| projen.Project | No description. |
node
Required
public readonly node: Node;
- Type: constructs.Node
The tree node.
project
Required
public readonly project: Project;
- Type: projen.Project
MavenPackaging
Configures a maven project to produce a .jar archive with sources and javadocs.
Initializers
import { java } from 'projen'
new java.MavenPackaging(project: Project, pom: Pom, options?: MavenPackagingOptions)
Name | Type | Description |
---|---|---|
| projen.Project | No description. |
|
| No description. |
|
| No description. |
project
Required
- Type: projen.Project
pom
Required
- Type: Pom
options
Optional
- Type: MavenPackagingOptions
Methods
Name | Description |
---|---|
| Returns a string representation of this construct. |
| Called after synthesis. |
| Called before synthesis. |
| Synthesizes files to the project output directory. |
toString
public toString(): string
Returns a string representation of this construct.
postSynthesize
public postSynthesize(): void
Called after synthesis.
Order is not guaranteed.
preSynthesize
public preSynthesize(): void
Called before synthesis.
synthesize
public synthesize(): void
Synthesizes files to the project output directory.
Static Functions
Name | Description |
---|---|
| Checks if x is a construct. |
| Test whether the given construct is a component. |
isConstruct
import { java } from 'projen'
java.MavenPackaging.isConstruct(x: any)
Checks if x
is a construct.
Use this method instead of instanceof
to properly detect Construct
instances, even when the construct library is symlinked.
Explanation: in JavaScript, multiple copies of the constructs
library on
disk are seen as independent, completely different libraries. As a
consequence, the class Construct
in each copy of the constructs
library
is seen as a different class, and an instance of one class will not test as
instanceof
the other class. npm install
will not create installations
like this, but users may manually symlink construct libraries together or
use a monorepo tool: in those cases, multiple copies of the constructs
library can be accidentally installed, and instanceof
will behave
unpredictably. It is safest to avoid using instanceof
, and using
this type-testing method instead.
x
Required
- Type: any
Any object.
isComponent
import { java } from 'projen'
java.MavenPackaging.isComponent(x: any)
Test whether the given construct is a component.
x
Required
- Type: any
Properties
Name | Type | Description |
---|---|---|
| constructs.Node | The tree node. |
| projen.Project | No description. |
| string | The directory containing the package output, relative to the project outdir. |
node
Required
public readonly node: Node;
- Type: constructs.Node
The tree node.
project
Required
public readonly project: Project;
- Type: projen.Project
distdir
Required
public readonly distdir: string;
- Type: string
The directory containing the package output, relative to the project outdir.
MavenSample
Java code sample.
Initializers
import { java } from 'projen'
new java.MavenSample(project: Project, options: MavenSampleOptions)
Name | Type | Description |
---|---|---|
| projen.Project | No description. |
|
| No description. |
project
Required
- Type: projen.Project
options
Required
- Type: MavenSampleOptions
Methods
Name | Description |
---|---|
| Returns a string representation of this construct. |
| Called after synthesis. |
| Called before synthesis. |
| Synthesizes files to the project output directory. |
toString
public toString(): string
Returns a string representation of this construct.
postSynthesize
public postSynthesize(): void
Called after synthesis.
Order is not guaranteed.
preSynthesize
public preSynthesize(): void
Called before synthesis.
synthesize
public synthesize(): void
Synthesizes files to the project output directory.
Static Functions
Name | Description |
---|---|
| Checks if x is a construct. |
| Test whether the given construct is a component. |
isConstruct
import { java } from 'projen'
java.MavenSample.isConstruct(x: any)
Checks if x
is a construct.
Use this method instead of instanceof
to properly detect Construct
instances, even when the construct library is symlinked.
Explanation: in JavaScript, multiple copies of the constructs
library on
disk are seen as independent, completely different libraries. As a
consequence, the class Construct
in each copy of the constructs
library
is seen as a different class, and an instance of one class will not test as
instanceof
the other class. npm install
will not create installations
like this, but users may manually symlink construct libraries together or
use a monorepo tool: in those cases, multiple copies of the constructs
library can be accidentally installed, and instanceof
will behave
unpredictably. It is safest to avoid using instanceof
, and using
this type-testing method instead.
x
Required
- Type: any
Any object.
isComponent
import { java } from 'projen'
java.MavenSample.isComponent(x: any)
Test whether the given construct is a component.
x
Required
- Type: any
Properties
Name | Type | Description |
---|---|---|
| constructs.Node | The tree node. |
| projen.Project | No description. |
node
Required
public readonly node: Node;
- Type: constructs.Node
The tree node.
project
Required
public readonly project: Project;
- Type: projen.Project
Pom
A Project Object Model or POM is the fundamental unit of work in Maven.
It is an XML file that contains information about the project and configuration details used by Maven to build the project.
Initializers
import { java } from 'projen'
new java.Pom(project: Project, options: PomOptions)
Name | Type | Description |
---|---|---|
| projen.Project | No description. |
|
| No description. |
project
Required
- Type: projen.Project
options
Required
- Type: PomOptions
Methods
Name | Description |
---|---|
| Returns a string representation of this construct. |
| Called after synthesis. |
| Called before synthesis. |
| Synthesizes files to the project output directory. |
| Adds a runtime dependency. |
| Adds a build plugin to the pom. |
| No description. |
| Adds a key/value property to the pom. |
| Adds a repository to the pom. |
| Adds a test dependency. |
toString
public toString(): string
Returns a string representation of this construct.
postSynthesize
public postSynthesize(): void
Called after synthesis.
Order is not guaranteed.
preSynthesize
public preSynthesize(): void
Called before synthesis.
synthesize
public synthesize(): void
Synthesizes files to the project output directory.
addDependency
public addDependency(spec: string): void
Adds a runtime dependency.
spec
Required
- Type: string
Format <groupId>/<artifactId>@<semver>
.
addPlugin
public addPlugin(spec: string, options?: PluginOptions): Dependency
Adds a build plugin to the pom.
The plug in is also added as a BUILD dep to the project.
spec
Required
- Type: string
dependency spec (group/artifact@version
).
options
Optional
- Type: PluginOptions
plugin options.
addPluginRepository
public addPluginRepository(repository: MavenRepository): void
repository
Required
- Type: MavenRepository
addProperty
public addProperty(key: string, value: string): void
Adds a key/value property to the pom.
key
Required
- Type: string
the key.
value
Required
- Type: string
the value.
addRepository
public addRepository(repository: MavenRepository): void
Adds a repository to the pom.
repository
Required
- Type: MavenRepository
the repository to add.
addTestDependency
public addTestDependency(spec: string): void
Adds a test dependency.
spec
Required
- Type: string
Format <groupId>/<artifactId>@<semver>
.
Static Functions
Name | Description |
---|---|
| Checks if x is a construct. |
| Test whether the given construct is a component. |
isConstruct
import { java } from 'projen'
java.Pom.isConstruct(x: any)
Checks if x
is a construct.
Use this method instead of instanceof
to properly detect Construct
instances, even when the construct library is symlinked.
Explanation: in JavaScript, multiple copies of the constructs
library on
disk are seen as independent, completely different libraries. As a
consequence, the class Construct
in each copy of the constructs
library
is seen as a different class, and an instance of one class will not test as
instanceof
the other class. npm install
will not create installations
like this, but users may manually symlink construct libraries together or
use a monorepo tool: in those cases, multiple copies of the constructs
library can be accidentally installed, and instanceof
will behave
unpredictably. It is safest to avoid using instanceof
, and using
this type-testing method instead.
x
Required
- Type: any
Any object.
isComponent
import { java } from 'projen'
java.Pom.isComponent(x: any)
Test whether the given construct is a component.
x
Required
- Type: any
Properties
Name | Type | Description |
---|---|---|
| constructs.Node | The tree node. |
| projen.Project | No description. |
| string | Maven artifact ID. |
| string | The name of the pom file. |
| string | Maven group ID. |
| string | Maven packaging format. |
| string | Project version. |
| string | Project description. |
| string | Project display name. |
| string | Project URL. |
node
Required
public readonly node: Node;
- Type: constructs.Node
The tree node.
project
Required
public readonly project: Project;
- Type: projen.Project
artifactId
Required
public readonly artifactId: string;
- Type: string
Maven artifact ID.
fileName
Required
public readonly fileName: string;
- Type: string
The name of the pom file.
groupId
Required
public readonly groupId: string;
- Type: string
Maven group ID.
packaging
Required
public readonly packaging: string;
- Type: string
Maven packaging format.
version
Required
public readonly version: string;
- Type: string
Project version.
description
Optional
public readonly description: string;
- Type: string
Project description.
name
Optional
public readonly name: string;
- Type: string
Project display name.
url
Optional
public readonly url: string;
- Type: string
Project URL.
Projenrc
Allows writing projenrc files in java.
This will install org.projen/projen
as a Maven dependency and will add a
synth
task which will compile & execute main()
from
src/main/java/projenrc.java
.
Initializers
import { java } from 'projen'
new java.Projenrc(project: Project, pom: Pom, options?: ProjenrcOptions)
Name | Type | Description |
---|---|---|
| projen.Project | No description. |
|
| No description. |
|
| No description. |
project
Required
- Type: projen.Project
pom
Required
- Type: Pom
options
Optional
- Type: ProjenrcOptions
Methods
Name | Description |
---|---|
| Returns a string representation of this construct. |
| Called after synthesis. |
| Called before synthesis. |
| Synthesizes files to the project output directory. |
toString
public toString(): string
Returns a string representation of this construct.
postSynthesize
public postSynthesize(): void
Called after synthesis.
Order is not guaranteed.
preSynthesize
public preSynthesize(): void
Called before synthesis.
synthesize
public synthesize(): void
Synthesizes files to the project output directory.
Static Functions
Name | Description |
---|---|
| Checks if x is a construct. |
| Test whether the given construct is a component. |
| Returns the Projenrc instance associated with a project or undefined if there is no Projenrc. |
isConstruct
import { java } from 'projen'
java.Projenrc.isConstruct(x: any)
Checks if x
is a construct.
Use this method instead of instanceof
to properly detect Construct
instances, even when the construct library is symlinked.
Explanation: in JavaScript, multiple copies of the constructs
library on
disk are seen as independent, completely different libraries. As a
consequence, the class Construct
in each copy of the constructs
library
is seen as a different class, and an instance of one class will not test as
instanceof
the other class. npm install
will not create installations
like this, but users may manually symlink construct libraries together or
use a monorepo tool: in those cases, multiple copies of the constructs
library can be accidentally installed, and instanceof
will behave
unpredictably. It is safest to avoid using instanceof
, and using
this type-testing method instead.
x
Required
- Type: any
Any object.
isComponent
import { java } from 'projen'
java.Projenrc.isComponent(x: any)
Test whether the given construct is a component.
x
Required
- Type: any
of
import { java } from 'projen'
java.Projenrc.of(project: Project)
Returns the Projenrc
instance associated with a project or undefined
if there is no Projenrc.
project
Required
- Type: projen.Project
The project.
Properties
Name | Type | Description |
---|---|---|
| constructs.Node | The tree node. |
| projen.Project | No description. |
| string | The path of the projenrc file. |
| string | The name of the java class that includes the projen entrypoint. |
node
Required
public readonly node: Node;
- Type: constructs.Node
The tree node.
project
Required
public readonly project: Project;
- Type: projen.Project
filePath
Required
public readonly filePath: string;
- Type: string
The path of the projenrc file.
className
Required
public readonly className: string;
- Type: string
The name of the java class that includes the projen entrypoint.
Structs
JavaProjectCommonOptions
Options for JavaProject
.
Initializer
import { java } from 'projen'
const javaProjectCommonOptions: java.JavaProjectCommonOptions = { ... }
Properties
Name | Type | Description |
---|---|---|
| string | This is the name of your project. |
| boolean | Whether to commit the managed files by default. |
| projen.IgnoreFileOptions | Configuration options for .gitignore file. |
| projen.GitOptions | Configuration options for git. |
| projen.LoggerOptions | Configure logging options such as verbosity. |
| string | The root directory of the project. |
| projen.Project | The parent project, if this project is part of a bigger project. |
| string | The shell command to use in order to run the projen CLI. |
| boolean | Generate (once) .projenrc.json (in JSON). Set to false in order to disable .projenrc.json generation. |
| projen.ProjenrcJsonOptions | Options for .projenrc.json. |
| boolean | Use renovatebot to handle dependency upgrades. |
| projen.RenovatebotOptions | Options for renovatebot. |
| projen.github.AutoApproveOptions | Enable and configure the 'auto approve' workflow. |
| boolean | Enable automatic merging on GitHub. |
| projen.github.AutoMergeOptions | Configure options for automatic merging on GitHub. |
| boolean | Add a clobber task which resets the repo to origin. |
| boolean | Add a VSCode development environment (used for GitHub Codespaces). |
| boolean | Enable GitHub integration. |
| projen.github.GitHubOptions | Options for GitHub integration. |
| boolean | Add a Gitpod development environment. |
| boolean | Whether mergify should be enabled on this repository or not. |
| projen.github.MergifyOptions | Options for mergify. |
| projen.ProjectType | Which type of project this is (library/app). |
| projen.github.GithubCredentials | Choose a method of providing GitHub API access for projen workflows. |
| string | The name of a secret which includes a GitHub Personal Access Token to be used by projen workflows. |
| projen.SampleReadmeProps | The README setup. |
| boolean | Auto-close of stale issues and pull request. |
| projen.github.StaleOptions | Auto-close stale issues and pull requests. |
| boolean | Enable VSCode integration. |
| string | The artifactId is generally the name that the project is known by. |
| string | This is generally unique amongst an organization or a project. |
| string | This is the last piece of the naming puzzle. |
| string | Description of a project is always good. |
| string | Project packaging format. |
|
| A Parent Pom can be used to have a child project inherit properties/plugins/ect in order to reduce duplication and keep standards across a large amount of repos. |
| string | The URL, like the name, is not required. |
|
| Compile options. |
| string[] | List of runtime dependencies for this project. |
| string | Final artifact output directory. |
| boolean | Include junit tests. |
|
| junit options. |
|
| Packaging options. |
| boolean | Use projenrc in java. |
|
| Options related to projenrc in java. |
| string[] | List of test dependencies for this project. |
name
Required
public readonly name: string;
- Type: string
- Default: $BASEDIR
This is the name of your project.
commitGenerated
Optional
public readonly commitGenerated: boolean;
- Type: boolean
- Default: true
Whether to commit the managed files by default.
gitIgnoreOptions
Optional
public readonly gitIgnoreOptions: IgnoreFileOptions;
- Type: projen.IgnoreFileOptions
Configuration options for .gitignore file.
gitOptions
Optional
public readonly gitOptions: GitOptions;
- Type: projen.GitOptions
Configuration options for git.
logging
Optional
public readonly logging: LoggerOptions;
- Type: projen.LoggerOptions
- Default: {}
Configure logging options such as verbosity.
outdir
Optional
public readonly outdir: string;
- Type: string
- Default: "."
The root directory of the project.
Relative to this directory, all files are synthesized.
If this project has a parent, this directory is relative to the parent directory and it cannot be the same as the parent or any of it's other subprojects.
parent
Optional
public readonly parent: Project;
- Type: projen.Project
The parent project, if this project is part of a bigger project.
projenCommand
Optional
public readonly projenCommand: string;
- Type: string
- Default: "npx projen"
The shell command to use in order to run the projen CLI.
Can be used to customize in special environments.
projenrcJson
Optional
public readonly projenrcJson: boolean;
- Type: boolean
- Default: false
Generate (once) .projenrc.json (in JSON). Set to false
in order to disable .projenrc.json generation.
projenrcJsonOptions
Optional
public readonly projenrcJsonOptions: ProjenrcJsonOptions;
- Type: projen.ProjenrcJsonOptions
- Default: default options
Options for .projenrc.json.
renovatebot
Optional
public readonly renovatebot: boolean;
- Type: boolean
- Default: false
Use renovatebot to handle dependency upgrades.
renovatebotOptions
Optional
public readonly renovatebotOptions: RenovatebotOptions;
- Type: projen.RenovatebotOptions
- Default: default options
Options for renovatebot.
autoApproveOptions
Optional
public readonly autoApproveOptions: AutoApproveOptions;
- Type: projen.github.AutoApproveOptions
- Default: auto approve is disabled
Enable and configure the 'auto approve' workflow.
autoMerge
Optional
public readonly autoMerge: boolean;
- Type: boolean
- Default: true
Enable automatic merging on GitHub.
Has no effect if github.mergify
is set to false.
autoMergeOptions
Optional
public readonly autoMergeOptions: AutoMergeOptions;
- Type: projen.github.AutoMergeOptions
- Default: see defaults in
AutoMergeOptions
Configure options for automatic merging on GitHub.
Has no effect if
github.mergify
or autoMerge
is set to false.
clobber
Optional
public readonly clobber: boolean;
- Type: boolean
- Default: true, but false for subprojects
Add a clobber
task which resets the repo to origin.
devContainer
Optional
public readonly devContainer: boolean;
- Type: boolean
- Default: false
Add a VSCode development environment (used for GitHub Codespaces).
github
Optional
public readonly github: boolean;
- Type: boolean
- Default: true
Enable GitHub integration.
Enabled by default for root projects. Disabled for non-root projects.
githubOptions
Optional
public readonly githubOptions: GitHubOptions;
- Type: projen.github.GitHubOptions
- Default: see GitHubOptions
Options for GitHub integration.
gitpod
Optional
public readonly gitpod: boolean;
- Type: boolean
- Default: false
Add a Gitpod development environment.
mergify
Optional
mergify
- Deprecated: use
githubOptions.mergify
instead
public readonly mergify: boolean;
- Type: boolean
- Default: true
Whether mergify should be enabled on this repository or not.
mergifyOptions
Optional
mergifyOptions
- Deprecated: use
githubOptions.mergifyOptions
instead
public readonly mergifyOptions: MergifyOptions;
- Type: projen.github.MergifyOptions
- Default: default options
Options for mergify.
projectType
Optional
projectType
- Deprecated: no longer supported at the base project level
public readonly projectType: ProjectType;
- Type: projen.ProjectType
- Default: ProjectType.UNKNOWN
Which type of project this is (library/app).
projenCredentials
Optional
public readonly projenCredentials: GithubCredentials;
- Type: projen.github.GithubCredentials
- Default: use a personal access token named PROJEN_GITHUB_TOKEN
Choose a method of providing GitHub API access for projen workflows.
projenTokenSecret
Optional
projenTokenSecret
- Deprecated: use
projenCredentials
public readonly projenTokenSecret: string;
- Type: string
- Default: "PROJEN_GITHUB_TOKEN"
The name of a secret which includes a GitHub Personal Access Token to be used by projen workflows.
This token needs to have the repo
, workflows
and packages
scope.
readme
Optional
public readonly readme: SampleReadmeProps;
- Type: projen.SampleReadmeProps
- Default: { filename: 'README.md', contents: '# replace this' }
The README setup.
Example
"{ filename: 'readme.md', contents: '# title' }"
stale
Optional
public readonly stale: boolean;
- Type: boolean
- Default: false
Auto-close of stale issues and pull request.
See staleOptions
for options.
staleOptions
Optional
public readonly staleOptions: StaleOptions;
- Type: projen.github.StaleOptions
- Default: see defaults in
StaleOptions
Auto-close stale issues and pull requests.
To disable set stale
to false
.
vscode
Optional
public readonly vscode: boolean;
- Type: boolean
- Default: true
Enable VSCode integration.
Enabled by default for root projects. Disabled for non-root projects.
artifactId
Required
public readonly artifactId: string;
- Type: string
- Default: "my-app"
The artifactId is generally the name that the project is known by.
Although the groupId is important, people within the group will rarely mention the groupId in discussion (they are often all be the same ID, such as the MojoHaus project groupId: org.codehaus.mojo). It, along with the groupId, creates a key that separates this project from every other project in the world (at least, it should :) ). Along with the groupId, the artifactId fully defines the artifact's living quarters within the repository. In the case of the above project, my-project lives in $M2_REPO/org/codehaus/mojo/my-project.
groupId
Required
public readonly groupId: string;
- Type: string
- Default: "org.acme"
This is generally unique amongst an organization or a project.
For example, all core Maven artifacts do (well, should) live under the groupId org.apache.maven. Group ID's do not necessarily use the dot notation, for example, the junit project. Note that the dot-notated groupId does not have to correspond to the package structure that the project contains. It is, however, a good practice to follow. When stored within a repository, the group acts much like the Java packaging structure does in an operating system. The dots are replaced by OS specific directory separators (such as '/' in Unix) which becomes a relative directory structure from the base repository. In the example given, the org.codehaus.mojo group lives within the directory $M2_REPO/org/codehaus/mojo.
version
Required
public readonly version: string;
- Type: string
- Default: "0.1.0"
This is the last piece of the naming puzzle.
groupId:artifactId denotes a single project but they cannot delineate which incarnation of that project we are talking about. Do we want the junit:junit of 2018 (version 4.12), or of 2007 (version 3.8.2)? In short: code changes, those changes should be versioned, and this element keeps those versions in line. It is also used within an artifact's repository to separate versions from each other. my-project version 1.0 files live in the directory structure $M2_REPO/org/codehaus/mojo/my-project/1.0.
description
Optional
public readonly description: string;
- Type: string
- Default: undefined
Description of a project is always good.
Although this should not replace formal documentation, a quick comment to any readers of the POM is always helpful.
packaging
Optional
public readonly packaging: string;
- Type: string
- Default: "jar"
Project packaging format.
parentPom
Optional
public readonly parentPom: ParentPom;
- Type: ParentPom
- Default: undefined
A Parent Pom can be used to have a child project inherit properties/plugins/ect in order to reduce duplication and keep standards across a large amount of repos.
url
Optional
public readonly url: string;
- Type: string
- Default: undefined
The URL, like the name, is not required.
This is a nice gesture for projects users, however, so that they know where the project lives.
compileOptions
Optional
public readonly compileOptions: MavenCompileOptions;
- Type: MavenCompileOptions
- Default: defaults
Compile options.
deps
Optional
public readonly deps: string[];
- Type: string[]
- Default: []
List of runtime dependencies for this project.
Dependencies use the format: <groupId>/<artifactId>@<semver>
Additional dependencies can be added via project.addDependency()
.
distdir
Optional
public readonly distdir: string;
- Type: string
- Default: "dist/java"
Final artifact output directory.
junit
Optional
public readonly junit: boolean;
- Type: boolean
- Default: true
Include junit tests.
junitOptions
Optional
public readonly junitOptions: JunitOptions;
- Type: JunitOptions
- Default: defaults
junit options.
packagingOptions
Optional
public readonly packagingOptions: MavenPackagingOptions;
- Type: MavenPackagingOptions
- Default: defaults
Packaging options.
projenrcJava
Optional
public readonly projenrcJava: boolean;
- Type: boolean
- Default: true
Use projenrc in java.
This will install projen
as a java dependency and will add a synth
task which
will compile & execute main()
from src/main/java/projenrc.java
.
projenrcJavaOptions
Optional
public readonly projenrcJavaOptions: ProjenrcOptions;
- Type: ProjenrcOptions
- Default: default options
Options related to projenrc in java.
testDeps
Optional
public readonly testDeps: string[];
- Type: string[]
- Default: []
List of test dependencies for this project.
Dependencies use the format: <groupId>/<artifactId>@<semver>
Additional dependencies can be added via project.addTestDependency()
.
JavaProjectOptions
Options for JavaProject
.
Initializer
import { java } from 'projen'
const javaProjectOptions: java.JavaProjectOptions = { ... }
Properties
Name | Type | Description |
---|---|---|
| string | This is the name of your project. |
| boolean | Whether to commit the managed files by default. |
| projen.IgnoreFileOptions | Configuration options for .gitignore file. |
| projen.GitOptions | Configuration options for git. |
| projen.LoggerOptions | Configure logging options such as verbosity. |
| string | The root directory of the project. |
| projen.Project | The parent project, if this project is part of a bigger project. |
| string | The shell command to use in order to run the projen CLI. |
| boolean | Generate (once) .projenrc.json (in JSON). Set to false in order to disable .projenrc.json generation. |
| projen.ProjenrcJsonOptions | Options for .projenrc.json. |
| boolean | Use renovatebot to handle dependency upgrades. |
| projen.RenovatebotOptions | Options for renovatebot. |
| projen.github.AutoApproveOptions | Enable and configure the 'auto approve' workflow. |
| boolean | Enable automatic merging on GitHub. |
| projen.github.AutoMergeOptions | Configure options for automatic merging on GitHub. |
| boolean | Add a clobber task which resets the repo to origin. |
| boolean | Add a VSCode development environment (used for GitHub Codespaces). |
| boolean | Enable GitHub integration. |
| projen.github.GitHubOptions | Options for GitHub integration. |
| boolean | Add a Gitpod development environment. |
| boolean | Whether mergify should be enabled on this repository or not. |
| projen.github.MergifyOptions | Options for mergify. |
| projen.ProjectType | Which type of project this is (library/app). |
| projen.github.GithubCredentials | Choose a method of providing GitHub API access for projen workflows. |
| string | The name of a secret which includes a GitHub Personal Access Token to be used by projen workflows. |
| projen.SampleReadmeProps | The README setup. |
| boolean | Auto-close of stale issues and pull request. |
| projen.github.StaleOptions | Auto-close stale issues and pull requests. |
| boolean | Enable VSCode integration. |
| string | The artifactId is generally the name that the project is known by. |
| string | This is generally unique amongst an organization or a project. |
| string | This is the last piece of the naming puzzle. |
| string | Description of a project is always good. |
| string | Project packaging format. |
|
| A Parent Pom can be used to have a child project inherit properties/plugins/ect in order to reduce duplication and keep standards across a large amount of repos. |
| string | The URL, like the name, is not required. |
|
| Compile options. |
| string[] | List of runtime dependencies for this project. |
| string | Final artifact output directory. |
| boolean | Include junit tests. |
|
| junit options. |
|
| Packaging options. |
| boolean | Use projenrc in java. |
|
| Options related to projenrc in java. |
| string[] | List of test dependencies for this project. |
| boolean | Include sample code and test if the relevant directories don't exist. |
| string | The java package to use for the code sample. |
name
Required
public readonly name: string;
- Type: string
- Default: $BASEDIR
This is the name of your project.
commitGenerated
Optional
public readonly commitGenerated: boolean;
- Type: boolean
- Default: true
Whether to commit the managed files by default.
gitIgnoreOptions
Optional
public readonly gitIgnoreOptions: IgnoreFileOptions;
- Type: projen.IgnoreFileOptions
Configuration options for .gitignore file.
gitOptions
Optional
public readonly gitOptions: GitOptions;
- Type: projen.GitOptions
Configuration options for git.
logging
Optional
public readonly logging: LoggerOptions;
- Type: projen.LoggerOptions
- Default: {}
Configure logging options such as verbosity.
outdir
Optional
public readonly outdir: string;
- Type: string
- Default: "."
The root directory of the project.
Relative to this directory, all files are synthesized.
If this project has a parent, this directory is relative to the parent directory and it cannot be the same as the parent or any of it's other subprojects.
parent
Optional
public readonly parent: Project;
- Type: projen.Project
The parent project, if this project is part of a bigger project.
projenCommand
Optional
public readonly projenCommand: string;
- Type: string
- Default: "npx projen"
The shell command to use in order to run the projen CLI.
Can be used to customize in special environments.
projenrcJson
Optional
public readonly projenrcJson: boolean;
- Type: boolean
- Default: false
Generate (once) .projenrc.json (in JSON). Set to false
in order to disable .projenrc.json generation.
projenrcJsonOptions
Optional
public readonly projenrcJsonOptions: ProjenrcJsonOptions;
- Type: projen.ProjenrcJsonOptions
- Default: default options
Options for .projenrc.json.
renovatebot
Optional
public readonly renovatebot: boolean;
- Type: boolean
- Default: false
Use renovatebot to handle dependency upgrades.
renovatebotOptions
Optional
public readonly renovatebotOptions: RenovatebotOptions;
- Type: projen.RenovatebotOptions
- Default: default options
Options for renovatebot.
autoApproveOptions
Optional
public readonly autoApproveOptions: AutoApproveOptions;
- Type: projen.github.AutoApproveOptions
- Default: auto approve is disabled
Enable and configure the 'auto approve' workflow.
autoMerge
Optional
public readonly autoMerge: boolean;
- Type: boolean
- Default: true
Enable automatic merging on GitHub.
Has no effect if github.mergify
is set to false.
autoMergeOptions
Optional
public readonly autoMergeOptions: AutoMergeOptions;
- Type: projen.github.AutoMergeOptions
- Default: see defaults in
AutoMergeOptions
Configure options for automatic merging on GitHub.
Has no effect if
github.mergify
or autoMerge
is set to false.
clobber
Optional
public readonly clobber: boolean;
- Type: boolean
- Default: true, but false for subprojects
Add a clobber
task which resets the repo to origin.
devContainer
Optional
public readonly devContainer: boolean;
- Type: boolean
- Default: false
Add a VSCode development environment (used for GitHub Codespaces).
github
Optional
public readonly github: boolean;
- Type: boolean
- Default: true
Enable GitHub integration.
Enabled by default for root projects. Disabled for non-root projects.
githubOptions
Optional
public readonly githubOptions: GitHubOptions;
- Type: projen.github.GitHubOptions
- Default: see GitHubOptions
Options for GitHub integration.
gitpod
Optional
public readonly gitpod: boolean;
- Type: boolean
- Default: false
Add a Gitpod development environment.
mergify
Optional
mergify
- Deprecated: use
githubOptions.mergify
instead
public readonly mergify: boolean;
- Type: boolean
- Default: true
Whether mergify should be enabled on this repository or not.
mergifyOptions
Optional
mergifyOptions
- Deprecated: use
githubOptions.mergifyOptions
instead
public readonly mergifyOptions: MergifyOptions;
- Type: projen.github.MergifyOptions
- Default: default options
Options for mergify.
projectType
Optional
projectType
- Deprecated: no longer supported at the base project level
public readonly projectType: ProjectType;
- Type: projen.ProjectType
- Default: ProjectType.UNKNOWN
Which type of project this is (library/app).
projenCredentials
Optional
public readonly projenCredentials: GithubCredentials;
- Type: projen.github.GithubCredentials
- Default: use a personal access token named PROJEN_GITHUB_TOKEN
Choose a method of providing GitHub API access for projen workflows.
projenTokenSecret
Optional
projenTokenSecret
- Deprecated: use
projenCredentials
public readonly projenTokenSecret: string;
- Type: string
- Default: "PROJEN_GITHUB_TOKEN"
The name of a secret which includes a GitHub Personal Access Token to be used by projen workflows.
This token needs to have the repo
, workflows
and packages
scope.
readme
Optional
public readonly readme: SampleReadmeProps;
- Type: projen.SampleReadmeProps
- Default: { filename: 'README.md', contents: '# replace this' }
The README setup.
Example
"{ filename: 'readme.md', contents: '# title' }"
stale
Optional
public readonly stale: boolean;
- Type: boolean
- Default: false
Auto-close of stale issues and pull request.
See staleOptions
for options.
staleOptions
Optional
public readonly staleOptions: StaleOptions;
- Type: projen.github.StaleOptions
- Default: see defaults in
StaleOptions
Auto-close stale issues and pull requests.
To disable set stale
to false
.
vscode
Optional
public readonly vscode: boolean;
- Type: boolean
- Default: true
Enable VSCode integration.
Enabled by default for root projects. Disabled for non-root projects.
artifactId
Required
public readonly artifactId: string;
- Type: string
- Default: "my-app"
The artifactId is generally the name that the project is known by.
Although the groupId is important, people within the group will rarely mention the groupId in discussion (they are often all be the same ID, such as the MojoHaus project groupId: org.codehaus.mojo). It, along with the groupId, creates a key that separates this project from every other project in the world (at least, it should :) ). Along with the groupId, the artifactId fully defines the artifact's living quarters within the repository. In the case of the above project, my-project lives in $M2_REPO/org/codehaus/mojo/my-project.
groupId
Required
public readonly groupId: string;
- Type: string
- Default: "org.acme"
This is generally unique amongst an organization or a project.
For example, all core Maven artifacts do (well, should) live under the groupId org.apache.maven. Group ID's do not necessarily use the dot notation, for example, the junit project. Note that the dot-notated groupId does not have to correspond to the package structure that the project contains. It is, however, a good practice to follow. When stored within a repository, the group acts much like the Java packaging structure does in an operating system. The dots are replaced by OS specific directory separators (such as '/' in Unix) which becomes a relative directory structure from the base repository. In the example given, the org.codehaus.mojo group lives within the directory $M2_REPO/org/codehaus/mojo.
version
Required
public readonly version: string;
- Type: string
- Default: "0.1.0"
This is the last piece of the naming puzzle.
groupId:artifactId denotes a single project but they cannot delineate which incarnation of that project we are talking about. Do we want the junit:junit of 2018 (version 4.12), or of 2007 (version 3.8.2)? In short: code changes, those changes should be versioned, and this element keeps those versions in line. It is also used within an artifact's repository to separate versions from each other. my-project version 1.0 files live in the directory structure $M2_REPO/org/codehaus/mojo/my-project/1.0.
description
Optional
public readonly description: string;
- Type: string
- Default: undefined
Description of a project is always good.
Although this should not replace formal documentation, a quick comment to any readers of the POM is always helpful.
packaging
Optional
public readonly packaging: string;
- Type: string
- Default: "jar"
Project packaging format.
parentPom
Optional
public readonly parentPom: ParentPom;
- Type: ParentPom
- Default: undefined
A Parent Pom can be used to have a child project inherit properties/plugins/ect in order to reduce duplication and keep standards across a large amount of repos.
url
Optional
public readonly url: string;
- Type: string
- Default: undefined
The URL, like the name, is not required.
This is a nice gesture for projects users, however, so that they know where the project lives.
compileOptions
Optional
public readonly compileOptions: MavenCompileOptions;
- Type: MavenCompileOptions
- Default: defaults
Compile options.
deps
Optional
public readonly deps: string[];
- Type: string[]
- Default: []
List of runtime dependencies for this project.
Dependencies use the format: <groupId>/<artifactId>@<semver>
Additional dependencies can be added via project.addDependency()
.
distdir
Optional
public readonly distdir: string;
- Type: string
- Default: "dist/java"
Final artifact output directory.
junit
Optional
public readonly junit: boolean;
- Type: boolean
- Default: true
Include junit tests.
junitOptions
Optional
public readonly junitOptions: JunitOptions;
- Type: JunitOptions
- Default: defaults
junit options.
packagingOptions
Optional
public readonly packagingOptions: MavenPackagingOptions;
- Type: MavenPackagingOptions
- Default: defaults
Packaging options.
projenrcJava
Optional
public readonly projenrcJava: boolean;
- Type: boolean
- Default: true
Use projenrc in java.
This will install projen
as a java dependency and will add a synth
task which
will compile & execute main()
from src/main/java/projenrc.java
.
projenrcJavaOptions
Optional
public readonly projenrcJavaOptions: ProjenrcOptions;
- Type: ProjenrcOptions
- Default: default options
Options related to projenrc in java.
testDeps
Optional
public readonly testDeps: string[];
- Type: string[]
- Default: []
List of test dependencies for this project.
Dependencies use the format: <groupId>/<artifactId>@<semver>
Additional dependencies can be added via project.addTestDependency()
.
sample
Optional
public readonly sample: boolean;
- Type: boolean
- Default: true
Include sample code and test if the relevant directories don't exist.
sampleJavaPackage
Optional
public readonly sampleJavaPackage: string;
- Type: string
- Default: "org.acme"
The java package to use for the code sample.
JunitOptions
Options for Junit
.
Initializer
import { java } from 'projen'
const junitOptions: java.JunitOptions = { ... }
Properties
Name | Type | Description |
---|---|---|
|
| Java pom. |
| string | Java package for test sample. |
| string | Junit version. |
pom
Required
public readonly pom: Pom;
- Type: Pom
Java pom.
sampleJavaPackage
Optional
public readonly sampleJavaPackage: string;
- Type: string
- Default: "org.acme"
Java package for test sample.
version
Optional
public readonly version: string;
- Type: string
- Default: "5.7.0"
Junit version.
MavenCompileOptions
Options for MavenCompile
.
Initializer
import { java } from 'projen'
const mavenCompileOptions: java.MavenCompileOptions = { ... }
Properties
Name | Type | Description |
---|---|---|
| string | Source language version. |
| string | Target JVM version. |
source
Optional
public readonly source: string;
- Type: string
- Default: "1.8"
Source language version.
target
Optional
public readonly target: string;
- Type: string
- Default: "1.8"
Target JVM version.
MavenPackagingOptions
Options for MavenPackage
.
Initializer
import { java } from 'projen'
const mavenPackagingOptions: java.MavenPackagingOptions = { ... }
Properties
Name | Type | Description |
---|---|---|
| string | Where to place the package output? |
| boolean | Include javadocs jar in package. |
| string[] | Exclude source files from docs. |
| boolean | Include sources jar in package. |
distdir
Optional
public readonly distdir: string;
- Type: string
- Default: "dist/java"
Where to place the package output?
javadocs
Optional
public readonly javadocs: boolean;
- Type: boolean
- Default: true
Include javadocs jar in package.
javadocsExclude
Optional
public readonly javadocsExclude: string[];
- Type: string[]
- Default: []
Exclude source files from docs.
sources
Optional
public readonly sources: boolean;
- Type: boolean
- Default: true
Include sources jar in package.
MavenRepository
Represents a Maven repository.
https://maven.apache.org/guides/introduction/introduction-to-repositories.html
Initializer
import { java } from 'projen'
const mavenRepository: java.MavenRepository = { ... }
Properties
Name | Type | Description |
---|---|---|
| string | The identifier for the repository. |
| string | The url of the repository. |
| string | The layout of the repository. |
| string | The name of the repository. |
|
| Repository Policy for Releases. |
|
| Repository Policy for Snapshots. |
id
Required
public readonly id: string;
- Type: string
The identifier for the repository.
url
Required
public readonly url: string;
- Type: string
The url of the repository.
layout
Optional
public readonly layout: string;
- Type: string
The layout of the repository.
name
Optional
public readonly name: string;
- Type: string
The name of the repository.
releases
Optional
public readonly releases: MavenRepositoryPolicy;
- Type: MavenRepositoryPolicy
Repository Policy for Releases.
snapshots
Optional
public readonly snapshots: MavenRepositoryPolicy;
- Type: MavenRepositoryPolicy
Repository Policy for Snapshots.
MavenRepositoryPolicy
Represents a Maven Repository Policy.
Initializer
import { java } from 'projen'
const mavenRepositoryPolicy: java.MavenRepositoryPolicy = { ... }
Properties
Name | Type | Description |
---|---|---|
|
| Checksum Policy When Maven deploys files to the repository, it also deploys corresponding checksum files. |
| boolean | No description. |
|
| Update Policy This element specifies how often updates should attempt to occur. |
checksumPolicy
Optional
public readonly checksumPolicy: ChecksumPolicy;
- Type: ChecksumPolicy
Checksum Policy When Maven deploys files to the repository, it also deploys corresponding checksum files.
enabled
Optional
public readonly enabled: boolean;
- Type: boolean
updatePolicy
Optional
public readonly updatePolicy: UpdatePolicy;
- Type: UpdatePolicy
- Default: UpdatePolicy.DAILY
Update Policy This element specifies how often updates should attempt to occur.
Maven will compare the local POM's timestamp (stored in a repository's maven-metadata file) to the remote.
MavenSampleOptions
Initializer
import { java } from 'projen'
const mavenSampleOptions: java.MavenSampleOptions = { ... }
Properties
Name | Type | Description |
---|---|---|
| string | Project root java package. |
package
Required
public readonly package: string;
- Type: string
Project root java package.
ParentPom
Initializer
import { java } from 'projen'
const parentPom: java.ParentPom = { ... }
Properties
Name | Type | Description |
---|---|---|
| string | Parent Pom Artifact ID. |
| string | Parent Pom Group ID. |
| string | Parent Pom Relative path from the current pom. |
| string | Parent Pom Version. |
artifactId
Optional
public readonly artifactId: string;
- Type: string
Parent Pom Artifact ID.
groupId
Optional
public readonly groupId: string;
- Type: string
Parent Pom Group ID.
relativePath
Optional
public readonly relativePath: string;
- Type: string
Parent Pom Relative path from the current pom.
version
Optional
public readonly version: string;
- Type: string
Parent Pom Version.
PluginExecution
Plugin execution definition.
Initializer
import { java } from 'projen'
const pluginExecution: java.PluginExecution = { ... }
Properties
Name | Type | Description |
---|---|---|
| string[] | Which Maven goals this plugin should be associated with. |
| string | The ID. |
| {[ key: string ]: any} | Execution key/value configuration. |
| string | The phase in which the plugin should execute. |
goals
Required
public readonly goals: string[];
- Type: string[]
Which Maven goals this plugin should be associated with.
id
Required
public readonly id: string;
- Type: string
The ID.
configuration
Optional
public readonly configuration: {[ key: string ]: any};
- Type: {[ key: string ]: any}
- Default: {}
Execution key/value configuration.
phase
Optional
public readonly phase: string;
- Type: string
The phase in which the plugin should execute.
PluginOptions
Options for Maven plugins.
Initializer
import { java } from 'projen'
const pluginOptions: java.PluginOptions = { ... }
Properties
Name | Type | Description |
---|---|---|
| {[ key: string ]: any} | Plugin key/value configuration. |
| string[] | You could configure the dependencies for the plugin. |
|
| Plugin executions. |
configuration
Optional
public readonly configuration: {[ key: string ]: any};
- Type: {[ key: string ]: any}
- Default: {}
Plugin key/value configuration.
dependencies
Optional
public readonly dependencies: string[];
- Type: string[]
- Default: []
You could configure the dependencies for the plugin.
Dependencies are in <groupId>/<artifactId>@<semver>
format.
executions
Optional
public readonly executions: PluginExecution[];
- Type: PluginExecution[]
- Default: []
Plugin executions.
PomOptions
Options for Pom
.
Initializer
import { java } from 'projen'
const pomOptions: java.PomOptions = { ... }
Properties
Name | Type | Description |
---|---|---|
| string | The artifactId is generally the name that the project is known by. |
| string | This is generally unique amongst an organization or a project. |
| string | This is the last piece of the naming puzzle. |
| string | Description of a project is always good. |
| string | Project packaging format. |
|
| A Parent Pom can be used to have a child project inherit properties/plugins/ect in order to reduce duplication and keep standards across a large amount of repos. |
| string | The URL, like the name, is not required. |
artifactId
Required
public readonly artifactId: string;
- Type: string
- Default: "my-app"
The artifactId is generally the name that the project is known by.
Although the groupId is important, people within the group will rarely mention the groupId in discussion (they are often all be the same ID, such as the MojoHaus project groupId: org.codehaus.mojo). It, along with the groupId, creates a key that separates this project from every other project in the world (at least, it should :) ). Along with the groupId, the artifactId fully defines the artifact's living quarters within the repository. In the case of the above project, my-project lives in $M2_REPO/org/codehaus/mojo/my-project.
groupId
Required
public readonly groupId: string;
- Type: string
- Default: "org.acme"
This is generally unique amongst an organization or a project.
For example, all core Maven artifacts do (well, should) live under the groupId org.apache.maven. Group ID's do not necessarily use the dot notation, for example, the junit project. Note that the dot-notated groupId does not have to correspond to the package structure that the project contains. It is, however, a good practice to follow. When stored within a repository, the group acts much like the Java packaging structure does in an operating system. The dots are replaced by OS specific directory separators (such as '/' in Unix) which becomes a relative directory structure from the base repository. In the example given, the org.codehaus.mojo group lives within the directory $M2_REPO/org/codehaus/mojo.
version
Required
public readonly version: string;
- Type: string
- Default: "0.1.0"
This is the last piece of the naming puzzle.
groupId:artifactId denotes a single project but they cannot delineate which incarnation of that project we are talking about. Do we want the junit:junit of 2018 (version 4.12), or of 2007 (version 3.8.2)? In short: code changes, those changes should be versioned, and this element keeps those versions in line. It is also used within an artifact's repository to separate versions from each other. my-project version 1.0 files live in the directory structure $M2_REPO/org/codehaus/mojo/my-project/1.0.
description
Optional
public readonly description: string;
- Type: string
- Default: undefined
Description of a project is always good.
Although this should not replace formal documentation, a quick comment to any readers of the POM is always helpful.
packaging
Optional
public readonly packaging: string;
- Type: string
- Default: "jar"
Project packaging format.
parentPom
Optional
public readonly parentPom: ParentPom;
- Type: ParentPom
- Default: undefined
A Parent Pom can be used to have a child project inherit properties/plugins/ect in order to reduce duplication and keep standards across a large amount of repos.
url
Optional
public readonly url: string;
- Type: string
- Default: undefined
The URL, like the name, is not required.
This is a nice gesture for projects users, however, so that they know where the project lives.
ProjenrcOptions
Options for Projenrc
.
Initializer
import { java } from 'projen'
const projenrcOptions: java.ProjenrcOptions = { ... }
Properties
Name | Type | Description |
---|---|---|
| string | The name of the Java class which contains the main() method for projen. |
| string | The projen version to use. |
| boolean | Defines projenrc under the test scope instead of the main scope, which is reserved to the app. |
className
Optional
public readonly className: string;
- Type: string
- Default: "projenrc"
The name of the Java class which contains the main()
method for projen.
projenVersion
Optional
public readonly projenVersion: string;
- Type: string
- Default: current version
The projen version to use.
testScope
Optional
public readonly testScope: boolean;
- Type: boolean
- Default: true
Defines projenrc under the test scope instead of the main scope, which is reserved to the app.
This means that projenrc will be under
src/test/java/projenrc.java
and projen will be defined as a test
dependency. This enforces that application code does not take a dependency
on projen code.
If this is disabled, projenrc should be under
src/main/java/projenrc.java
.
Classes
UpdatePolicy
Initializers
import { java } from 'projen'
new java.UpdatePolicy()
Name | Type | Description |
---|
Static Functions
Name | Description |
---|---|
| Updates at an interval of X minutes. |
interval
import { java } from 'projen'
java.UpdatePolicy.interval(minutes: number)
Updates at an interval of X minutes.
minutes
Required
- Type: number
Constants
Name | Type | Description |
---|---|---|
| string | No description. |
| string | No description. |
| string | No description. |
ALWAYS
Required
public readonly ALWAYS: string;
- Type: string
DAILY
Required
public readonly DAILY: string;
- Type: string
NEVER
Required
public readonly NEVER: string;
- Type: string
Enums
ChecksumPolicy
Members
Name | Description |
---|---|
| No description. |
| No description. |
| No description. |