Home > front end >  "Set me up" interface for Maven repo not permitting me to generate settings.xml without id
"Set me up" interface for Maven repo not permitting me to generate settings.xml without id

Time:03-24

Using the below image as a reference, I have a few challenges at the moment.

I'm trying to generate the settings.xml template for maven, so I can download my maven dependencies from artifactory. That's all I'm trying to do. I'm not trying to establish a deployment repo, or anything else. I'm only trying to establish my dependency proxy for maven plugins.

My maven repo which will download/cache from maven central is called "joeytest-maven-central-remote".

When I click "Set me up", here is what happens:

  1. I'm prompted to choose a repository. Naturally I'd simply choose the remote repo I just setup. That's where I want to download my dependencies from. Problem is, I can't. It's not an option. I had to create another repo called "joeytest-maven-dev-local" which presumably would be something I'd deploy my maven artifacts to, just to have something to select in this drop down. Why can't I just choose the remote repo I created? That's problem #1.

  2. Moving furrther down in the configure tab, I'm now forced to identify four (4) virtual repos for releases/snapshots/plug-releases/plugin-snapshots. Why? What does this have to do with me just wanting to download dependencies from this one remote repo? I understand the purpose of virtual repos, but in no way do I want/need to use them at the moment. Are they not supposed to be a convenience/logistical feature, rather than a required component? That's problem #2.

Are these problems simpy a poorly designed "set me up" GUI, and I'm not required to enter any of this information. I can simply get the template, remove all of the unnecessary stuff, and download dependencies directly from my initially created remote repo?

Or am I completely missing some pre-requisites and if so, can someone shed some light on why these components are required in order to download the settingsl.xml template file?

enter image description here

Thanks in advance,

CodePudding user response:

I'm going to answer this myself now that I have solved it. Hopefully this helps others.

I got hung up quite heavily on this and want to provide my findings. Within artifactory, there is a “set me up” button in the upper right corner of the repository selection screen. This button is mentioned in several online resources as a starting point when setting up artifactory to download your maven dependencies. What the online articles fail to mention however, is that this button is used to generate a template which permits much more than just downloading dependencies. It also sets you up for deployment, and the use of virtual artifactory repos. As a result, in order to use this feature you must already have a deployment repo, and at least one virtual repo, setup in artifactory. This creates a false assumption that these items are required to use artifactory as a proxy for downloading dependencies. This is false. See below.

You can skip this “set me up” button altogether and directly setup your settings.xml on the maven side instead. This method is cleaner and simpler as a beginner. If you need a starting point for the maven settings.xml, templates exist freely that you can use to start. Here is a working example template for reference to get you started.

<?xml version="1.0" encoding="UTF-8"?>
<settings xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.2.0 http://maven.apache.org/xsd/settings-1.2.0.xsd" xmlns="http://maven.apache.org/SETTINGS/1.2.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    
  <servers>
    <server>
      <id>myRepository</id>
      <username>JohnDoe</username>
      <password>****</password>
    </server>  
    <server>
      <id>myPluginRepository</id>
      <username>JohnDoe</username>
      <password>****</password>
    </server>
  </servers>
  
  <profiles>
    <profile>
      <id>artifactory_default_profile</id>
      <activation>
        <activeByDefault>true</activeByDefault>
      </activation>
      
      <repositories>
        <repository>
          <id>central</id>
          <url>https://repo1.maven.org/maven2/</url>
          <releases>
            <enabled>false</enabled>
          </releases>
          <snapshots>
            <enabled>false</enabled>
          </snapshots>
        </repository>
        <repository>
          <id>myRepository</id>
          <name>joeytest-maven-libs-virtual</name>
          <url>https://artifactory.dev.{myorg}.com:443/artifactory/joeytest-maven-libs-virtual/</url>
          <releases>
            <enabled>true</enabled>
          </releases>
          <snapshots>
            <enabled>true</enabled>
          </snapshots>        
        </repository>
      </repositories>
      
      <pluginRepositories>
        <pluginRepository>
          <id>central</id>
          <url>https://repo1.maven.org/maven2/</url>
          <releases>
            <enabled>false</enabled>
          </releases>
          <snapshots>
            <enabled>false</enabled>
          </snapshots>
        </pluginRepository>
        <pluginRepository>
          <id>myPluginRepository</id>
          <name>joeytest-maven-libs-virtual</name>
          <url>https://artifactory.dev.{myorg}.com:443/artifactory/joeytest-maven-libs-virtual/</url>
          <releases>
            <enabled>true</enabled>
          </releases>
          <snapshots>
            <enabled>true</enabled>
          </snapshots>        
        </pluginRepository>
      </pluginRepositories>
      
    </profile>
  </profiles>
  
  <activeProfiles>
    <activeProfile>artifactory_default_profile</activeProfile>
  </activeProfiles>
  
</settings>

This template does 2 things:

  • Disables the default maven central download location so it will not be used.
  • Instructs Maven to use artifactory to download everything for the maven builds.

All you require in order to use artifactory as a proxy for downloading dependencies is at least one remote repo created in artifactory, which has a valid URL to source artifacts from externally. Beyond that if you wish, you may create deployment repositories for your builds, and/or create virtual repositories to aggregate other artifactory repositories, but these steps are completely optional.

  • Related