Maven + Artifactory + Eclipse Setup

Jul 29, 2019 3 min read
Maven + Artifactory + Eclipse Setup

Motivation:

We work on a company and we need to follow thier rules. A new Artifactory instance has been set up by the BARS and Platform teams to improve build performance on the  Jenkins instance. Follow these steps to get your developer workstation configured to work with it.

This setup is for Windows only

Get your settings.xml working

  1. Login to Artifactory (url provided by your organization), and click on 'Artifacts' on the left vertical toolbar, then click 'Set Me Up' on the right top corner. After that select Maven and type your employee password, then click the arrow to unlock and finally click 'Generate Maven Settings'. Download the file 'settings.xml' and inside copy the encrypted password which you'll need below. (Here is a more detailed step by step)
  2. Locate your .m2 folder, it's usually in your user directory. Once there, paste the "settings.xml" you downloaded and write your username and password on the corresponding fields.

Maven paths

  1. Now we need to include the maven paths of our installations. Type:
mvn -version #If you get something like this: Apache Maven 3.5.3 (3383c37e1f9e9b3bc3df5050c29c8aff9f295297; 2018-02-24T14:49:05-05:00) Maven home: C:\ProgramData\Development\apache-maven-3.5.3\bin\.. Java version: 1.8.0_212, vendor: Oracle Corporation Java home: C:\Program Files\Java\jdk1.8.0_212\jre Default locale: en_US, platform encoding: Cp1252 OS name: "windows 10", version: "10.0", arch: "amd64", family: "windows"

Then it means you can jump to the Eclipse setup already. If not, continue below:

Go to the Windows OS start menu and search for 'Edit enviroment variables for your account', then make sure you have something like this (the path may be different so make sure you edit it)

userEnv


For the System variables you are going to need admin priviledges depending on your access, if so you can contact the support team using the Chat and tell them you need to edit those files. Once you have access, make sure you have something similar to this:

System-var


and for the path:

System-env-path

After that close the terminal and run again the command 'mvn -version' to make sure you get an output similar to the one mentioned above.

Eclipse

  1. Make sure your User Settings are setup.
    Go to Window -> Preferences -> Maven -> User Settings and where it says User settings, click on Browse... to locate your settings.xml file in the .m2 folder, after that click on Update Settings and Apply and Close.
    Do not change any other setting such as work offline because that will create build problems.
  2. Add your runtime enviroment (or check it):
    Go to Window > Preferences > Java > Installed JREs and check your installed JREs. You should have an entry with a JDK there.
  3. Git Configurations:
    Open Eclipse.
    Go to Window -> Preferences -> Team -> Git -> Configuration
    Add entries:
    Key: core.autocrlf; Value: false
    Key: http.sslVerify; Value: false

SampleGitConfig
  1. Setup Eclipse Network Configurations:
    Open Eclipse.  Go to Window -> Preferences -> General -> Network Connections
    Go to Active Provider: Native
    Check only the row that has Schema: HTTP; Host: Dynamic Example:
SampleNetworkConfig

Troubleshooting

For this error refer to settings.xml above

Could not calculate build plan: Plugin org.apache.maven.plugins:maven-resources-plugin:2.6 or one of its dependencies could not be resolved: Cannot access central

For this error refer to Maven paths above

The JAVA_HOME environment variable is not defined correctly This environment variable is needed to run this program NB: JAVA_HOME should point to a JDK not a JRE How to add Maven to the Path variable?

Great! Next, complete checkout for full access to ArturoFM.
Welcome back! You've successfully signed in.
You've successfully subscribed to ArturoFM.
Success! Your account is fully activated, you now have access to all content.
Success! Your billing info has been updated.
Your billing was not updated.