java Submodule
Constructs
JavaProject
Java project.
Initializers
import { java } from 'projen'
new java.JavaProject(options: JavaProjectOptions)
| Name | Type | Description |
|---|---|---|
| | No description. |
optionsRequired
- 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.
globsRequired
- Type: ...string[]
The glob patterns to match.
addGitIgnore
public addGitIgnore(pattern: string): void
Adds a .gitignore pattern.
patternRequired
- 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.
_patternRequired
- 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.
nameRequired
- Type: string
The task name to add.
propsOptional
- Type: projen.TaskOptions
Task properties.
addTip
addTippublic addTip(message: string): void
Prints a "tip" message during synthesis.
messageRequired
- 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
globRequired
- 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.
nameRequired
- 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>
taskRequired
- 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.
filePathRequired
- Type: string
The file path.
If this path is relative, it will be resolved from the root of this project.
tryFindJsonFile
tryFindJsonFilepublic tryFindJsonFile(filePath: string): JsonFile
Finds a json file by name.
filePathRequired
- Type: string
The file path.
tryFindObjectFile
public tryFindObjectFile(filePath: string): ObjectFile
Finds an object file (like JsonFile, YamlFile, etc.) by name.
filePathRequired
- 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.
filePathRequired
- 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.
specRequired
- 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.
specRequired
- Type: string
dependency spec (group/artifact@version).
optionsOptional
- Type: PluginOptions
plugin options.
addTestDependency
public addTestDependency(spec: string): void
Adds a test dependency.
specRequired
- 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.
xRequired
- Type: any
Any object.
isProject
import { java } from 'projen'
java.JavaProject.isProject(x: any)
Test whether the given construct is a project.
xRequired
- 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.
constructRequired
- 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. |
nodeRequired
public readonly node: Node;
- Type: constructs.Node
The tree node.
buildTaskRequired
public readonly buildTask: Task;
- Type: projen.Task
commitGeneratedRequired
public readonly commitGenerated: boolean;
- Type: boolean
Whether to commit the managed files by default.
compileTaskRequired
public readonly compileTask: Task;
- Type: projen.Task
componentsRequired
public readonly components: Component[];
- Type: projen.Component[]
Returns all the components within this project.
depsRequired
public readonly deps: Dependencies;
- Type: projen.Dependencies
Project dependencies.
ejectedRequired
public readonly ejected: boolean;
- Type: boolean
Whether or not the project is being ejected.
filesRequired
public readonly files: FileBase[];
- Type: projen.FileBase[]
All files in this project.
gitattributesRequired
public readonly gitattributes: GitAttributesFile;
- Type: projen.GitAttributesFile
The .gitattributes file for this repository.
gitignoreRequired
public readonly gitignore: IgnoreFile;
- Type: projen.IgnoreFile
.gitignore.
loggerRequired
public readonly logger: Logger;
- Type: projen.Logger
Logging utilities.
nameRequired
public readonly name: string;
- Type: string
Project name.
outdirRequired
public readonly outdir: string;
- Type: string
Absolute output directory of this project.
packageTaskRequired
public readonly packageTask: Task;
- Type: projen.Task
postCompileTaskRequired
public readonly postCompileTask: Task;
- Type: projen.Task
preCompileTaskRequired
public readonly preCompileTask: Task;
- Type: projen.Task
projectBuildRequired
public readonly projectBuild: ProjectBuild;
- Type: projen.ProjectBuild
Manages the build process of the project.
projenCommandRequired
public readonly projenCommand: string;
- Type: string
The command to use in order to run the projen CLI.
rootRequired
public readonly root: Project;
- Type: projen.Project
The root project.
subprojectsRequired
public readonly subprojects: Project[];
- Type: projen.Project[]
Returns all the subprojects within this project.
tasksRequired
public readonly tasks: Tasks;
- Type: projen.Tasks
Project tasks.
testTaskRequired
public readonly testTask: Task;
- Type: projen.Task
defaultTaskOptional
public readonly defaultTask: Task;
- Type: projen.Task
This is the "default" task, the one that executes "projen".
Undefined if the project is being ejected.
initProjectOptional
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.
parentOptional
public readonly parent: Project;
- Type: projen.Project
A parent project.
If undefined, this is the root project.
projectTypeRequired
public readonly projectType: ProjectType;
- Type: projen.ProjectType
autoApproveOptional
public readonly autoApprove: AutoApprove;
- Type: projen.github.AutoApprove
Auto approve set up for this project.
devContainerOptional
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
githubOptional
public readonly github: GitHub;
- Type: projen.github.GitHub
Access all github components.
This will be undefined for subprojects.
gitpodOptional
public readonly gitpod: Gitpod;
- Type: projen.Gitpod
Access for Gitpod.
This will be undefined if gitpod boolean is false
vscodeOptional
public readonly vscode: VsCode;
- Type: projen.vscode.VsCode
Access all VSCode components.
This will be undefined for subprojects.
compileRequired
public readonly compile: MavenCompile;
- Type: MavenCompile
Compile component.
distdirRequired
public readonly distdir: string;
- Type: string
Maven artifact output directory.
packagingRequired
public readonly packaging: MavenPackaging;
- Type: MavenPackaging
Packaging component.
pomRequired
public readonly pom: Pom;
- Type: Pom
API for managing pom.xml.
junitOptional
public readonly junit: Junit;
- Type: Junit
JUnit component.
projenrcOptional
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_TASKRequired
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. |
projectRequired
- Type: projen.Project
optionsRequired
- 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.
xRequired
- Type: any
Any object.
isComponent
import { java } from 'projen'
java.Junit.isComponent(x: any)
Test whether the given construct is a component.
xRequired
- Type: any
Properties
| Name | Type | Description |
|---|---|---|
| constructs.Node | The tree node. |
| projen.Project | No description. |
nodeRequired
public readonly node: Node;
- Type: constructs.Node
The tree node.
projectRequired
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. |
projectRequired
- Type: projen.Project
pomRequired
- Type: Pom
optionsOptional
- 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.
xRequired
- Type: any
Any object.
isComponent
import { java } from 'projen'
java.MavenCompile.isComponent(x: any)
Test whether the given construct is a component.
xRequired
- Type: any
Properties
| Name | Type | Description |
|---|---|---|
| constructs.Node | The tree node. |
| projen.Project | No description. |
nodeRequired
public readonly node: Node;
- Type: constructs.Node
The tree node.
projectRequired
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. |
projectRequired
- Type: projen.Project
pomRequired
- Type: Pom
optionsOptional
- 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.
xRequired
- Type: any
Any object.
isComponent
import { java } from 'projen'
java.MavenPackaging.isComponent(x: any)
Test whether the given construct is a component.
xRequired
- 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. |
nodeRequired
public readonly node: Node;
- Type: constructs.Node
The tree node.
projectRequired
public readonly project: Project;
- Type: projen.Project
distdirRequired
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. |
projectRequired
- Type: projen.Project
optionsRequired
- 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.
xRequired
- Type: any
Any object.
isComponent
import { java } from 'projen'
java.MavenSample.isComponent(x: any)
Test whether the given construct is a component.
xRequired
- Type: any
Properties
| Name | Type | Description |
|---|---|---|
| constructs.Node | The tree node. |
| projen.Project | No description. |
nodeRequired
public readonly node: Node;
- Type: constructs.Node
The tree node.
projectRequired
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. |
projectRequired
- Type: projen.Project
optionsRequired
- 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.
specRequired
- 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.
specRequired
- Type: string
dependency spec (group/artifact@version).
optionsOptional
- Type: PluginOptions
plugin options.
addPluginRepository
public addPluginRepository(repository: MavenRepository): void
repositoryRequired
- Type: MavenRepository
addProperty
public addProperty(key: string, value: string): void
Adds a key/value property to the pom.
keyRequired
- Type: string
the key.
valueRequired
- Type: string
the value.
addRepository
public addRepository(repository: MavenRepository): void
Adds a repository to the pom.
repositoryRequired
- Type: MavenRepository
the repository to add.
addTestDependency
public addTestDependency(spec: string): void
Adds a test dependency.
specRequired
- 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.
xRequired
- Type: any
Any object.
isComponent
import { java } from 'projen'
java.Pom.isComponent(x: any)
Test whether the given construct is a component.
xRequired
- 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. |
nodeRequired
public readonly node: Node;
- Type: constructs.Node
The tree node.
projectRequired
public readonly project: Project;
- Type: projen.Project
artifactIdRequired
public readonly artifactId: string;
- Type: string
Maven artifact ID.
fileNameRequired
public readonly fileName: string;
- Type: string
The name of the pom file.
groupIdRequired
public readonly groupId: string;
- Type: string
Maven group ID.
packagingRequired
public readonly packaging: string;
- Type: string
Maven packaging format.
versionRequired
public readonly version: string;
- Type: string
Project version.
descriptionOptional
public readonly description: string;
- Type: string
Project description.
nameOptional
public readonly name: string;
- Type: string
Project display name.
urlOptional
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. |
projectRequired
- Type: projen.Project
pomRequired
- Type: Pom
optionsOptional
- 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.
xRequired
- Type: any
Any object.
isComponent
import { java } from 'projen'
java.Projenrc.isComponent(x: any)
Test whether the given construct is a component.
xRequired
- 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.
projectRequired
- 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. |
nodeRequired
public readonly node: Node;
- Type: constructs.Node
The tree node.
projectRequired
public readonly project: Project;
- Type: projen.Project
filePathRequired
public readonly filePath: string;
- Type: string
The path of the projenrc file.
classNameRequired
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. |
nameRequired
public readonly name: string;
- Type: string
- Default: $BASEDIR
This is the name of your project.
commitGeneratedOptional
public readonly commitGenerated: boolean;
- Type: boolean
- Default: true
Whether to commit the managed files by default.
gitIgnoreOptionsOptional
public readonly gitIgnoreOptions: IgnoreFileOptions;
- Type: projen.IgnoreFileOptions
Configuration options for .gitignore file.
gitOptionsOptional
public readonly gitOptions: GitOptions;
- Type: projen.GitOptions
Configuration options for git.
loggingOptional
public readonly logging: LoggerOptions;
- Type: projen.LoggerOptions
- Default: {}
Configure logging options such as verbosity.
outdirOptional
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.
parentOptional
public readonly parent: Project;
- Type: projen.Project
The parent project, if this project is part of a bigger project.
projenCommandOptional
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.
projenrcJsonOptional
public readonly projenrcJson: boolean;
- Type: boolean
- Default: false
Generate (once) .projenrc.json (in JSON). Set to false in order to disable .projenrc.json generation.
projenrcJsonOptionsOptional
public readonly projenrcJsonOptions: ProjenrcJsonOptions;
- Type: projen.ProjenrcJsonOptions
- Default: default options
Options for .projenrc.json.
renovatebotOptional
public readonly renovatebot: boolean;
- Type: boolean
- Default: false
Use renovatebot to handle dependency upgrades.
renovatebotOptionsOptional
public readonly renovatebotOptions: RenovatebotOptions;
- Type: projen.RenovatebotOptions
- Default: default options
Options for renovatebot.
autoApproveOptionsOptional
public readonly autoApproveOptions: AutoApproveOptions;
- Type: projen.github.AutoApproveOptions
- Default: auto approve is disabled
Enable and configure the 'auto approve' workflow.
autoMergeOptional
public readonly autoMerge: boolean;
- Type: boolean
- Default: true
Enable automatic merging on GitHub.
Has no effect if github.mergify
is set to false.
autoMergeOptionsOptional
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.
clobberOptional
public readonly clobber: boolean;
- Type: boolean
- Default: true, but false for subprojects
Add a clobber task which resets the repo to origin.
devContainerOptional
public readonly devContainer: boolean;
- Type: boolean
- Default: false
Add a VSCode development environment (used for GitHub Codespaces).
githubOptional
public readonly github: boolean;
- Type: boolean
- Default: true
Enable GitHub integration.
Enabled by default for root projects. Disabled for non-root projects.
githubOptionsOptional
public readonly githubOptions: GitHubOptions;
- Type: projen.github.GitHubOptions
- Default: see GitHubOptions
Options for GitHub integration.
gitpodOptional
public readonly gitpod: boolean;
- Type: boolean
- Default: false
Add a Gitpod development environment.
mergifyOptional
mergify- Deprecated: use
githubOptions.mergifyinstead
public readonly mergify: boolean;
- Type: boolean
- Default: true
Whether mergify should be enabled on this repository or not.
mergifyOptionsOptional
mergifyOptions- Deprecated: use
githubOptions.mergifyOptionsinstead
public readonly mergifyOptions: MergifyOptions;
- Type: projen.github.MergifyOptions
- Default: default options
Options for mergify.
projectTypeOptional
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).
projenCredentialsOptional
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.
projenTokenSecretOptional
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.
readmeOptional
public readonly readme: SampleReadmeProps;
- Type: projen.SampleReadmeProps
- Default: { filename: 'README.md', contents: '# replace this' }
The README setup.
Example
"{ filename: 'readme.md', contents: '# title' }"
staleOptional
public readonly stale: boolean;
- Type: boolean
- Default: false
Auto-close of stale issues and pull request.
See staleOptions for options.
staleOptionsOptional
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.
vscodeOptional
public readonly vscode: boolean;
- Type: boolean
- Default: true
Enable VSCode integration.
Enabled by default for root projects. Disabled for non-root projects.
artifactIdRequired
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.
groupIdRequired
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.
versionRequired
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.
descriptionOptional
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.
packagingOptional
public readonly packaging: string;
- Type: string
- Default: "jar"
Project packaging format.
parentPomOptional
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.
urlOptional
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.
compileOptionsOptional
public readonly compileOptions: MavenCompileOptions;
- Type: MavenCompileOptions
- Default: defaults
Compile options.
depsOptional
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().
distdirOptional
public readonly distdir: string;
- Type: string
- Default: "dist/java"
Final artifact output directory.
junitOptional
public readonly junit: boolean;
- Type: boolean
- Default: true
Include junit tests.
junitOptionsOptional
public readonly junitOptions: JunitOptions;
- Type: JunitOptions
- Default: defaults
junit options.
packagingOptionsOptional
public readonly packagingOptions: MavenPackagingOptions;
- Type: MavenPackagingOptions
- Default: defaults
Packaging options.
projenrcJavaOptional
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.
projenrcJavaOptionsOptional
public readonly projenrcJavaOptions: ProjenrcOptions;
- Type: ProjenrcOptions
- Default: default options
Options related to projenrc in java.
testDepsOptional
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. |
nameRequired
public readonly name: string;
- Type: string
- Default: $BASEDIR
This is the name of your project.
commitGeneratedOptional
public readonly commitGenerated: boolean;
- Type: boolean
- Default: true
Whether to commit the managed files by default.
gitIgnoreOptionsOptional
public readonly gitIgnoreOptions: IgnoreFileOptions;
- Type: projen.IgnoreFileOptions
Configuration options for .gitignore file.
gitOptionsOptional
public readonly gitOptions: GitOptions;
- Type: projen.GitOptions
Configuration options for git.
loggingOptional
public readonly logging: LoggerOptions;
- Type: projen.LoggerOptions
- Default: {}
Configure logging options such as verbosity.
outdirOptional
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.
parentOptional
public readonly parent: Project;
- Type: projen.Project
The parent project, if this project is part of a bigger project.
projenCommandOptional
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.
projenrcJsonOptional
public readonly projenrcJson: boolean;
- Type: boolean
- Default: false
Generate (once) .projenrc.json (in JSON). Set to false in order to disable .projenrc.json generation.
projenrcJsonOptionsOptional
public readonly projenrcJsonOptions: ProjenrcJsonOptions;
- Type: projen.ProjenrcJsonOptions
- Default: default options
Options for .projenrc.json.
renovatebotOptional
public readonly renovatebot: boolean;
- Type: boolean
- Default: false
Use renovatebot to handle dependency upgrades.
renovatebotOptionsOptional
public readonly renovatebotOptions: RenovatebotOptions;
- Type: projen.RenovatebotOptions
- Default: default options
Options for renovatebot.
autoApproveOptionsOptional
public readonly autoApproveOptions: AutoApproveOptions;
- Type: projen.github.AutoApproveOptions
- Default: auto approve is disabled
Enable and configure the 'auto approve' workflow.
autoMergeOptional
public readonly autoMerge: boolean;
- Type: boolean
- Default: true
Enable automatic merging on GitHub.
Has no effect if github.mergify
is set to false.
autoMergeOptionsOptional
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.
clobberOptional
public readonly clobber: boolean;
- Type: boolean
- Default: true, but false for subprojects
Add a clobber task which resets the repo to origin.
devContainerOptional
public readonly devContainer: boolean;
- Type: boolean
- Default: false
Add a VSCode development environment (used for GitHub Codespaces).
githubOptional
public readonly github: boolean;
- Type: boolean
- Default: true
Enable GitHub integration.
Enabled by default for root projects. Disabled for non-root projects.
githubOptionsOptional
public readonly githubOptions: GitHubOptions;
- Type: projen.github.GitHubOptions
- Default: see GitHubOptions
Options for GitHub integration.
gitpodOptional
public readonly gitpod: boolean;
- Type: boolean
- Default: false
Add a Gitpod development environment.
mergifyOptional
mergify- Deprecated: use
githubOptions.mergifyinstead
public readonly mergify: boolean;
- Type: boolean
- Default: true
Whether mergify should be enabled on this repository or not.
mergifyOptionsOptional
mergifyOptions- Deprecated: use
githubOptions.mergifyOptionsinstead
public readonly mergifyOptions: MergifyOptions;
- Type: projen.github.MergifyOptions
- Default: default options
Options for mergify.
projectTypeOptional
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).
projenCredentialsOptional
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.
projenTokenSecretOptional
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.
readmeOptional
public readonly readme: SampleReadmeProps;
- Type: projen.SampleReadmeProps
- Default: { filename: 'README.md', contents: '# replace this' }
The README setup.
Example
"{ filename: 'readme.md', contents: '# title' }"
staleOptional
public readonly stale: boolean;
- Type: boolean
- Default: false
Auto-close of stale issues and pull request.
See staleOptions for options.
staleOptionsOptional
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.
vscodeOptional
public readonly vscode: boolean;
- Type: boolean
- Default: true
Enable VSCode integration.
Enabled by default for root projects. Disabled for non-root projects.
artifactIdRequired
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.
groupIdRequired
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.
versionRequired
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.
descriptionOptional
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.
packagingOptional
public readonly packaging: string;
- Type: string
- Default: "jar"
Project packaging format.
parentPomOptional
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.
urlOptional
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.
compileOptionsOptional
public readonly compileOptions: MavenCompileOptions;
- Type: MavenCompileOptions
- Default: defaults
Compile options.
depsOptional
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().
distdirOptional
public readonly distdir: string;
- Type: string
- Default: "dist/java"
Final artifact output directory.
junitOptional
public readonly junit: boolean;
- Type: boolean
- Default: true
Include junit tests.
junitOptionsOptional
public readonly junitOptions: JunitOptions;
- Type: JunitOptions
- Default: defaults
junit options.
packagingOptionsOptional
public readonly packagingOptions: MavenPackagingOptions;
- Type: MavenPackagingOptions
- Default: defaults
Packaging options.
projenrcJavaOptional
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.
projenrcJavaOptionsOptional
public readonly projenrcJavaOptions: ProjenrcOptions;
- Type: ProjenrcOptions
- Default: default options
Options related to projenrc in java.
testDepsOptional
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().
sampleOptional
public readonly sample: boolean;
- Type: boolean
- Default: true
Include sample code and test if the relevant directories don't exist.
sampleJavaPackageOptional
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. |
pomRequired
public readonly pom: Pom;
- Type: Pom
Java pom.
sampleJavaPackageOptional
public readonly sampleJavaPackage: string;
- Type: string
- Default: "org.acme"
Java package for test sample.
versionOptional
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. |
sourceOptional
public readonly source: string;
- Type: string
- Default: "1.8"
Source language version.
targetOptional
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. |
distdirOptional
public readonly distdir: string;
- Type: string
- Default: "dist/java"
Where to place the package output?
javadocsOptional
public readonly javadocs: boolean;
- Type: boolean
- Default: true
Include javadocs jar in package.
javadocsExcludeOptional
public readonly javadocsExclude: string[];
- Type: string[]
- Default: []
Exclude source files from docs.
sourcesOptional
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. |
idRequired
public readonly id: string;
- Type: string
The identifier for the repository.
urlRequired
public readonly url: string;
- Type: string
The url of the repository.
layoutOptional
public readonly layout: string;
- Type: string
The layout of the repository.
nameOptional
public readonly name: string;
- Type: string
The name of the repository.
releasesOptional
public readonly releases: MavenRepositoryPolicy;
- Type: MavenRepositoryPolicy
Repository Policy for Releases.
snapshotsOptional
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. |
checksumPolicyOptional
public readonly checksumPolicy: ChecksumPolicy;
- Type: ChecksumPolicy
Checksum Policy When Maven deploys files to the repository, it also deploys corresponding checksum files.
enabledOptional
public readonly enabled: boolean;
- Type: boolean
updatePolicyOptional
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. |
packageRequired
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. |
artifactIdOptional
public readonly artifactId: string;
- Type: string
Parent Pom Artifact ID.
groupIdOptional
public readonly groupId: string;
- Type: string
Parent Pom Group ID.
relativePathOptional
public readonly relativePath: string;
- Type: string
Parent Pom Relative path from the current pom.
versionOptional
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. |
goalsRequired
public readonly goals: string[];
- Type: string[]
Which Maven goals this plugin should be associated with.
idRequired
public readonly id: string;
- Type: string
The ID.
configurationOptional
public readonly configuration: {[ key: string ]: any};
- Type: {[ key: string ]: any}
- Default: {}
Execution key/value configuration.
phaseOptional
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. |
configurationOptional
public readonly configuration: {[ key: string ]: any};
- Type: {[ key: string ]: any}
- Default: {}
Plugin key/value configuration.
dependenciesOptional
public readonly dependencies: string[];
- Type: string[]
- Default: []
You could configure the dependencies for the plugin.
Dependencies are in <groupId>/<artifactId>@<semver> format.
executionsOptional
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. |
artifactIdRequired
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.
groupIdRequired
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.
versionRequired
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.
descriptionOptional
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.
packagingOptional
public readonly packaging: string;
- Type: string
- Default: "jar"
Project packaging format.
parentPomOptional
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.
urlOptional
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. |
classNameOptional
public readonly className: string;
- Type: string
- Default: "projenrc"
The name of the Java class which contains the main() method for projen.
projenVersionOptional
public readonly projenVersion: string;
- Type: string
- Default: current version
The projen version to use.
testScopeOptional
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.
minutesRequired
- Type: number
Constants
| Name | Type | Description |
|---|---|---|
| string | No description. |
| string | No description. |
| string | No description. |
ALWAYSRequired
public readonly ALWAYS: string;
- Type: string
DAILYRequired
public readonly DAILY: string;
- Type: string
NEVERRequired
public readonly NEVER: string;
- Type: string
Enums
ChecksumPolicy
Members
| Name | Description |
|---|---|
| No description. |
| No description. |
| No description. |