Maven: Difference between revisions

From bibbleWiki
Jump to navigation Jump to search
No edit summary
Line 28: Line 28:
  6  process-resources
  6  process-resources
     Copy and process the resources into the destination directory, ready for packaging phase.
     Copy and process the resources into the destination directory, ready for packaging phase.
  7  compile
  7  compile<build>
        <plugins>
 
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-site-plugin</artifactId>
                <version>3.7.1</version>
            </plugin>
<build>
        <plugins>
 
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-site-plugin</artifactId>
                <version>3.7.1</version>
            </plugin>
 
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-project-info-reports-plugin</artifactId>
                <version>3.0.0</version>
            </plugin>
 
        </plugins>
    </build>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-project-info-reports-plugin</artifactId>
                <version>3.0.0</version>
            </plugin>
 
        </plugins>
    </build>
     Compile the source code of the project.
     Compile the source code of the project.
  8  process-classes
  8  process-classes
Line 58: Line 90:
  21 deploy
  21 deploy
     Copies the final package to the remote repository for sharing with other developers and projects.
     Copies the final package to the remote repository for sharing with other developers and projects.
==Tutorial==
I followed the tutorial on
https://www.tutorialspoint.com/maven/maven_build_profiles.htm
The following error occurred
org.apache.maven.doxia.siterenderer.DocumentContent
Found the following fix on
https://mkyong.com/maven/mvn-site-java-lang-classnotfoundexception-org-apache-maven-doxia-siterenderer-documentcontent/
<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-site-plugin</artifactId>
            <version>3.7.1</version>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-project-info-reports-plugin</artifactId>
            <version>3.0.0</version>
        </plugin>
    </plugins>
</build>

Revision as of 21:31, 12 May 2020

Installation of ubuntu 20.04

Surprise nothing special

apt-get update
apt-get install maven

Set Environment

In ~/.bashrc add

export M2_HOME=/usr/share/maven
export M2=$M2_HOME/bin
export MAVEN_OPTS="-Xms256m -Xmx512m"

You can either log out or run the script with

. ~/.bashrc

Lifecyle

1  validate
   Validates whether project is correct and all necessary information is available to complete the build process.
2  initialize
   Initializes build state, for example set properties.
3  generate-sources
   Generate any source code to be included in compilation phase.
4  process-sources
   Process the source code, for example, filter any value.
5  generate-resources
   Generate resources to be included in the package.
6  process-resources
   Copy and process the resources into the destination directory, ready for packaging phase.
7  compile<build>
       <plugins>
           <plugin>
               <groupId>org.apache.maven.plugins</groupId>
               <artifactId>maven-site-plugin</artifactId>
               <version>3.7.1</version>
           </plugin>

<build>

       <plugins>
           <plugin>
               <groupId>org.apache.maven.plugins</groupId>
               <artifactId>maven-site-plugin</artifactId>
               <version>3.7.1</version>
           </plugin>
           <plugin>
               <groupId>org.apache.maven.plugins</groupId>
               <artifactId>maven-project-info-reports-plugin</artifactId>
               <version>3.0.0</version>
           </plugin>
       </plugins>
   </build>
           <plugin>
               <groupId>org.apache.maven.plugins</groupId>
               <artifactId>maven-project-info-reports-plugin</artifactId>
               <version>3.0.0</version>
           </plugin>
       </plugins>
   </build>
   Compile the source code of the project.
8  process-classes
   Post-process the generated files from compilation, for example to do bytecode enhancement/optimization on Java classes.
9  generate-test-sources
   Generate any test source code to be included in compilation phase.
10 process-test-sources
   Process the test source code, for example, filter any values.
11 test-compile
   Compile the test source code into the test destination directory.
12 process-test-classes
   Process the generated files from test code file compilation.
13 test
   Run tests using a suitable unit testing framework (Junit is one).
14 prepare-package
   Perform any operations necessary to prepare a package before the actual packaging.
15 package
   Take the compiled code and package it in its distributable format, such as a JAR, WAR, or EAR file.
16 pre-integration-test
   Perform actions required before integration tests are executed. For example, setting up the required environment.
17 integration-test
   Process and deploy the package if necessary into an environment where integration tests can be run.
18 post-integration-test
   Perform actions required after integration tests have been executed. For example, cleaning up the environment.
19 verify
   Run any check-ups to verify the package is valid and meets quality criteria.
20 install
   Install the package into the local repository, which can be used as a dependency in other projects locally.
21 deploy
   Copies the final package to the remote repository for sharing with other developers and projects.

Tutorial

I followed the tutorial on

https://www.tutorialspoint.com/maven/maven_build_profiles.htm

The following error occurred

org.apache.maven.doxia.siterenderer.DocumentContent

Found the following fix on

https://mkyong.com/maven/mvn-site-java-lang-classnotfoundexception-org-apache-maven-doxia-siterenderer-documentcontent/
<build>
    <plugins> 
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-site-plugin</artifactId>
            <version>3.7.1</version>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-project-info-reports-plugin</artifactId>
            <version>3.0.0</version>
        </plugin>
    </plugins>
</build>