简体   繁体   中英

maven settings.xml configuration for looking up workspace artifacts

I'm using maven and I'm currently stumped with the following issue:

Project setup:

- master (parent project)
- module1 (parent is master)
- module2 (parent is master and needs module1 as "provided")

As shown in the following settings.xml, I'm making the artifactory as a mirror for all artifact requests. This is in a way needed because there are few proprietary jars that my build needs (and artifactory is responsible it).

settings.xml:

    <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 http://maven.apache.org/xsd/settings-1.0.0.xsd">
  <localRepository>${user.home}/.m2/repository</localRepository>
  <interactiveMode>true</interactiveMode>
  <usePluginRegistry>false</usePluginRegistry>
  <offline>false</offline>
  <mirrors>
    <mirror>
      <id>artifactory-virtual-repo</id>
      <name>myartifactory</name>
      <url>http://<artifactory-ip>:8081/artifactory/simple/<repo-name>/</url>
      <mirrorOf>*</mirrorOf>
    </mirror>
  </mirrors>
  <proxies/>
  <profiles/> 
  <activeProfiles/>
</settings>

module1 builds fine. However, when I try to build master or module2 it is checking for module1 in the artifactory (mentioned above in settings.xml) where these projects are still missing. How can I force eclipse (m2e) to look at workspace projects as well?

In otherwords, how do I configure maven to make sure that artifacts in the current workspace are also looked up if it fails to find it in the repository ?

Maven considers dependencies "inner" (and looks for classes in the project instead of going after jars) once they are declared as modules in the reactor. If your parent pom has the following modules declaration, Maven shouldn't reach out to Artifactory, but should use the compiled classes:

<modules>
    <module>module1</module>
    <module>module2</module>
</modules>

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