From WebIDE Full-stack on SAP Cloud Platform It is used when you create a new Java application project.
Knowledge of build tools in the Java area stopped at ʻant` This is a summary of some research on how to use it.
Maven
is a tool for building Java programs.
Describe the program information in pom.xml
, install the necessary modules, and
It compiles, deploys modules, etc. with commands.
Install using homebrew.
brew install maven
The following definitions can be described under the project element.
element | Description |
---|---|
modelVersion | pom version |
groupId | Project name (unique). It seems common to specify the root package name. |
artifactId | Deliverable name. Used for names such as JARs and WARs to create |
version | Project version |
packaging | Deliverable format. Specify jar or war |
name | Display name. Used when creating documents, etc. |
mvn clean
mvn compile
Compile the source file
Target source is under src / main / java /
Output the compiled class file to target / classes
mvn test
Test execution with a file that corresponds to the following pattern.
mvn package
Create an artifact in target
The file name is determined by artifactId, version and packaging of pom.xml.
Main element description method and set value
<dependencies>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
<scope>provided</scope>
</dependency>
<dependency>
~~~
</dependency>
</dependencies>
element | Description |
---|---|
dependencies | Described in the element |
dependency | Describe one module per element |
groupId | Project name (unique). It seems common to specify the root package name. |
artifactId | Deliverable name. Used for names such as JARs and WARs to create |
version | Project version |
scope | Condition specification that the library adds to the classpath |
Setting value for scope | Timing of addition |
---|---|
compile | Default value. Add to classpath in all situations |
provided | Add to classpath only at compile time |
runtime | Add to classpath during test or normal run |
test | Specify if required only during testing |
system | If you want to explicitly add system libraries to your classpath. Note that it does not search the repository. |
Recommended Posts