IT-SDK-Maven

From wiki.samerhijazi.net
Jump to navigation Jump to search

Ref.

Proxy


Creating a Project

mvn archetype:generate -DartifactId=app -DgroupId=com.company.app -DinteractiveMode=false
mvn archetype:generate -DartifactId=app -DgroupId=com.company.app -DinteractiveMode=false -DarchetypeArtifactId=maven-archetype-quickstart

Install Pachage

mvn install:install-file -Dfile=<path-to-file> -DgroupId=<group-id> -DartifactId=<artifact-id> -Dversion=<version> -Dpackaging=<packaging>
mvn install:install-file -Dfile=<path-to-file> -DpomFile=<path-to-pomfile>

Maven Phases

mvn clean       # cleans up artifacts created by prior builds
mvn validate    # validate the project is correct and all necessary information is available
mvn compile     # compile the source code of the project
mvn package     # take the compiled code and package it in its distributable format, such as a JAR.
mvn install     # install the package into the local repository, for use as a dependency in other projects locally
mvn deploy      # done in an integration or release environment, copies the final package to the remote repository for sharing with other developers and projects.

Maven POM

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.company</groupId>
  <artifactId>mqtt-mvn</artifactId>
  <version>1.0-SNAPSHOT</version>
  <packaging>jar</packaging>
  <name>mqtt-mvn</name>  
  <properties>
    <compiler-plugin.version>3.8.1</compiler-plugin.version>
    <maven.compiler.release>11</maven.compiler.release>
    <maven.compiler.source>1.8</maven.compiler.source>
    <maven.compiler.target>1.8</maven.compiler.target>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
  </properties>
  <dependencies>
    <dependency>
      <groupId>com.hivemq</groupId>
      <artifactId>hivemq-mqtt-client</artifactId>
      <version>1.3.0</version>
    </dependency>
  </dependencies>
  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.8.1</version>
        <configuration>
          <source>1.8</source>
          <target>1.8</target>
        </configuration>
      </plugin>
    </plugins>
  </build>
</project>