[Maven] About Maven

■ Overview

--Learn about Maven at the following site and curate (summary) what you learned
https://www.techscore.com/tech/Java/ApacheJakarta/Maven/index/

■ What is Maven?

--Software PJ management tool developed by ʻApache Software Foundation --Manage PJ life cycle with the idea ofProject Object Model (POM) -<font color = "Red"> All PJ information is aggregated inpom.xml` </ font> ――The merit is ** Support function to support developers to understand PJ in a short period of time ** --The disadvantage is that you can't benefit if you don't understand Maven **

■ How to get

--Available from the following site
https://maven.apache.org/download.cgi --Qiita article that will be helpful for introduction
https://qiita.com/saitoryc/items/737ee9e711f1ebe0dcfa

■ Architecture

画像
参照元:https://www.techscore.com/tech/Java/ApacheJakarta/Maven/index/

--Each task can be performed using the mvn command --The build method is the same even if the PJ is different ( Advantages of Maven </ font>) --Plugins and libraries are placed in local / remote repositories --Life cycle flow

① PJ creation
② Compile
③ Unit test
④ Documentation
⑤JAR creation
⑥ Reflection in local repository
⑦ Reflection in remote repository
⑧ PJ clear

■ Execution of Maven

--Execute the mvn command --Specify the task you want to perform with an argument --Set conf / setting.xml according to the environment --You can check the unknown part with -help argument

■ Life cycle

--Check points for each life cycle

① PJ creation

--You can create a PJ template (skeleton) --pom.xml is created by default --Standard directory structure is recommended --Files required to create artifacts are placed under src

|path|Commentary|
|:--|:--|
|src/main/java|java source code|
|src/test/java|Java source code for testing|

--Each element of pom.xml

|element|Commentary|

| :-- | :-- | | modelversion |POM version
* No special changes required| | groupId |A name that uniquely identifies the PJ.
It is common to specify the root package name of PJ.| | artifactId |The name of the PJ artifact.
Jar to create/Used for names such as war.| | packaging |The package type of the artifact to be created.
The default is jar.| | version |PJ version.| | name |Display name of PJ.
Used when creating documents.| | url |URL of PJ's site.
Used when creating documents.| | dependencies |Information about the libraries that PJ depends on.|

$ mvn archetype:generate -DgroupId=<ID> -DartifactId=<ID>

[Explanation of arguments]
- archetype:generate → Arguments that specify template creation
- -DgroupId → PJ root package name
- -DartifactId → PJ name

② Compile

--Convert source code to PJ executable format (.class) --The created class file will be output under target / class

$ mvn compile

③ Unit test

$ mvn test

--By default, files that meet the following conditions are run as tests

```

*/Test.java **/*Test.java **/*TestCase.java


 --By default, files that meet the following conditions are excluded from the test

	```
**/Abstract*Test.java
**/Abstract*TestCase.java
**/*$*

④ Documentation

1. Creating Javadoc

--Javadoc is placed under target / javadoc

$ mvn javadoc:javadoc

2. Creating a site

--By default, necessary information is placed under src / site --Information on site creation can be found in src / site / site.xml

$ mvn site

⑤ Create JAR file

--The name of the JAR file is determined from ʻartifactId and versioninpom.xml` --JAR file is placed under target

mvn package

⑥ Installation to local repository

--The created JAR file can be installed (reflected) in the local repository. --When the installation (reflection) is completed, you can refer to it from other PJs.

mvn install

⑦ Placement in remote repository

--It is necessary to set the required repository information in pom.xml --Add a repository element as a nest of the pom.xml> project / project / distributionManagement element --Child element of repository

|Element name|Commentary|

|:--|:--| |id|Repository identifier| |name|The name of the repository| |url|URL indicating the location of the repository|

$ mvn deploy

⑧ PJ clean

--Delete the subordinate of target

$ mvn clean

Recommended Posts

[Maven] About Maven
maven
About =
About method.invoke
About attr_accessor
About Hinemos
About inheritance
About params
About Docker
About Rails 6
About Spring ③
About enum
About polymorphism
About Optional
About hashes
About Dockerfile
About this ()
About devise
About Docker
About JAVA_HOME
About active_hash
About static
About exceptions
Maven learning
About scope
About exception handling
About Java interface
[Java] About Java 12 features
Create Maven Project
About Rails routing
About cyclomatic complexity
About exception handling
About AsyncTask Generics
About array multiplication
Try using Maven
[Java] About arrays
java, maven memo
What is maven?
About ruby ​​form
[Swift] About generics
About Active Storage
About class inheritance.
About Spring AOP
About Ruby Hashes
About singular methods
About getter setter
About build tools
About MacinCloud introduction
[Note] About nil
About keyword arguments
Chew about API
[About double hash]
About installing Cocoapods
Something about java
Where about java
About HttpServlet () methods
About Java features
About ActiveRecord :: PendingMigrationError
About the method
About standard classes
About spring AOP