Maven的警告“重写简介:‘空’......”

问题描述:

什么是以下Maven警告的可能原因:Maven的警告“重写简介:‘空’......”

Overriding profile: 'null' (source: pom) with new instance from source: pom 

我试着注释掉我的整个默认配置文件作为提示中提到“个人资料” ,但这没有帮助。我也试着评论我的报告选项,但警告仍显示出来。

我已经用-X标志跑过maven,并且在我的hamcrest依赖被引入之后立即显示警告,但是将其注释掉并不能消除警告。

编辑:

输出mvn help:active-profiles

Active Profiles for Project 'com.sophware.XXX:main:jar:0.0.1-SNAPSHOT': 

The following profiles are active: 

- default (source: pom) 

输出mvn help:all-profiles

[INFO] Listing Profiles for Project: com.sophware.XXX:main:jar:0.0.1-SNAPSHOT 
    Profile Id: default (Active: true , Source: pom) 

default确实是我使用的配置文件的ID每个请求其他信息在我的朋友。在这一点上,我只有一个配置文件,但我希望在未来增加更多。

分辨率:

彼得是对的问题。问题源于maven配置文件中没有id元素。在我的情况下,由于我的miglayout依赖性,一个pom文件被拉进来。

在通过相关的POM的寻找,我发现miglayout,的确,不使用id“在其分布曲线Si:

<profile> 
     <activation> 
      <os> 
       <family>windows</family> 
       <arch>x86</arch> 
      </os> 
     </activation> 
     <dependencies> 
      <dependency> 
       <groupId>org.eclipse.swt.win32.win32</groupId> 
       <artifactId>x86</artifactId> 
       <version>3.3.0-v3346</version> 
       <optional>true</optional> 
      </dependency> 
     </dependencies> 
    </profile> 

有一些其他的配置文件丢失id的和好,每个都会导致警告出现。

这很容易在Maven 2.2.9中重现。这样做的唯一原因是两个maven配置文件在同一个pom.xml中没有配置文件id元素,因此id被处理为null。我不知道这个配置文件的用例是什么,但Maven 2.2.9默默地允许这样的配置文件存在,除非您尝试覆盖它 - 当然,您会收到提及的警告。

这是一个简单的pom,它将重现错误。注意每个配置文件缺少<id>元素。

 
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> 
    <modelVersion>4.0.0</modelVersion> 

    <groupId>org.apache.maven.its.mngxxxx</groupId> 
    <artifactId>parent</artifactId> 
    <version>1.0-SNAPSHOT</version> 
    <packaging>pom</packaging> 
    <name>parent</name> 
    <profiles> 
    <profile> 
     <activation> 
     <property><name>foo</name></property> 
     </activation> 
    </profile> 
    <profile> 
     <activation> 
     <property><name>foo</name></property> 
     </activation> 
    </profile> 
    </profiles> 
</project> 

只需键入mvn -X validate -Dfoo=true,您应该在输出顶部附近看到警告消息。这是由第二个配置文件定义试图覆盖第一个。

在Maven 2的相关的代码发出该警告是在DefaultProfileManager.java线123


在Maven中3中,这种情况已经改变。使用最新的maven 3.0-alpha-6,你会得到。

 
[ERROR] The build could not read 1 project -> [Help 1] 
org.apache.maven.project.ProjectBuildingException: Some problems were encountered while processing the POMs: 
[ERROR] profiles.profile.id must be unique but found duplicate profile with id default @ org.apache.maven.its.mngxxxx:parent:1.0-SNAPSHOT, /Users/plynch/dev/apache/maven/core-integration-testing/mytests/mng-xxxx-IT/src/test/resources/mng-xxxx/pom.xml 

at org.apache.maven.project.DefaultProjectBuilder.build(DefaultProjectBuilder.java:285) 
at org.apache.maven.DefaultMaven.collectProjects(DefaultMaven.java:402) 
at org.apache.maven.DefaultMaven.getProjectsForMavenReactor(DefaultMaven.java:351) 
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:171) 
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:104) 
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:422) 
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:157) 
at org.apache.maven.cli.MavenCli.main(MavenCli.java:122) 
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) 
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) 
at java.lang.reflect.Method.invoke(Method.java:592) 
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290) 
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230) 
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409) 
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352) 
[ERROR] The project org.apache.maven.its.mngxxxx:parent:1.0-SNAPSHOT (/Users/plynch/dev/apache/maven/core-integration-testing/mytests/mng-xxxx-IT/src/test/resources/mng-xxxx/pom.xml) has 1 error 
[ERROR]  profiles.profile.id must be unique but found duplicate profile with id default 
[ERROR] 
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles: 
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/ProjectBuildingException 

还请注意,缺少<id>将导致Maven 3应用“默认”配置文件ID。


最后在多模块构建,应该在父POM定义具有相同id作为一个在子的轮廓,没有警告或从Maven的发射其他指示。