Differences

This shows you the differences between two versions of the page.

Link to this comparison view

maven [29/11/2013 23:12]
p171024 created
maven [01/02/2019 16:01] (current)
Anthony Arents [Setting up a developer machine :]
Line 1: Line 1:
 ====== Maven ====== ====== Maven ======
  
 +===== Why use Maven ? =====
 +
 +Maven is one of several possible build tools, it's easy to use and supported in Netbeans + Eclipse.
 +Maven is preinstalled on mac (3.0.3), maven is also bundled with Netbeans (3.0.5). I prefer downloading latest from http://maven.apache.org
 +
 +===== Advantages of using Maven are numerous : =====
 +
 +  * jars are referenced with an xml config file, they are no longer stored in SVN
 +  * once you get the hang of developing with Maven, you'll notice you need to spend less time getting your dependencies together.
 +  * it's easier to test if your project can work with an updated version of one of the dependencies.
 +  * when a company repository is used: the jars and wars you build will be saved there.
 +  * when a company repository is used: only your current project has to be opened.  (improves IDE startup time)
 +  * you can divide the project in multiple smaller projects, which improves code reusability 
 +  * a buildprogress which is easy to adjust.
 +  * projects can combine multiple projects into a single war
 +  * it's easier to see what jars we depend on.
 +  * There's plugins for a number of things: ftp deployment, creating a test site, ...
 +  * possible future?: archetypes could be used to create new projects from templates : 
 +'mvn archetype:generate eza-inno-sach' would use the template to create a new project, in netbeans this is also simplified (just need to use the search form to find the archetype).
 +
 +===== What does it take to convert an existing project to Maven ? =====
 +
 +  - You create a new maven project (jar or war) & copy the source
 +  - You configure the POM (set parent to company POM parent, usually MentoringSystems. There is no parent JCP project... yet)
 +  - You start resolving dependencies
 +
 +==== Resolving dependencies : ====
 +
 +  * version number : Most of the existing jars have a version number, if they're not named with a version number you should take a look inside the JAR, META-INF/manifest.mf sometimes contains the version number.
 +  * use the repository search to find the xml config statement for your dependency, you should be able to use the one in nexus.
 +  * If you are sure a dependency is missing, try finding it with google (for example: 'maven antlr' or 'maven antlr 2.7.6'. 
 +  * If you have a dependency which won't resolve (can't be found in repository) you should contact repository admin.
 +
 +===== Creating a new BUILD project (1 build per customer/product) : =====
 +
 +  - Netbeans : New project 
 +
 +First screen : 
 +Maven -> Web Application
 +
 +Next : 
 +  * projectname: follow naming convention : JCPIS_ANALYSE_BUILD_<customer in caps> other projects are named JCPIS_ANALYSE_MODUL_ (for additions), JCPIS_ANALYSE_UI_ (for javascript clients like JCPIS_ANALYSE_UI_ANALYSE / UI_SACH)
 +  * groupname : de.jcpis.analyse
 +  * package : leave blank
 +
 +Next :
 +  * Server Tomcat
 +
 +  * When the project is made, you need to configure the POM first :
 +I recommend copying the POM of JCPIS_ANALYSE_BUILD_EFFEKT & changing 2 properties :
 +artifactId: build-<customer in normal letters>
 +name: JCPIS_ANALYSE_BUILD_<customer in caps>
 +
 +
 +  - fiddle with the options in pom to generate a different build.
 +  - time to change the context.xml file (located under Web Pages/META-INF/context.xml)\\ easiest way : copy the file from JCPIS_ANALYSE_BUILD_EFFEKT, adjust it so the path & webapp rootkey are unique
 +  - Remove the web.xml file from the build !
 +
 +
 +===== Company repository : =====
 +
 +
 +Think of it as the SVN for all our binary project dependencies.
 +  * It stores all the jars we've used, It provides a proxy so it can cache any future jars.
 +  * It allows us to combine several repositories in 1 url (needed for netbeans)
 +  * It stores our projects
 +  * It allows us to add 3rd party or non maven projects to the repository.
 +  * It can restrict the version on certain dependencies *haven't looked that far into it yet*
 +  * It reduces download time for dependencies
 +
 +===== Setting up a developer machine : =====
 +
 +  - settings.xml
 +<code xml><?xml version="1.0" encoding="iso-8859-1"?>
 +<settings 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/xsd/settings-1.0.0.xsd">
 + <mirrors>
 + <mirror>
 + <id>nexus</id>
 + <mirrorOf>*</mirrorOf>
 + <url>http://svn.jcpis.de:8081/nexus/content/groups/public</url>
 + </mirror>
 + </mirrors>
 + <proxies/>
 + <servers>
 + <server>
 + <id>nexus</id>
 + <username>***</username>
 + <password>***</password>
 + </server>
 + </servers>
 + <pluginGroups/>
 + <profiles>
 + <profile>
 + <id>nexus</id>
 + <!--Enable snapshots for the built in central repo to direct -->
 + <!--all requests to nexus via the mirror -->
 + <repositories>
 + <repository>
 + <id>central</id>
 + <url>http://central</url>
 + <releases>
 + <updatePolicy>always</updatePolicy>
 + <enabled>true</enabled>
 + </releases>
 + <snapshots>
 + <updatePolicy>always</updatePolicy>
 + <enabled>true</enabled>
 + </snapshots>
 + </repository>
 + </repositories>
 + <pluginRepositories>
 + <pluginRepository>
 + <id>central</id>
 + <url>http://central</url>
 + <releases>
 + <updatePolicy>always</updatePolicy>
 + <enabled>true</enabled>
 + </releases>
 + <snapshots>
 + <updatePolicy>always</updatePolicy>
 + <enabled>true</enabled>
 + </snapshots>
 + </pluginRepository>
 + </pluginRepositories>
 + </profile>
 + </profiles>
 + <activeProfiles>
 + <activeProfile>nexus</activeProfile>
 + </activeProfiles>
 +</settings>
 +</code>
 +possible locations :
 +
 +bundled maven (mac) : \\ 
 +''/Applications/NetBeans/NetBeans 8.2.app/Contents/Resources/NetBeans/java/maven/conf/settings.xml''
 +
 +preinstalled maven (mac) : \\ 
 +''/usr/share/maven/conf/settings.xml''
 +
 +installed maven (mac, probably the same for linux) : \\ 
 +''/<wherever you've placed it>/maven/conf/settings.xml''
 +
 +installed maven (windows) : \\ 
 +''<userdir>/.m2/settings.xml''
 +
 +  - Check out MentoringSystems parent pom & build this one first, it contains some settings needed to recover all company projects !
 +  - Check out the project you need to work on
 +(for example, work on model)
 +===== Important : updating an existing maven project : =====
 +
 +Some of the old projects (like jav2013 etc...) were marked as FINAL versions (version nr does not end with snapshot). 
 +Before editting these projects, you need to change the versionnumber :
 +
 +<code xml><version>1.0</version></code> becomes <code xml><version>1.1-SNAPSHOT</version></code>
 +
 +And change the reference in projects where jav2013 is used, This ensures the projects will use your latest version.
 +
 +depending on the version, a different repository is used. You can't change final versions (repository won't allow it).
 +Think of this as an extra precaution upon production release, you can ALWAYS return to a previous version or you can fix a project 
 +to use a previous version whilst development works with a newer version.
 +
 +===== JCPIS_ANALYSE overrides =====
 +
 +Build projects are essentially overrides, you can override ANY of the other projects by simply copying the file over to the build project, (correct folder structure required) & editting it.
 +
 +===== JCPIS_ANALYSE plugins =====
 +
 +Several plugin projects exist, making use of detached spring configuration.
 +Examples are JCPIS_ANALYSE_CODIE, JCPIS_ANALYSE_SOFTFAIR.
 +
 +When adding controllers it would be best to check other projects for the ORDER parameter on SimpleUrlHandlerMapping.
 +In the future it might be better to add naming conventions or start with using spring 3.1 annotations to reduce the xml code.
 +
 +==== JCPIS_ANALYSE login plugin ====
 +
 +Interface :
 +de.jcpis.analyse.security.AuthenticationFilter
 +
 +Working implementation : Codie loginfilter.