Pages

Showing posts with label java. Show all posts
Showing posts with label java. Show all posts

Saturday, 4 December 2021

Maven

 Basic commands

mvn compile     # compile the project
mvn deploy     # validate--> compile--> test--> package -->verify --> install -->deploy

mvn clean package  -Dmaven.test.skip=true # clean the build files and do package but skip test file compilation


Run integration test

mvn failsafe:integration-test

Skip Nexus deploy plugin

You can use the Nexus Staging Plugin's property skipNexusStagingDeployMojo to achieve this:

mvn clean package deploy:deploy -DskipNexusStagingDeployMojo=true 
-DaltDeploymentRepository=snapshots::default::https://my.nexus.host/content/repositories/snapshots-local

It is important to explicitly invoke package and then deploy:deploy, as otherwise (when only invoking mvn deploy) the default execution of the maven-deploy-plugin is suppressed by the Nexus Staging Plugin (even with the skip set to true).


fail at end


-fae,--fail-at-end Only fail the build afterwards; allow all non-impacted builds to continue
-fn,--fail-never NEVER fail the build, regardless of project result


Create src archive explicitly

org.apache.maven.plugins:maven-source-plugin:3.2.0:jar




Maven deploy locally

mvn deploy -DaltDeploymentRepository=local::file:./target/staging-deploy






Dependency check pom plugin

A mvn plugin to generate a report on dependencies:

mvn   site:stage  -DskipTests=true

https://maven.apache.org/plugins/maven-site-plugin/



Pom.xml


<distributionManagement>

<site>

      <id>mojo.website</id>

      <name>Mojo Website</name>

      <url>scp://localhost/scratch/kpokkana/workdir/simple-http-server-py/index-root/kpokkana/target2/</url>

    </site>

</distributionManagement>



<build>

        <plugins>

        <plugin>

        <groupId>org.owasp</groupId>

        <artifactId>dependency-check-maven</artifactId>

        <version>6.0.2</version>

        <executions>

        <execution>

        <goals>

        <goal>check</goal>

        </goals>

        </execution>

        </executions>

        </plugin>


<plugin>

    <groupId>org.apache.maven.plugins</groupId>

    <artifactId>maven-site-plugin</artifactId>

    <version>3.7.1</version>

 </plugin>


        </plugins>

        </build>