English 中文(简体)
Maven warning "Overriding profile: null ..."
原标题:

What are possible causes of the following maven warning:

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

I ve tried commenting out my entire default profile as the warning mentions "profile", but that didn t help. I ve also tried commenting out my reporting options and the warning still shows up.

I ve ran maven with the -X flag and the warning shows up immediately after my hamcrest dependency is brought in, but commenting it out doesn t eliminate the warning.

EDIT: additional information per request:

Output from 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)

Output from 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 is indeed the id of the profile that I use in my pom. At this point, I only have one profile, although I expect to add more in the future.

Resolution:

Peter was right about the problem. The problem stems from not having an id element within a maven profile. In my case, a pom file was being pulled in because of my miglayout dependency.

Upon looking through the dependent pom s, I found that miglayout, indeed, does not use id s in its profiles:

   <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>

There s a number of other profiles missing id s as well as well, each of which cause the warning to be present.

最佳回答

This is easy to reproduce in Maven 2.2.9. The only cause of this is two maven profiles are defined without a profile id element in the same pom.xml, thus the ids are treated null. I don t know what the use case for such a profile is, but Maven 2.2.9 silently allows such a profile to exist, unless you try to override it of course - you get the mentioned warning.

Here is a simple pom that will reproduce the error. Notice the missing <id> element for each profile.

<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>

Simply type mvn -X validate -Dfoo=true and you should see near the top of the output the warning message. This is caused by the second profile definition trying to override the first.

The relevant code in Maven 2 that emits this warning is in DefaultProfileManager.java line 123.


In Maven 3, this has changed. Using the latest maven 3.0-alpha-6 you get.

[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

Notice also that the missing <id> will cause Maven 3 to apply a default profile id.


Lastly in a multi-module build, should a parent pom define a profile with the same id as one in the child, there is no warning or other indication emitted from Maven.

问题回答

暂无回答




相关问题
Derby gets stuck closing?

I ve got unit tests (in maven) that use derby. At the end of the test run, there is a very long pause, with these log messages before the pause. INFO: Closing Hibernate SessionFactory Nov 16, 2009 8:...

Execute goal on parent after children complete

I have a multi-module maven project (several levels of nesting). Normally, when I execute a maven build (like mvn install or whatever), maven will run all the goals for the parent project before ...

Including dependencies in a jar with Maven

Is there a way to force maven(2.0.9) to include all the dependencies in a single jar file? I have a project the builds into a single jar file. I want the classes from dependencies to be copied into ...

Java Equivalent of distcc

Distcc makes it easy to distribute a C or C++ compile job across a number of machines, and is a godsend for working with large, frequently-built codebases. An increasing number of our large projects ...

Maven Assembly Problem

I have a maven multiple-module project, which is giving me headaches in the assembly:assembly phase. I have a module which has an assembly defined in it which works fine when I invoke mvn assembly:...

热门标签