## page was renamed from ApacheMaven <> = Apache Maven = Maven is a software project management and comprehension tool. Based on the concept of a Project Object Model (POM), Maven can manage a project's build, reporting and documentation from a central piece of information. Requires Java. == Lifecycles and phases == * https://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html#Lifecycle_Reference === Clean Lifecycle === * pre-clean: execute processes needed prior to the actual project cleaning * clean: remove all files generated by the previous build * post-clean: execute processes needed to finalize the project cleaning === Default Lifecycle === * validate: validate the project is correct and all necessary information is available. * initialize: initialize build state, e.g. set properties or create directories. * generate-sources: generate any source code for inclusion in compilation. * process-sources: process the source code, for example to filter any values. * generate-resources: generate resources for inclusion in the package. * process-resources: copy and process the resources into the destination directory, ready for packaging. * compile: compile the source code of the project. * process-classes: post-process the generated files from compilation, for example to do bytecode enhancement on Java classes. * generate-test-sources: generate any test source code for inclusion in compilation. * process-test-sources: process the test source code, for example to filter any values. * generate-test-resources: create resources for testing. * process-test-resources: copy and process the resources into the test destination directory. * test-compile: compile the test source code into the test destination directory * process-test-classes: post-process the generated files from test compilation, for example to do bytecode enhancement on Java classes. * test: run tests using a suitable unit testing framework. These tests should not require the code be packaged or deployed. * prepare-package: perform any operations necessary to prepare a package before the actual packaging. This often results in an unpacked, processed version of the package. * package: take the compiled code and package it in its distributable format, such as a JAR. * pre-integration-test: perform actions required before integration tests are executed. This may involve things such as setting up the required environment. * integration-test: process and deploy the package if necessary into an environment where integration tests can be run. * post-integration-test: perform actions required after integration tests have been executed. This may including cleaning up the environment. * verify: run any checks to verify the package is valid and meets quality criteria. * install: install the package into the local repository, for use as a dependency in other projects locally. * deploy: done in an integration or release environment, copies the final package to the remote repository for sharing with other developers and projects. === Site Lifecycle === * pre-site: execute processes needed prior to the actual project site generation * site: generate the project's site documentation * post-site: execute processes needed to finalize the site generation, and to prepare for site deployment * site-deploy: deploy the generated site documentation to the specified web server == Slackbuild == {{{#!highlight sh su cd /tmp wget https://slackbuilds.org/slackbuilds/14.2/development/apache-maven.tar.gz tar xvzf apache-maven.tar.gz cd apache-maven wget http://archive.apache.org/dist/maven/maven-3/3.8.1/binaries/apache-maven-3.8.1-bin.tar.gz ./apache-maven.SlackBuild installpkg /tmp/apache-maven-3.8.1-noarch-1_SBo.tgz }}} == User settings == You can specify your user configuration in ${user.home}/.m2/settings.xml. The default location of your local repository is ${user.home}/.m2/repository/. == Maven sample web app for JBoss AS 7.1.1 == === Web application creation === {{{#!highlight sh cd ~ mvn archetype:generate -DgroupId=org.allowed.bitarus -DartifactId=WebApp -DarchetypeArtifactId=maven-archetype-webapp -DinteractiveMode=false cd WebApp mvn clean mvn compile mvn package }}} Sample WebApp file with source code to use MySQL data source:[[attachment:WebApp.zip]] Sample WebAppJersey2, with dependencies for Jersey2 and JSON, to be deployed on Tomcat 7:[[attachment:WebAppJersey2.zip]] === Deploy web application on jboss AS 7.1.1 === {{{#!highlight sh /opt/jboss-as-7.1.1.Final/bin/standalone.sh # http://localhost:9990 # admin 12345678 # Manage deployments # Add content # Choose file ~/WebApp/target/WebApp.war # next, save # enable , confirm # http://localhost:8080/WebApp/ }}} === Add REST and servlet support === * url http://localhost:8080/WebApp/rest/testSvc/paramx Add dependencies to pom.xml, jboss AS 7.1.1 JAX-RS {{{#!highlight xml org.jboss.resteasy resteasy-jaxrs 2.2.1.GA provided javax javaee-web-api 6.0 provided }}} In JBoss 5.1.0 comment the scope provided for resteasy, to add to WEB-INF folder the required libraries for resteasy. === Create source code for REST service and servlet === ==== src/main/java/org/allowed/bitarus/TestService.java ==== URL http://localhost:8080/WebApp/rest/testSvc/asddddd {{{#!highlight java package org.allowed.bitarus; import javax.ws.rs.GET; import javax.ws.rs.Path; import javax.ws.rs.PathParam; import javax.ws.rs.core.Response; @Path("/testSvc") public class TestService { @GET @Path("/{param}") public Response getMsg(@PathParam("param") String msg) { String out = String.format("testSvc returns %s", msg); return Response.status(200).entity(out).build(); } } }}} ==== src/main/java/org/allowed/bitarus/Servletx.java ==== http://localhost:8080/WebApp/servletxxx {{{#!highlight java // File src/main/java/org/allowed/bitarus/Servletx.java // References EJB in JBoss5. Test to see EJB invocation from Tomcat package org.allowed.bitarus; import javax.servlet.*; import javax.servlet.http.*; import java.io.*; import java.security.Security; import java.util.Properties; import javax.naming.Context; import javax.naming.InitialContext; import org.allowed.bitarus.IWSTest; public class Servletx extends HttpServlet{ public void service(HttpServletRequest req, HttpServletResponse res) throws IOException { res.setContentType("text/html"); PrintWriter out = res.getWriter(); String text=""; try{ Properties env = new Properties(); env.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory"); env.put(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces"); env.put(Context.PROVIDER_URL, "jnp://127.0.0.1:1099"); InitialContext context = new InitialContext(env); IWSTest test = (IWSTest) context.lookup("WSTest/remote"); text=test.helloWorld(); } catch(Exception ex){ } out.println("Hello World!"); out.println(String.format("

Hello World! %s

",text)); } } }}} Dependency for JAR that has IWSTest interface that WSTest EJB implements: {{{#!highlight xml org.allowed.bitarus test2 0.0.1 }}} === Configure web app === ==== src/main/webapp/WEB-INF/web.xml ==== {{{#!highlight xml Archetype Created Web Application resteasy.scan true resteasy.servlet.mapping.prefix /rest resteasy-servlet org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher resteasy-servlet /rest/* Servletx org.allowed.bitarus.Servletx Servletx /servletxxx }}} == Dependencies scopes on pom.xml == === compile === compile is the default scope; all dependencies are compile-scoped if a scope is not supplied. compile dependencies are available in all classpaths, and '''they are packaged'''. === provided === provided dependencies are used when you expect the '''JDK or a container to provide them'''. == Eclipse plugin == === Install on Eclipse 3.8.2 === * Choose Help menu * Install new software * Name: M2Eclipse * Location: http://download.eclipse.org/technology/m2e/releases * Maven Integration For Eclipse * Select all * next * next * I accept * Finish === Import existing project === * Java perspective * Import * Maven * Existing Maven project * next * root folder * next * finish == Maven sample enterprise app == {{{#!highlight sh cd /tmp mvn archetype:generate -DgroupId=org.allowed.bitarus -DartifactId=EnterpriseApp -DarchetypeArtifactId=org.jboss.spec.archetypes.jboss-javaee6-ear-webapp -DinteractiveMode=false cd EnterpriseApp/ # Edit pom.xml and comment site module mvn clean mvn compile mvn package # /tmp/EnterpriseApp/EnterpriseApp-ear/target/EnterpriseApp.ear # Deploy the EnterpriseApp.ear with http://localhost:9990 (JBoss/Wildfly web console) # Open http://localhost:8080/EnterpriseApp/index.jsf }}} == Maven sample EJB JEE5 == {{{#!highlight sh cd /tmp mvn archetype:generate -DgroupId=org.allowed.bitarus -DartifactId=EjbJEE5 -DarchetypeArtifactId=org.codehaus.mojo.archetypes.ejb-jee5 -DinteractiveMode=false cd EnterpriseApp/ # Edit pom.xml and comment site module mvn clean mvn compile mvn package # /tmp/EnterpriseApp/EnterpriseApp-ear/target/EnterpriseApp.ear }}} == POM EJB 3.0 + JAX-WS + JBoss 5.1.0 == For JBoss 5.0. Source code Java below folder ejbModule. Create source folder in Eclipse named ejbModule. === pom.xml === {{{#!highlight xml 4.0.0 org.allowed.bitarus test2 0.0.1 ejb ejbModule ejbModule **/*.java maven-ejb-plugin 2.3 3.0 javax.ejb ejb-api 3.0 sun-jaxws jsr181-api 1.0 javaee javaee-api 5 }}} === ejbModule/org/allowed/bitarus/WSTest.java === {{{#!highlight java package org.allowed.bitarus; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.util.ArrayList; import javax.ejb.Stateless; import javax.jws.WebMethod; import javax.jws.WebService; import javax.naming.Context; import javax.naming.InitialContext; /** * Session Bean implementation class WSTest */ @Stateless @WebService // http://localhost:8080/test2-0.0.1/WSTest?wsdl public class WSTest implements WSTestRemote, WSTestLocal { private static final String QUERY1 = "SELECT distinct table_name FROM user_tables"; private static final String JNDI_DATASOURCE = "java:OracleDS"; // private static final String QUERY1 = "select table_name from information_schema.tables;"; // private static final String JNDI_DATASOURCE = "java:/MysqlDS"; public WSTest() { } @WebMethod public String helloWorld() { return "Hello world"; } @WebMethod public String[] checkDB() { ArrayList list = new ArrayList(); Connection conn = null; PreparedStatement ps = null; ResultSet rs = null; try { Context ctx = new InitialContext(); conn = ((javax.sql.DataSource) ctx.lookup(WSTest.JNDI_DATASOURCE)).getConnection(); ps = conn.prepareStatement(WSTest.QUERY1); rs = ps.executeQuery(); while (rs.next()) { list.add(rs.getString(1)); } } catch (Exception e) { list.add(e.getMessage()); } finally { if (rs != null) { try { rs.close(); } catch (SQLException e) { e.printStackTrace(); } } if (ps != null) { try { ps.close(); } catch (SQLException e) { e.printStackTrace(); } } if (conn != null) { try { conn.close(); } catch (SQLException e) { e.printStackTrace(); } } } String[] r = new String[list.size()]; list.toArray(r); return r; } } }}} === ejbModule/org/allowed/bitarus/WSTestLocal.java === {{{#!highlight java //WSTestLocal.java package org.allowed.bitarus; import javax.ejb.Local; @Local public interface WSTestLocal extends IWSTest{ } }}} ejbModule/org/allowed/bitarus/WSTestRemote.java {{{#!highlight java //WSTestRemote.java package org.allowed.bitarus; import javax.ejb.Remote; @Remote public interface WSTestRemote extends IWSTest{ } }}} === ejbModule/org/allowed/bitarus/IWSTest.java === {{{#!highlight java //IWSTest package org.allowed.bitarus; public interface IWSTest { public String helloWorld(); } }}} Build EJB JAR with maven {{{#!highlight sh mvn clean compile package }}} In http://localhost:8080/admin-console/ at link EJB 3.x Application (EJB JAR), add resource test2-0.0.1.jar. In JBoss 5.1.0 copy the following libraries from the JBOSS_HOME/client directory to the JBOSS_HOME/lib/endorsed directory, so that the JAX-WS 2.0 apis supported by JBossWS are used: * jbossws-native-saaj.jar * jbossws-native-jaxrpc.jar * jbossws-native-jaxws.jar * jbossws-native-jaxws-ext.jar Check deployed EJB with http://localhost:8080/test2-0.0.1/WSTest?wsdl Project structure: {{{#!highlight sh . |-- ejbModule | `-- org | `-- allowed | `-- bitarus | |-- IWSTest.java | |-- WSTest.java | |-- WSTestLocal.java | `-- WSTestRemote.java |-- pom.xml `-- target |-- classes | `-- org | `-- allowed | `-- bitarus | |-- IWSTest.class | |-- WSTest.class | |-- WSTestLocal.class | `-- WSTestRemote.class |-- maven-archiver | `-- pom.properties |-- surefire `-- test2-0.0.1.jar }}} === Oracle datasource for JBoss 5 === Copy to <...>\jboss-5.1.0.GA\server\default\deploy\oracle-ds.xml Copy ojdbc6.jar to <...>\jboss-5.1.0.GA\server\default\lib {{{#!highlight xml OracleDS jdbc:oracle:thin:@localhost:1521:xe oracle.jdbc.driver.OracleDriver SYSTEM jboss org.jboss.resource.adapter.jdbc.vendor.OracleValidConnectionChecker Oracle9i }}} === MySQL datasource for JBoss 5 === Copy to <...>\jboss-5.1.0.GA\server\default\deploy\mysql-ds.xml Copy mysql-connector-java-5.1.30-bin.jar to <...>\jboss-5.1.0.GA\server\default\lib {{{#!highlight xml MysqlDS jdbc:mysql://localhost:3306/mysql com.mysql.jdbc.Driver root 12345678 org.jboss.resource.adapter.jdbc.vendor.MySQLValidConnectionChecker mySQL }}} == Assembly plugin == The Assembly Plugin for Maven is primarily intended to allow users to aggregate the project output along with its dependencies, modules, site documentation, and other files into a single distributable archive. http://maven.apache.org/plugins/maven-assembly-plugin/usage.html {{{ maven-assembly-plugin 2.4 jar-with-dependencies }}} == Standalone app - Fat JAR == === pom.xml === {{{#!highlight xml 4.0.0 com.example artifactX jar 0.0.1 artifactX http://maven.apache.org maven-assembly-plugin 2.4 jar-with-dependencies com.example.Main make-assembly package single com.google.code.gson gson 2.3 mysql mysql-connector-java 5.1.31 compile org.slf4j slf4j-api 1.7.7 org.slf4j slf4j-simple 1.7.7 }}} === Init script CentOS/Fedora === * In debian /etc/init.d/progx {{{#!highlight sh #!/bin/sh # chkconfig: 345 99 99 # description: Starts and stops the progx process USER=userx PROG=progx PIDFILE="/tmp/progx.pid" PATH="/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin:/usr/local/sbin" LOG="/tmp/progx.log" JAVA="/usr/java/jdk1.6.0_26/bin/java" JARFILE="/home/userx/progx-0.0.1-jar-with-dependencies.jar" start(){ echo "Start called $PROG with user $USER" su - $USER -c "$JAVA -jar $JARFILE " & /bin/sleep 2 PID=`ps uax| grep java | grep $PROG | grep $USER | awk '{print $2}'` echo "Program $PROG running with PID: $PID" echo "$PID" > $PIDFILE } status(){ PID=`cat $PIDFILE` echo "Running $PROG with PID: $PID" } stop(){ echo "Stop called for $PROG" PID=`cat $PIDFILE` echo "PID to kill $PROG $PID" kill -9 $PID rm $PIDFILE } # switch case "$1" in start) start ;; status) status ;; stop) stop ;; restart) stop start ;; *) echo "$PROG start|status|stop|restart" exit 1 ;; esac }}} == Install JAR local repository == To install a JAR in the local repository use the following command: {{{#!highlight sh mvn install:install-file -Dfile= -DgroupId= -DartifactId= -Dversion= -Dpackaging= }}} {{{#!highlight sh mvn install:install-file -DgroupId=com.sun -DartifactId=tools -Dversion=1.4.2 -Dpackaging=jar -Dfile=C:\temp\test\tools.jar }}} Dependency: {{{ com.sun tools 1.4.2 }}} == Maven skip tests == http://maven.apache.org/surefire/maven-surefire-plugin/examples/skipping-test.html {{{#!highlight sh mvn clean install -Dmaven.test.skip=true mvn clean install -DskipTests }}} or {{{#!highlight xml org.apache.maven.plugins maven-surefire-plugin 2.18.1 true }}} == Ant run plugin - copy == * https://maven.apache.org/plugins/maven-antrun-plugin/usage.html * https://ant.apache.org/manual/ The maven-antrun-plugin has only one goal, run. {{{#!highlight xml org.apache.maven.plugins maven-antrun-plugin 1.8 copy install run }}} == Download javadoc == {{{#!highlight sh mvn clean install dependency:resolve -Dclassifier=javadoc }}} == Install raw maven in Slackware == {{{#!highlight sh cd ~/Downloads wget http://www-eu.apache.org/dist/maven/maven-3/3.5.3/binaries/apache-maven-3.5.3-bin.tar.gz cp apache-maven-3.5.3-bin.tar.gz /opt/java cd /opt/java tar xvzf apache-maven-3.5.3-bin.tar.gz cd apache-maven-3.5.3/bin/ ./mvn PATH=$PATH:/opt/java/jdk1.8.0_162/bin:/opt/java/apache-maven-3.5.3/bin }}} == Check dependencies for artifact == * set artifact in pom.xml file * run mvn dependency:tree --log-file out.txt {{{#!highlight xml 4.0.0 check-dep check-dep 0.0.1 pom android-repo android-repo https://dl.google.com/dl/android/maven2/ spring-io-plugins-release spring-io-plugins-release https://repo.spring.io/plugins-release/ com.android.tools.build gradle 2.3.1 androidx.annotation annotation 1.0.0 androidx.core core 1.0.2 aar androidx.legacy legacy-support-v4 1.0.0 aar com.google.android.gms play-services-analytics 11.0.1 aar com.google.firebase firebase-analytics 17.2.3 aar com.google.firebase firebase-messaging 20.1.7 aar com.squareup.okhttp3 okhttp-urlconnection 3.10.0 me.leolin ShortcutBadger 1.1.22 aar com.android.support appcompat-v7 23.4.0 aar }}} === Sample output === {{{ [INFO] [INFO] --- maven-dependency-plugin:2.8:tree (default-cli) @ check-dep --- [INFO] check-dep:check-dep:pom:0.0.1 [INFO] +- com.android.tools.build:gradle:jar:2.3.1:compile [INFO] | \- com.android.tools.build:gradle-core:jar:2.3.1:runtime [INFO] | +- com.android.tools.build:builder:jar:2.3.1:runtime [INFO] | | +- com.android.tools.build:builder-model:jar:2.3.1:runtime [INFO] | | +- com.android.tools.build:builder-test-api:jar:2.3.1:runtime [INFO] | | +- com.android.tools:sdklib:jar:25.3.1:runtime [INFO] | | | +- com.android.tools.layoutlib:layoutlib-api:jar:25.3.1:runtime [INFO] | | | | \- com.intellij:annotations:jar:12.0:runtime [INFO] | | | +- com.android.tools:dvlib:jar:25.3.1:runtime [INFO] | | | +- com.android.tools:repository:jar:25.3.1:runtime [INFO] | | | | \- com.google.jimfs:jimfs:jar:1.1:runtime [INFO] | | | +- com.google.code.gson:gson:jar:2.2.4:runtime [INFO] | | | +- org.apache.commons:commons-compress:jar:1.8.1:runtime [INFO] | | | +- org.apache.httpcomponents:httpclient:jar:4.1.1:runtime [INFO] | | | | +- org.apache.httpcomponents:httpcore:jar:4.1:runtime [INFO] | | | | +- commons-logging:commons-logging:jar:1.1.1:runtime [INFO] | | | | \- commons-codec:commons-codec:jar:1.4:runtime [INFO] | | | \- org.apache.httpcomponents:httpmime:jar:4.1:runtime [INFO] | | +- com.android.tools:sdk-common:jar:25.3.1:runtime [INFO] | | +- com.android.tools:common:jar:25.3.1:runtime [INFO] | | +- com.android.tools.build:manifest-merger:jar:25.3.1:runtime [INFO] | | | \- net.sf.kxml:kxml2:jar:2.3.0:runtime [INFO] | | +- com.android.tools.ddms:ddmlib:jar:25.3.1:runtime [INFO] | | +- com.android.tools.jack:jack-api:jar:0.13.0:runtime [INFO] | | +- com.android.tools.jill:jill-api:jar:0.10.0:runtime [INFO] | | +- com.android.tools.analytics-library:protos:jar:25.3.1:runtime [INFO] | | +- com.android.tools.analytics-library:shared:jar:25.3.1:runtime [INFO] | | +- com.android.tools.analytics-library:tracker:jar:25.3.1:runtime [INFO] | | +- com.squareup:javawriter:jar:2.5.0:runtime [INFO] | | +- org.bouncycastle:bcpkix-jdk15on:jar:1.48:runtime [INFO] | | +- org.bouncycastle:bcprov-jdk15on:jar:1.48:runtime [INFO] | | \- org.ow2.asm:asm-tree:jar:5.0.4:runtime [INFO] | +- com.android.tools.lint:lint:jar:25.3.1:runtime [INFO] | | +- com.android.tools.lint:lint-checks:jar:25.3.1:runtime [INFO] | | | +- com.android.tools.lint:lint-api:jar:25.3.1:runtime [INFO] | | | | +- com.android.tools.external.com-intellij:uast:jar:162.2228.14:runtime [INFO] | | | | \- com.android.tools.external.lombok:lombok-ast:jar:0.2.3:runtime [INFO] | | | \- org.ow2.asm:asm-analysis:jar:5.0.4:runtime [INFO] | | \- org.eclipse.jdt.core.compiler:ecj:jar:4.6.1:runtime [INFO] | +- com.android.tools.build:transform-api:jar:2.0.0-deprecated-use-gradle-api:runtime [INFO] | +- com.android.tools.build:gradle-api:jar:2.3.1:runtime [INFO] | | \- com.google.guava:guava:jar:18.0:runtime [INFO] | +- com.android.databinding:compilerCommon:jar:2.3.1:runtime [INFO] | | +- com.android.databinding:baseLibrary:jar:2.3.1:runtime [INFO] | | +- org.antlr:antlr4:jar:4.5.3:runtime [INFO] | | +- commons-io:commons-io:jar:2.4:runtime [INFO] | | +- com.googlecode.juniversalchardet:juniversalchardet:jar:1.0.3:runtime [INFO] | | \- com.android.tools:annotations:jar:24.5.0:runtime [INFO] | +- org.ow2.asm:asm:jar:5.0.4:runtime [INFO] | +- org.ow2.asm:asm-commons:jar:5.0.4:runtime [INFO] | +- net.sf.proguard:proguard-gradle:jar:5.3.2:runtime [INFO] | | \- net.sf.proguard:proguard-base:jar:5.3.2:runtime [INFO] | +- org.jacoco:org.jacoco.core:jar:0.7.5.201505241946:runtime [INFO] | | \- org.ow2.asm:asm-debug-all:jar:5.0.1:runtime [INFO] | +- org.jacoco:org.jacoco.report:jar:0.7.5.201505241946:runtime [INFO] | +- net.sf.jopt-simple:jopt-simple:jar:4.9:runtime [INFO] | +- com.google.protobuf:protobuf-java:jar:3.0.0:runtime [INFO] | \- org.antlr:antlr:jar:3.5.2:runtime [INFO] | +- org.antlr:antlr-runtime:jar:3.5.2:runtime [INFO] | \- org.antlr:ST4:jar:4.0.8:runtime [INFO] +- androidx.annotation:annotation:jar:1.0.0:compile [INFO] +- androidx.core:core:aar:1.0.2:compile [INFO] | +- androidx.collection:collection:jar:1.0.0:compile [INFO] | +- androidx.lifecycle:lifecycle-runtime:aar:2.0.0:compile [INFO] | | +- androidx.lifecycle:lifecycle-common:jar:2.0.0:compile [INFO] | | \- androidx.arch.core:core-common:jar:2.0.0:compile [INFO] | \- androidx.versionedparcelable:versionedparcelable:aar:1.0.0:compile [INFO] +- androidx.legacy:legacy-support-v4:aar:1.0.0:compile [INFO] | +- androidx.media:media:aar:1.0.0:compile [INFO] | +- androidx.legacy:legacy-support-core-utils:aar:1.0.0:compile [INFO] | | +- androidx.documentfile:documentfile:aar:1.0.0:compile [INFO] | | +- androidx.loader:loader:aar:1.0.0:compile [INFO] | | | \- androidx.lifecycle:lifecycle-livedata:aar:2.0.0:compile [INFO] | | | +- androidx.arch.core:core-runtime:aar:2.0.0:compile [INFO] | | | \- androidx.lifecycle:lifecycle-livedata-core:aar:2.0.0:compile [INFO] | | +- androidx.localbroadcastmanager:localbroadcastmanager:aar:1.0.0:compile [INFO] | | \- androidx.print:print:aar:1.0.0:compile [INFO] | +- androidx.legacy:legacy-support-core-ui:aar:1.0.0:compile [INFO] | | +- androidx.customview:customview:aar:1.0.0:compile [INFO] | | +- androidx.viewpager:viewpager:aar:1.0.0:compile [INFO] | | +- androidx.coordinatorlayout:coordinatorlayout:aar:1.0.0:compile [INFO] | | +- androidx.drawerlayout:drawerlayout:aar:1.0.0:compile [INFO] | | +- androidx.slidingpanelayout:slidingpanelayout:aar:1.0.0:compile [INFO] | | +- androidx.interpolator:interpolator:aar:1.0.0:compile [INFO] | | +- androidx.swiperefreshlayout:swiperefreshlayout:aar:1.0.0:compile [INFO] | | +- androidx.asynclayoutinflater:asynclayoutinflater:aar:1.0.0:compile [INFO] | | \- androidx.cursoradapter:cursoradapter:aar:1.0.0:compile [INFO] | \- androidx.fragment:fragment:aar:1.0.0:compile [INFO] | \- androidx.lifecycle:lifecycle-viewmodel:aar:2.0.0:compile [INFO] +- com.google.android.gms:play-services-analytics:aar:11.0.1:compile [INFO] | +- com.google.android.gms:play-services-analytics-impl:aar:11.0.1:compile (version selected from constraint [11.0.1,11.0.1]) [INFO] | +- com.google.android.gms:play-services-base:aar:11.0.1:compile (version selected from constraint [11.0.1,11.0.1]) [INFO] | | \- com.google.android.gms:play-services-tasks:aar:11.0.1:compile (version selected from constraint [11.0.1,11.0.1]) [INFO] | +- com.google.android.gms:play-services-basement:aar:11.0.1:compile (version selected from constraint [11.0.1,11.0.1]) [INFO] | \- com.google.android.gms:play-services-tagmanager-v4-impl:aar:11.0.1:compile (version selected from constraint [11.0.1,11.0.1]) [INFO] +- com.google.firebase:firebase-analytics:aar:17.2.3:compile [INFO] | +- com.google.android.gms:play-services-measurement:aar:17.2.3:compile [INFO] | | +- com.google.android.gms:play-services-measurement-base:aar:17.2.3:compile (version selected from constraint [17.2.3,17.2.3]) [INFO] | | \- com.google.android.gms:play-services-measurement-impl:aar:17.2.3:compile (version selected from constraint [17.2.3,17.2.3]) [INFO] | | \- com.google.android.gms:play-services-ads-identifier:aar:17.0.0:compile [INFO] | +- com.google.android.gms:play-services-measurement-api:aar:17.2.3:compile [INFO] | | \- com.google.android.gms:play-services-measurement-sdk-api:aar:17.2.3:compile (version selected from constraint [17.2.3,17.2.3]) [INFO] | \- com.google.android.gms:play-services-measurement-sdk:aar:17.2.3:compile [INFO] +- com.google.firebase:firebase-messaging:aar:20.1.7:compile [INFO] | +- com.google.android.datatransport:transport-api:aar:2.2.0:compile [INFO] | +- com.google.android.datatransport:transport-backend-cct:aar:2.2.0:compile [INFO] | +- com.google.android.datatransport:transport-runtime:aar:2.2.0:compile [INFO] | | \- com.google.dagger:dagger:jar:2.24:compile [INFO] | | \- javax.inject:javax.inject:jar:1:compile [INFO] | +- com.google.android.gms:play-services-stats:aar:17.0.0:compile [INFO] | +- com.google.firebase:firebase-common:aar:19.3.0:compile [INFO] | | \- com.google.auto.value:auto-value-annotations:jar:1.6.5:compile [INFO] | +- com.google.firebase:firebase-components:aar:16.0.0:compile [INFO] | +- com.google.firebase:firebase-datatransport:aar:17.0.3:compile [INFO] | +- com.google.firebase:firebase-encoders-json:aar:16.0.0:compile [INFO] | +- com.google.firebase:firebase-iid:aar:20.1.7:compile (version selected from constraint [20.1.7,20.1.7]) [INFO] | | \- com.google.firebase:firebase-iid-interop:aar:17.0.0:compile [INFO] | +- com.google.firebase:firebase-installations:aar:16.3.0:compile [INFO] | +- com.google.firebase:firebase-installations-interop:aar:16.0.0:compile [INFO] | \- com.google.firebase:firebase-measurement-connector:aar:18.0.0:compile [INFO] +- com.squareup.okhttp3:okhttp-urlconnection:jar:3.10.0:compile [INFO] | \- com.squareup.okhttp3:okhttp:jar:3.10.0:compile [INFO] | \- com.squareup.okio:okio:jar:1.14.0:compile [INFO] +- me.leolin:ShortcutBadger:aar:1.1.22:compile [INFO] \- com.android.support:appcompat-v7:aar:23.4.0:compile [INFO] +- com.android.support:animated-vector-drawable:aar:23.4.0:compile [INFO] +- com.android.support:support-v4:aar:23.4.0:compile [INFO] | \- com.android.support:support-annotations:jar:23.4.0:compile [INFO] \- com.android.support:support-vector-drawable:aar:23.4.0:compile [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ }}} == Copy dependencies == {{{#!highlight sh mvn dependency:copy-dependencies --log-file out1copydep.txt # check folder target/dependencies split --verbose -b4096K deps2.zip deps2.zip. cat deps2.zip.?? > zip2.new unzip -t zip2.new }}} == Standalone app - FAT Jar - Java 1.7 == {{{#!highlight sh mvn clean install }}} === pom.xml === {{{#!highlight xml 4.0.0 com.example artifactX jar 0.0.1 artifactX http://maven.apache.org maven-assembly-plugin 2.4 jar-with-dependencies hello.Main make-assembly package single org.slf4j slf4j-api 1.7.7 org.slf4j slf4j-simple 1.7.7 1.7 1.7 }}} === src/main/java/hello/Main.java === {{{#!highlight java package hello; import java.util.Date; import java.text.SimpleDateFormat; class Main { public static void main(String args[]) { Date d = new Date(); SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy HH:MM"); System.out.println("Hello, world! " + sdf.format(d) ); } } }}} == Standalone app/service - FAT Jar - Java 17 == {{{#!highlight sh cd ~ mkdir fat-jar-jdk17 cd fat-jar-jdk17/ mkdir -p src/main/java/hello touch src/main/java/hello/Main.java nano pom.xml nano src/main/java/hello/Main.java mvn clean install jar tf target/artifact-jdk17-0.0.1-jar-with-dependencies.jar ls -lah target/artifact-jdk17-0.0.1-jar-with-dependencies.jar # -rw-r--r-- 1 vagrant vagrant 76K May 26 18:00 target/artifact-jdk17-0.0.1-jar-with-dependencies.jar java -jar target/artifact-jdk17-0.0.1-jar-with-dependencies.jar # Hello, world! 26-05-2023 17:05 }}} === pom.xml === {{{#!highlight xml 4.0.0 com.example artifact-jdk17 jar 0.0.1 artifact-jdk17 http://maven.apache.org maven-assembly-plugin 3.6.0 jar-with-dependencies hello.Main make-assembly package single org.slf4j slf4j-api 2.0.7 org.slf4j slf4j-simple 2.0.7 17 17 }}} === src/main/java/hello/Main.java === {{{#!highlight java package hello; import java.util.Date; import java.text.SimpleDateFormat; class Main { public static void main(String args[]) { SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy HH:mm"); for (;;) { try { Date d = new Date(); System.out.println("Hello, world! " + sdf.format(d)); Thread.sleep(60000); } catch (Exception ex) { ex.printStackTrace(); } } } } }}} === /etc/init.d/artifact-jdk17 === {{{#!highlight sh #!/bin/sh # chkconfig: 345 99 99 # description: Starts and stops the artifact-jdk17 process with user vagrant # /etc/init.d/artifact-jdk17 USER=vagrant PROG=artifact-jdk17 PIDFILE="/tmp/artifact-jdk17.pid" PATH="/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin:/usr/local/sbin" LOG="/tmp/artifact-jdk17.log" JAVA="/usr/bin/java" JARFILE="/home/vagrant/fat-jar-jdk17/target/artifact-jdk17-0.0.1-jar-with-dependencies.jar" start(){ echo "Start called $PROG with user $USER" su - $USER -c "$JAVA -jar $JARFILE >> $LOG" & /bin/sleep 2 PID=`ps uax| grep java | grep $PROG | grep $USER | awk '{print $2}'` echo "Program $PROG running with PID: $PID" echo "$PID" > $PIDFILE } status(){ PID=`cat $PIDFILE` echo "Running $PROG with PID: $PID" } stop(){ echo "Stop called for $PROG" PID=`cat $PIDFILE` echo "PID to kill $PROG $PID" kill -9 $PID rm $PIDFILE } # switch case "$1" in start) start ;; status) status ;; stop) stop ;; restart) stop start ;; *) echo "$PROG start|status|stop|restart" exit 1 ;; esac }}} === Steps to configure artifact-jdk17 service in Debian bullseye (11) === {{{#!highlight sh sudo bash chmod 755 /etc/init.d/artifact-jdk17 # register service update-rc.d artifact-jdk17 defaults update-rc.d artifact-jdk17 defaults 20 80 update-rc.d artifact-jdk17 start 20 2 3 4 . start 30 5 . stop 80 0 1 6 . # check if service will run on startup , + sign service --status-all # start service manually and check its status service artifact-jdk17 start service artifact-jdk17 status # check if service is running with the PID mentioned in status ps uax tail -f /tmp/artifact-jdk17.log # remove service from startup initialization update-rc.d -f artifact-jdk17 remove }}} == Attach debugger to mvn test == Listens on port 5005. IntelliJ * run * attach debugger to process listening in 5005 {{{#!highlight sh mvn test -Dmaven.surefire.debug=true # run specific test in test class mvn test -Dmaven.surefire.debug=true -Dtest=”TestClass#testMethod” }}}