= 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. == Slackbuild == * su * cd /tmp * wget http://slackbuilds.org/slackbuilds/14.0/development/apache-maven.tar.gz * tar xvzf apache-maven.tar.gz * cd apache-maven * wget http://archive.apache.org/dist/maven/binaries/apache-maven-3.0.4-bin.tar.gz * ./apache-maven.SlackBuild * installpkg /tmp/apache-maven-3.0.4-noarch-1_SBo.tgz Package: [[attachment:apache-maven-3.0.4-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 === * cd ~ * mvn archetype:generate -DgroupId=org.allowed.bitarus -DartifactId=WebApp -DarchetypeArtifactId=maven-archetype-webapp -DinteractiveMode=false * cd WebApp * mvn clean * mvn compile * mvn package === Deploy web application on jboss AS 7.1.1 === * /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 }}} === Create source code for REST service and servlet === File 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(); } } }}} File src/main/java/org/allowed/bitarus/Servletx.java http://localhost:8080/WebApp/servletxxx {{{#!highlight java package org.allowed.bitarus; import javax.servlet.*; import javax.servlet.http.*; import java.io.*; public class Servletx extends HttpServlet{ public void service(HttpServletRequest req, HttpServletResponse res) throws IOException { res.setContentType("text/html"); PrintWriter out = res.getWriter(); out.println("Hello World!"); out.println("

Hello World!

"); } } }}} === Configure web app === File 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 }}}