简体   繁体   中英

externalize global maven settings.xml to a database?

My maven settings xml file basically declares a bunch of repo locations to search for artifacts. I want to centralize this so that i know that all developers, build slaves, etc. Are using the same build profile when building artifacts for the project. Is there a plugin to do this and if not, what is the best way to setup a plugin to do this? Something like below? What is the phase/goal when settings is loaded? Assuming i can inject additional information using http://maven.apache.org/plugin-tools/maven-plugin-tools-annotations/ can someone suggest a good approach to solving this?

<executions>
   <execution>
           <id>bootstrap</id>
           <phase>initialize</phase>
           <goals>
                   <goal></goal>
           </goals>
   </execution>
</executions>

I would keep it simple. If you have a well set up nexus/artifactory, then all you will need in your settings.xml is something like :

<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
                          https://maven.apache.org/xsd/settings-1.0.0.xsd">

   <mirrors>
     <mirror>
          <id>internalmirror</id>
          <mirrorOf>*</mirrorOf>
          <url>https://path to virtual repo combing other repos/</url>
      </mirror>
  </mirrors>

</settings>

This is not an answer:

The first problem I see in your question is that you are mixing things. The settings.xml should contain only a default configuration to access a repository manager and not many repositories. This is smell at first. Secondly if you need to define some kind of profiles there is another smell. You should use at least no profile. Furthermore in the settings.xml there can be username/passwords (encrypted best) etc. on a user base which should be located in users home. On Jenkins you can use the config file provider to solve that in a general good way.

Apart from that what is the relationship to Plugins ? Why loading the settings.xml in plugin? For what purpose? Unfortunately you are very general but do not explain your real problem ? And what kind of you are trying to solve?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM