Maven support - tooltwist/documentation GitHub Wiki
In Eclipse, go to the Eclipse MarketPlace and install the m2e-wtp feature.
mvn -Declipse.workspace=<eclipse workspace directory> eclipse:add-maven-repo
IMPORTANT: Make sure all your changes are committed to git, or else they may be lost.
-
Right click on the project and select New -> Source Folder. Enter src/main/java as the Folder Name, and check Update Exclusion Filters in other source folders to solve nesting. Click OK.
-
On the command line, go to your project and move your source to the new directory. You'll need to do this one file/directory at a time, because moving src/* will try to move the main directory into itself.
$ git mv src/ttStd src/main/java $ git mv src/META-INF/ src/main/java
-
Git should recognise the source files as renamed, rather than deleted and created. Check the git status to check.
$ git status # On branch 8.1-dev # Changes to be committed: # (use "git reset HEAD <file>..." to unstage) # # renamed: src/META-INF/MANIFEST.MF -> src/main/META-INF/MANIFEST.MF # renamed: src/ttStd/basic/PublicSecurityPluggin.java -> src/main/ttStd/basic/PublicSecurityPluggin.java # renamed: src/ttStd/basic/UserSecurityPluggin.java -> src/main/ttStd/basic/UserSecurityPluggin.java # renamed: src/ttStd/company_maint/CompanyMaintUIM.java -> src/main/ttStd/company_maint/CompanyMaintUIM.java # renamed: src/ttStd/contact_maintenance/ContactMaintenanceUIM.java -> src/main/ttStd/contact_maintenance/ContactMaintenanceUIM.java ...
-
If this looks right, commit it now.
$ git add src $ git commit -m "Moved source to Maven's standard directory structure" [phil-1pmThursday ef0e7ad] Moved source to Maven's standard directory structure 103 files changed, 0 insertions(+), 0 deletions(-) rename src/{ => main}/META-INF/MANIFEST.MF (100%) rename src/{ => main}/META-INF/web-fragment.xml (100%) rename src/{ => main}/tooltwist/guroopro/detectSectors/LapsAndSectors.java (100%) ...
-
Back in Eclipse, right click on the project and select Properties -> Java Build Path -> Source. Click on <project name>/src and press Remove. Press OK when you're finished.
-
Right click on the project again and select New -> Source Folder. Enter src/main/java for the Folder Name and press Finish.
-
Right click on the project again and select New -> Source Folder. Enter src/test/java for the Folder Name and press Finish.
- Right click on project -> Configure -> Convert to Maven Project. If the "Create new POM" dialog is displayed, enter the customer's URL (e.g. com.tooltwist) for the group ID. Version will be based upon your project (e.g. 0.0.1-SNAPSHOT).
-
In the project properties, go to Java Build Path -> Projects. Take note of the referenced projects, and then remove any that are already available via Maven. This includes tooltwist, ttStd, ttWbd, XData, and any projects you've already converted. Press OK when you've finished.
-
Remove any jar files in WebContent/WEB-INF/lib.
-
Open pom.xml, and select the dependencies tab. Add each of the project dependencies you deleted to this screen. The Select Dependency dialog is easy to use if you use the auto-complete feature - press Control-Space to get a list of allowable values. For tooltwist, ttStd and ttWbd, the Group Id is com.tooltwist.
-
From the top menu, select Project -> Clean..., select your project and press OK. Your project should now build cleanly.
-
Back in the project's Properties -> Java Build Path -> Libraries tab, remove 3rdPartyJars. This will probably cause errors, and show undefined classes on the Eclipse Problems tab.
-
Open pom.xml for your project an go to the Dependencies tab. For each undefined class, we'll need to add a Maven controlled jar to this list.
-
Choose an undefined class from the Problems tab, press Command-Shift-T and enter the class name. This should show which jar file in 3rdPartyJars contains the class. Take note of the jar file's name, and the version if shown. If the class exists in multiple jar files, go to the source file where the class is undefined and look at the import statement, highlight the full package/class name, and press Command-Shift-T.
-
On the dependencies tab press Add... and in the Enter groupid, artifactid or sha1 prefix or pattern field enter the name of the jar file. Search through the list for the jar file name. Expand the list below the jar file, select the correct version and press OK. Depending upon your project, you may wish to switch to a later version of jar files, be take note of any you change, and be sure to retest you application.
-
Press Command-S to save pom.xml and the project will rebuild and update the Problems tab.
-
Repeat these steps until all the missing classes are resolved.
Note that the dependencies of those jar files, and other projects are all calculated and displayed in the Dependency Hierarchy tab. If there are any version conflicts this tab will help.
Recent versions of Log4j reference dependencies not available in Maven Central. The solution is to insert the code below into your pom.xml. http://unitstep.net/blog/2009/05/18/resolving-log4j-1215-dependency-problems-in-maven-using-exclusions/
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.15</version>
<scope>provided</scope>
<exclusions>
<exclusion>
<groupId>javax.mail</groupId>
<artifactId>mail</artifactId>
</exclusion>
<exclusion>
<groupId>javax.jms</groupId>
<artifactId>jms</artifactId>
</exclusion>
<exclusion>
<groupId>com.sun.jdmk</groupId>
<artifactId>jmxtools</artifactId>
</exclusion>
<exclusion>
<groupId>com.sun.jmx</groupId>
<artifactId>jmxri</artifactId>
</exclusion>
</exclusions>
</dependency>
Oracle's licensing prevents the jar files from being included in public repositories. See http://stackoverflow.com/questions/1074869/find-oracle-jdbc-driver-in-maven-repository
--