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</开发者_如何学Coptional>
</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.
精彩评论