Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/maven/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在Maven 3.5.2中,如何在pom.xml文件中使用settings.xml文件中定义的概要文件?_Maven_Maven 3_Maven Plugin - Fatal编程技术网

在Maven 3.5.2中,如何在pom.xml文件中使用settings.xml文件中定义的概要文件?

在Maven 3.5.2中,如何在pom.xml文件中使用settings.xml文件中定义的概要文件?,maven,maven-3,maven-plugin,Maven,Maven 3,Maven Plugin,假设我在~/.m2/settings.xml文件中定义了以下配置文件 <profiles> <profile> <id>artifactory</id> </repositories> <repository> <snapshots> <enabled>false</enabled>

假设我在~/.m2/settings.xml文件中定义了以下配置文件

 <profiles>
   <profile>
     <id>artifactory</id>
     </repositories> 
        <repository>
          <snapshots>
            <enabled>false</enabled>
          </snapshots>
          <id>thirdparty</id>
          <name>scscm-thirdparty</name>
          <url>http://www.mycompany.com/artifactory/my-thirdparty-repo</url>
        </repository>
      </repositories>
    </profile>
  </profiles>

人工制品
假的
第三方
第三方
http://www.mycompany.com/artifactory/my-thirdparty-repo
现在我想从settings.xml中定义的第三方存储库id下载一个自制的apr-1.6.2.tar.gz arfifact,因此在pom.xml文件中

<artifactId>apr</artifactId>
<groupId>com.company</groupId>
<version>1.6.2</version>
<packaging>pom</packaging>

<dependencies>
  <dependency>
    <groupId>org.apache</groupId>
    <artifactId>apr</artifactId>
    <version>1.6.2</version>
    <type>tar.gz</type>
  </dependency>
</dependencies>

<build>
  <plugins>
    <plugin>
    <groupId>com.googlecode.maven-download-plugin</groupId>
    <artifactId>download-maven-plugin</artifactId>
    <version>1.4.0</version>
    <executions>
      <execution>
        <id>apr</id>
        <phase>pre-integration-test</phase>
          <goals>
            <goal>wget</goal>
          </goals>
          <configuration>
            # HOW DO I SPECIFY URL FROM PROFILE HERE????
           <unpack>false</unpack>
         </configuration>
      </execution>
    </executions>
    </plugin>
  </plujgins>
</build>
apr
com公司
1.6.2
聚甲醛
org.apache
四月
1.6.2
tar.gz
com.googlecode.maven-download-plugin
下载maven插件
1.4.0
四月
预集成测试
wget
#如何从这里的配置文件中指定URL????
假的

我在网上看到了配置文件的示例,但它们都是在pom.xml本身中定义的,但这不是我想要做的。我只想在pom.xml文件中使用settings.xml配置文件中定义的URL

通过命令行(
-p
)或您喜欢的触发器激活它们。但是问问你自己,这是否是找到你个人资料的正确地点。有关更多信息,请参阅文档:

一,


  • 您可以通过多种方式实现这一点

  • 在Settings.xml中设置活动配置文件

    <profiles>
     <profile>
       <id>artifactory</id>
       </repositories> 
          <repository>
            <snapshots>
              <enabled>false</enabled>
            </snapshots>
            <id>thirdparty</id>
            <name>scscm-thirdparty</name>
            <url>http://www.mycompany.com/artifactory/my-thirdparty-repo</url>
          </repository>
        </repositories>
      </profile>
    </profiles>
    
    <activeProfiles>
      <activeProfile>artifactory</activeProfile>
    </activeProfiles>
    
    <profiles>
     <profile>
       <id>artifactory</id>
       </repositories> 
          <repository>
            <snapshots>
              <enabled>false</enabled>
            </snapshots>
            <id>thirdparty</id>
            <name>scscm-thirdparty</name>
            <url>http://www.mycompany.com/artifactory/my-thirdparty-repo</url>
          </repository>
        </repositories>
        <activation>
          <activeByDefault>true</activeByDefault>
        </activation>
      </profile>
    </profiles>
    
    
    人工制品
    假的
    第三方
    第三方
    http://www.mycompany.com/artifactory/my-thirdparty-repo
    

    页提供的链接都没有回答我提出的具体问题。比如,我在哪里问过Eclipse?嗯,我想你的问题是关于在构建中激活配置文件,这就是为什么…在settings.xml中定义一个属性并使用它。但我认为这不是一个好主意…此外,我想问你为什么要单独下载一个文件…你是对的,我不想要一个属性,而是一个配置文件。我正在下载这个文件,这样我就可以编译、构建并打包成一个RPM。如果您使用的是apr,它本身应该通过RPM依赖项提供吗?不是吗?除此之外,我不确定在这种情况下使用Maven是否真的是个好主意……apr只是一个例子。它可以是任何文件。