{"record":{"id":"5dee01158d8de9d7","repo":"apache/maven","slug":"overriding-profile-source-with-new-ins","errorCode":null,"errorMessage":"Overriding profile: '{}' (source: {}) with new instance from source: {}","messagePattern":"Overriding profile: '(.+?)' \\(source: (.+?)\\) with new instance from source: (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"compat/maven-compat/src/main/java/org/apache/maven/profiles/DefaultProfileManager.java","lineNumber":105,"sourceCode":"    public Properties getRequestProperties() {\n        return requestProperties;\n    }\n\n    @Override\n    public Map<String, Profile> getProfilesById() {\n        return profilesById;\n    }\n\n    /* (non-Javadoc)\n     * @see org.apache.maven.profiles.ProfileManager#addProfile(org.apache.maven.model.Profile)\n     */\n    @Override\n    public void addProfile(Profile profile) {\n        String profileId = profile.getId();\n\n        Profile existing = profilesById.get(profileId);\n        if (existing != null) {\n            logger.warn(\"Overriding profile: '\" + profileId + \"' (source: \" + existing.getSource()\n                    + \") with new instance from source: \" + profile.getSource());\n        }\n\n        profilesById.put(profile.getId(), profile);\n\n        Activation activation = profile.getActivation();\n\n        if (activation != null && activation.isActiveByDefault()) {\n            activateAsDefault(profileId);\n        }\n    }\n\n    /* (non-Javadoc)\n     * @see org.apache.maven.profiles.ProfileManager#explicitlyActivate(java.lang.String)\n     */\n    @Override\n    public void explicitlyActivate(String profileId) {\n        if (!activatedIds.contains(profileId)) {","sourceCodeStart":87,"sourceCodeEnd":123,"githubUrl":"https://github.com/apache/maven/blob/e4093d4e120eac99d6bdce5ba67cace2f3085c97/compat/maven-compat/src/main/java/org/apache/maven/profiles/DefaultProfileManager.java#L87-L123","documentation":"Warning logged by DefaultProfileManager.addProfile when a profile with the same id is registered twice: the previous instance (and its source, e.g. 'settings.xml', 'pom.xml', 'profiles.xml') is replaced by the new one. Last registration wins; activation properties of the discarded profile are lost. It is diagnostic only, but silent behavior changes can follow because the effective profile differs from what the user expects.","triggerScenarios":"The same profile id is defined in more than one source processed by the ProfileManager: settings.xml plus pom.xml, two poms in an inheritance chain, or profiles injected programmatically (e.g. via MavenExecutionRequest.addProfile) that collide with file-defined ids.","commonSituations":"A corporate settings.xml ships a 'local-dev' profile while the project pom.xml also defines 'local-dev'; IDEs injecting profiles with generic ids; copy-pasted profiles between parent and child POMs.","solutions":["Search all sources for the id: grep -r '<id>NAME</id>' across pom.xml, ~/.m2/settings.xml, and any injected profiles.","Rename one of the profiles so both can coexist, or delete the duplicate you do not need.","If inheritance overwriting is intended (child redefines parent profile), keep it but be aware the parent's activation is fully replaced.","For plugin/embedder authors: check profilesById before addProfile, or namespace programmatic profile ids."],"exampleFix":"<!-- before: same id in settings.xml and pom.xml -->\n<profile><id>dev</id>...</profile>\n<!-- after: rename in pom.xml -->\n<profile><id>project-dev</id>...</profile>","handlingStrategy":"validation","validationCode":"// embedder: check before adding\nProfile existing = profileManager.getProfilesById().get(profile.getId());\nif (existing != null && !existing.getSource().equals(profile.getSource())) {\n    throw new IllegalStateException(\"duplicate profile id from \" + profile.getSource());\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Namespace custom profile ids (e.g. com.corp.dev) to avoid collisions with pom profiles.","Audit settings.xml profiles when onboarding shared corporate settings.","Remember last-registered profile wins; verify effective profile with help:effective-settings / help:active-profiles."],"tags":["maven","profiles","configuration","duplicate-id"],"backgroundTag":"duplicate-profile-id","analyzedSha":"e4093d4e120eac99d6bdce5ba67cace2f3085c97","analyzedAt":"2026-08-21T22:58:24.034Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}