Maven
  1. Maven
  2. MNG-4148

Apply profiles from settings.xml to POMs built from the repository

    Details

    • Type: Improvement Improvement
    • Status: Closed Closed
    • Priority: Major Major
    • Resolution: Won't Fix
    • Affects Version/s: 2.1.0
    • Fix Version/s: None
    • Labels:
      None
    • Complexity:
      Intermediate
    • Testcase included:
      yes
    • Number of attachments :
      1

      Description

      When we declare a profile in the settings.xml, it will never be applied to POMs loaded from the Maven repository. This means that overriding the central repository definition - for instance - cannot be done without using mirror definitions, since transitive dependencies (any dependency of a direct dependency) will skip the modified definition and use the original from the super-POM instead.

      I'm attaching a testing setup that was originally reported for MNG-3553, which exhibits this problem when dealing with scope == import. The instructions for using it are as follows:

      I installed locally a nexus server (1.3.3 Open Source) and I'm using maven 2.1.0 (I reproduced the issue with 2.0.10).
      In the releases repository of nexus you upload all artifacts given in the toUpload directory :
      
          * parent 1.0.0 pom
          * dependencies 1.0.0 pom
          * module 1.0.0 pom and jar
      
      You'll find in the root of the archive my settings. It defines to use nexus for the central repository.
      You launch a build of the project and you'll have :
      
      [INFO] Scanning for projects...
      [INFO] ------------------------------------------------------------------------
      [INFO] Building Unnamed - org.apache.maven.it.mng3553:project:jar:1.0.0-SNAPSHOT
      [INFO]    task-segment: [install]
      [INFO] ------------------------------------------------------------------------
      [INFO] [resources:resources]
      [WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
      [INFO] skip non existing resourceDirectory E:\jtb\workspaces\tests\test-mng3553\project\src\main\resources
      Downloading: http://localhost:8081/nexus/content/groups/public//org/apache/maven/it/mng3553/module/1.0.0/module-1.0.0.pom
      867b downloaded  (module-1.0.0.pom)
      Downloading: http://repo1.maven.org/maven2/org/apache/maven/it/mng3553/dependencies/1.0.0/dependencies-1.0.0.pom
      [WARNING] Unable to get resource 'org.apache.maven.it.mng3553:dependencies:pom:1.0.0'
      from repository central (http://repo1.maven.org/maven2): Authorization failed: Access denied to:
        http://repo1.maven.org/maven2/org/apache/maven/it/mng3553/dependencies/1.0.0/dependencies-1.0.0.pom
      [INFO] ------------------------------------------------------------------------
      [ERROR] BUILD ERROR
      [INFO] ------------------------------------------------------------------------
      [INFO] Failed to resolve artifact.
      GroupId: org.apache.maven.it.mng3553
      ArtifactId: dependencies
      Version: 1.0.0
      Reason: Unable to download the artifact from any repository
        org.apache.maven.it.mng3553:dependencies:pom:1.0.0
      from the specified remote repositories:
        central (http://repo1.maven.org/maven2)
      [INFO] ------------------------------------------------------------------------
      [INFO] For more information, run Maven with the -e switch
      [INFO] ------------------------------------------------------------------------
      [INFO] Total time: 1 second
      [INFO] Finished at: Thu Apr 30 15:19:47 CEST 2009
      [INFO] Final Memory: 6M/254M
      [INFO] ------------------------------------------------------------------------
      
      
      You can see that the project downloads successfully the module-1.0.0 from nexus but
      it fails for depencencies which is an import. It tries to download it from the real central repository
      and not from the one I defined in my settings.
      The behavior is inconsistent...
      

        Issue Links

          Activity

          John Casey made changes -
          Field Original Value New Value
          Link This issue is related to MNG-3553 [ MNG-3553 ]
          Hide
          John Casey added a comment -

          The relationship between these issues merely captures the fact that MNG-3553 was where this issue was originally uncovered.

          Show
          John Casey added a comment - The relationship between these issues merely captures the fact that MNG-3553 was where this issue was originally uncovered.
          John Casey made changes -
          Fix Version/s 2.2.x [ 13141 ]
          Hide
          Arnaud Heritier added a comment - - edited

          I reproduced the issue with a project using a plugin which has an import of depMgt. Maven downloads the plugin, and then fails to download the pom from the import.
          In our settings we defined a proxy * and have a profile which says that central repo allows snapshots. In logs I can see that to download the pom from the import which is a snapshot, Maven evicts the central repo (our proxy) :

          [INFO] snapshot fr.mycompany.myproject.batch:myproject-batch:3.0.0-M1-SNAPSHOT: checking for updates from central
          [DEBUG] Using mirror: http://maven-proxy.groupe.mycompany.fr/all (id: mycompany-mirror)
          [DEBUG] Checking for pre-existing User-Agent configuration.
          [DEBUG] Adding User-Agent configuration.
          [DEBUG] Connecting to repository: 'mycompany-mirror' with url: 'http://maven-proxy.groupe.mycompany.fr/all'.
          [DEBUG] myproject-batch: resolved to version 3.0.0-M1-20090603.080615-14 from repository central
          [DEBUG] Retrieving parent-POM: fr.mycompany.myproject:myproject:pom:3.0.0-M1-SNAPSHOT for project: fr.mycompany.myproject.batch:myproject-batch:pom:null from the repository.
          [INFO] snapshot fr.mycompany.myproject:myproject:3.0.0-M1-SNAPSHOT: checking for updates from central
          [DEBUG] Using mirror: http://maven-proxy.groupe.mycompany.fr/all (id: mycompany-mirror)
          [DEBUG] Checking for pre-existing User-Agent configuration.
          [DEBUG] Adding User-Agent configuration.
          [DEBUG] Connecting to repository: 'mycompany-mirror' with url: 'http://maven-proxy.groupe.mycompany.fr/all'.
          [INFO] snapshot fr.mycompany.myproject:myproject:3.0.0-M1-SNAPSHOT: checking for updates from central
          [DEBUG] Using mirror: http://maven-proxy.groupe.mycompany.fr/all (id: mycompany-mirror)
          [DEBUG] Checking for pre-existing User-Agent configuration.
          [DEBUG] Adding User-Agent configuration.
          [DEBUG] Connecting to repository: 'mycompany-mirror' with url: 'http://maven-proxy.groupe.mycompany.fr/all'.
          [DEBUG] myproject: resolved to version 3.0.0-M1-20090603.080615-14 from repository central
          [DEBUG] Skipping disabled repository central
          [DEBUG] myentity-pdg-jboss: using locally installed snapshot
          [DEBUG] Skipping disabled repository central
          [DEBUG] Using mirror: http://maven-proxy.groupe.mycompany.fr/all (id: mycompany-mirror)
          [INFO] ------------------------------------------------------------------------
          [ERROR] BUILD ERROR
          [INFO] ------------------------------------------------------------------------
          [INFO] Failed to resolve artifact.
          
          GroupId: fr.mycompany.myentity.myproject.pdg
          ArtifactId: myentity-pdg-jboss
          Version: 1.1.0-M1-SNAPSHOT
          
          Reason: Unable to download the artifact from any repository
          
            fr.mycompany.myentity.myproject.pdg:myentity-pdg-jboss:pom:1.1.0-M1-SNAPSHOT
          
          from the specified remote repositories:
            mycompany-mirror (http://maven-proxy.groupe.mycompany.fr/all)
          
          
          
          [INFO] ------------------------------------------------------------------------
          [DEBUG] Trace
          org.apache.maven.lifecycle.LifecycleExecutionException: Unable to build project for plugin 'fr.mycompany.myproject.plugins:myproject-batchpackager-plugin': POM 'fr.gener
          ali.myentity.myproject.pdg:myentity-pdg-jboss' not found in repository: Unable to download the artifact from any repository
          
            fr.mycompany.myentity.myproject.pdg:myentity-pdg-jboss:pom:1.1.0-M1-SNAPSHOT
          
          from the specified remote repositories:
            mycompany-mirror (http://maven-proxy.groupe.mycompany.fr/all)
          
           for project fr.mycompany.myentity.myproject.pdg:myentity-pdg-jboss
                  at org.apache.maven.lifecycle.DefaultLifecycleExecutor.verifyPlugin(DefaultLifecycleExecutor.java:1534)
                  at org.apache.maven.lifecycle.DefaultLifecycleExecutor.bindPluginToLifecycle(DefaultLifecycleExecutor.java:1479)
                  at org.apache.maven.lifecycle.DefaultLifecycleExecutor.constructLifecycleMappings(DefaultLifecycleExecutor.java:1245)
                  at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:518)
                  at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:371)
                  at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:332)
                  at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:181)
                  at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:356)
                  at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:137)
                  at org.apache.maven.cli.MavenCli.main(MavenCli.java:356)
                  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:585)
                  at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
                  at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
                  at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
                  at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
          Caused by: org.apache.maven.plugin.InvalidPluginException: Unable to build project for plugin 'fr.mycompany.myproject.plugins:myproject-batchpackager-plugin': POM 'fr.ge
          nerali.myentity.myproject.pdg:myentity-pdg-jboss' not found in repository: Unable to download the artifact from any repository
          
            fr.mycompany.myentity.myproject.pdg:myentity-pdg-jboss:pom:1.1.0-M1-SNAPSHOT
          
          from the specified remote repositories:
            mycompany-mirror (http://maven-proxy.groupe.mycompany.fr/all)
          
           for project fr.mycompany.myentity.myproject.pdg:myentity-pdg-jboss
                  at org.apache.maven.plugin.DefaultPluginManager.checkRequiredMavenVersion(DefaultPluginManager.java:286)
                  at org.apache.maven.plugin.DefaultPluginManager.verifyVersionedPlugin(DefaultPluginManager.java:198)
                  at org.apache.maven.plugin.DefaultPluginManager.verifyPlugin(DefaultPluginManager.java:177)
                  at org.apache.maven.lifecycle.DefaultLifecycleExecutor.verifyPlugin(DefaultLifecycleExecutor.java:1517)
                  ... 17 more
          Caused by: org.apache.maven.project.ProjectBuildingException: POM 'fr.mycompany.myentity.myproject.pdg:myentity-pdg-jboss' not found in repository: Unable to download the arti
          fact from any repository
          
            fr.mycompany.myentity.myproject.pdg:myentity-pdg-jboss:pom:1.1.0-M1-SNAPSHOT
          
          from the specified remote repositories:
            mycompany-mirror (http://maven-proxy.groupe.mycompany.fr/all)
          
           for project fr.mycompany.myentity.myproject.pdg:myentity-pdg-jboss
                  at org.apache.maven.project.DefaultMavenProjectBuilder.findModelFromRepository(DefaultMavenProjectBuilder.java:605)
                  at org.apache.maven.project.DefaultMavenProjectBuilder.buildFromRepository(DefaultMavenProjectBuilder.java:251)
                  at org.apache.maven.project.DefaultMavenProjectBuilder.mergeManagedDependencies(DefaultMavenProjectBuilder.java:1466)
                  at org.apache.maven.project.DefaultMavenProjectBuilder.processProjectLogic(DefaultMavenProjectBuilder.java:1008)
                  at org.apache.maven.project.DefaultMavenProjectBuilder.buildInternal(DefaultMavenProjectBuilder.java:880)
                  at org.apache.maven.project.DefaultMavenProjectBuilder.buildFromRepository(DefaultMavenProjectBuilder.java:255)
                  at org.apache.maven.plugin.DefaultPluginManager.checkRequiredMavenVersion(DefaultPluginManager.java:270)
                  ... 20 more
          Caused by: org.apache.maven.artifact.resolver.ArtifactNotFoundException: Unable to download the artifact from any repository
          
            fr.mycompany.myentity.myproject.pdg:myentity-pdg-jboss:pom:1.1.0-M1-SNAPSHOT
          
          from the specified remote repositories:
            mycompany-mirror (http://maven-proxy.groupe.mycompany.fr/all)
          
          
                  at org.apache.maven.artifact.resolver.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:228)
                  at org.apache.maven.artifact.resolver.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:90)
                  at org.apache.maven.project.DefaultMavenProjectBuilder.findModelFromRepository(DefaultMavenProjectBuilder.java:558)
                  ... 26 more
          Caused by: org.apache.maven.wagon.ResourceDoesNotExistException: Unable to download the artifact from any repository
                  at org.apache.maven.artifact.manager.DefaultWagonManager.getArtifact(DefaultWagonManager.java:349)
                  at org.apache.maven.artifact.resolver.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:216)
                  ... 28 more
          [INFO] ------------------------------------------------------------------------
          [INFO] Total time: 2 seconds
          [INFO] Finished at: Tue Jun 09 10:59:16 CEST 2009
          [INFO] Final Memory: 3M/254M
          [INFO] ------------------------------------------------------------------------
          
          Show
          Arnaud Heritier added a comment - - edited I reproduced the issue with a project using a plugin which has an import of depMgt. Maven downloads the plugin, and then fails to download the pom from the import. In our settings we defined a proxy * and have a profile which says that central repo allows snapshots. In logs I can see that to download the pom from the import which is a snapshot, Maven evicts the central repo (our proxy) : [INFO] snapshot fr.mycompany.myproject.batch:myproject-batch:3.0.0-M1-SNAPSHOT: checking for updates from central [DEBUG] Using mirror: http: //maven-proxy.groupe.mycompany.fr/all (id: mycompany-mirror) [DEBUG] Checking for pre-existing User-Agent configuration. [DEBUG] Adding User-Agent configuration. [DEBUG] Connecting to repository: 'mycompany-mirror' with url: 'http: //maven-proxy.groupe.mycompany.fr/all'. [DEBUG] myproject-batch: resolved to version 3.0.0-M1-20090603.080615-14 from repository central [DEBUG] Retrieving parent-POM: fr.mycompany.myproject:myproject:pom:3.0.0-M1-SNAPSHOT for project: fr.mycompany.myproject.batch:myproject-batch:pom: null from the repository. [INFO] snapshot fr.mycompany.myproject:myproject:3.0.0-M1-SNAPSHOT: checking for updates from central [DEBUG] Using mirror: http: //maven-proxy.groupe.mycompany.fr/all (id: mycompany-mirror) [DEBUG] Checking for pre-existing User-Agent configuration. [DEBUG] Adding User-Agent configuration. [DEBUG] Connecting to repository: 'mycompany-mirror' with url: 'http: //maven-proxy.groupe.mycompany.fr/all'. [INFO] snapshot fr.mycompany.myproject:myproject:3.0.0-M1-SNAPSHOT: checking for updates from central [DEBUG] Using mirror: http: //maven-proxy.groupe.mycompany.fr/all (id: mycompany-mirror) [DEBUG] Checking for pre-existing User-Agent configuration. [DEBUG] Adding User-Agent configuration. [DEBUG] Connecting to repository: 'mycompany-mirror' with url: 'http: //maven-proxy.groupe.mycompany.fr/all'. [DEBUG] myproject: resolved to version 3.0.0-M1-20090603.080615-14 from repository central [DEBUG] Skipping disabled repository central [DEBUG] myentity-pdg-jboss: using locally installed snapshot [DEBUG] Skipping disabled repository central [DEBUG] Using mirror: http: //maven-proxy.groupe.mycompany.fr/all (id: mycompany-mirror) [INFO] ------------------------------------------------------------------------ [ERROR] BUILD ERROR [INFO] ------------------------------------------------------------------------ [INFO] Failed to resolve artifact. GroupId: fr.mycompany.myentity.myproject.pdg ArtifactId: myentity-pdg-jboss Version: 1.1.0-M1-SNAPSHOT Reason: Unable to download the artifact from any repository fr.mycompany.myentity.myproject.pdg:myentity-pdg-jboss:pom:1.1.0-M1-SNAPSHOT from the specified remote repositories: mycompany-mirror (http: //maven-proxy.groupe.mycompany.fr/all) [INFO] ------------------------------------------------------------------------ [DEBUG] Trace org.apache.maven.lifecycle.LifecycleExecutionException: Unable to build project for plugin 'fr.mycompany.myproject.plugins:myproject-batchpackager-plugin': POM 'fr.gener ali.myentity.myproject.pdg:myentity-pdg-jboss' not found in repository: Unable to download the artifact from any repository fr.mycompany.myentity.myproject.pdg:myentity-pdg-jboss:pom:1.1.0-M1-SNAPSHOT from the specified remote repositories: mycompany-mirror (http: //maven-proxy.groupe.mycompany.fr/all) for project fr.mycompany.myentity.myproject.pdg:myentity-pdg-jboss at org.apache.maven.lifecycle.DefaultLifecycleExecutor.verifyPlugin(DefaultLifecycleExecutor.java:1534) at org.apache.maven.lifecycle.DefaultLifecycleExecutor.bindPluginToLifecycle(DefaultLifecycleExecutor.java:1479) at org.apache.maven.lifecycle.DefaultLifecycleExecutor.constructLifecycleMappings(DefaultLifecycleExecutor.java:1245) at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:518) at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:371) at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:332) at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:181) at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:356) at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:137) at org.apache.maven.cli.MavenCli.main(MavenCli.java:356) 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:585) at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315) at org.codehaus.classworlds.Launcher.launch(Launcher.java:255) at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430) at org.codehaus.classworlds.Launcher.main(Launcher.java:375) Caused by: org.apache.maven.plugin.InvalidPluginException: Unable to build project for plugin 'fr.mycompany.myproject.plugins:myproject-batchpackager-plugin': POM 'fr.ge nerali.myentity.myproject.pdg:myentity-pdg-jboss' not found in repository: Unable to download the artifact from any repository fr.mycompany.myentity.myproject.pdg:myentity-pdg-jboss:pom:1.1.0-M1-SNAPSHOT from the specified remote repositories: mycompany-mirror (http: //maven-proxy.groupe.mycompany.fr/all) for project fr.mycompany.myentity.myproject.pdg:myentity-pdg-jboss at org.apache.maven.plugin.DefaultPluginManager.checkRequiredMavenVersion(DefaultPluginManager.java:286) at org.apache.maven.plugin.DefaultPluginManager.verifyVersionedPlugin(DefaultPluginManager.java:198) at org.apache.maven.plugin.DefaultPluginManager.verifyPlugin(DefaultPluginManager.java:177) at org.apache.maven.lifecycle.DefaultLifecycleExecutor.verifyPlugin(DefaultLifecycleExecutor.java:1517) ... 17 more Caused by: org.apache.maven.project.ProjectBuildingException: POM 'fr.mycompany.myentity.myproject.pdg:myentity-pdg-jboss' not found in repository: Unable to download the arti fact from any repository fr.mycompany.myentity.myproject.pdg:myentity-pdg-jboss:pom:1.1.0-M1-SNAPSHOT from the specified remote repositories: mycompany-mirror (http: //maven-proxy.groupe.mycompany.fr/all) for project fr.mycompany.myentity.myproject.pdg:myentity-pdg-jboss at org.apache.maven.project.DefaultMavenProjectBuilder.findModelFromRepository(DefaultMavenProjectBuilder.java:605) at org.apache.maven.project.DefaultMavenProjectBuilder.buildFromRepository(DefaultMavenProjectBuilder.java:251) at org.apache.maven.project.DefaultMavenProjectBuilder.mergeManagedDependencies(DefaultMavenProjectBuilder.java:1466) at org.apache.maven.project.DefaultMavenProjectBuilder.processProjectLogic(DefaultMavenProjectBuilder.java:1008) at org.apache.maven.project.DefaultMavenProjectBuilder.buildInternal(DefaultMavenProjectBuilder.java:880) at org.apache.maven.project.DefaultMavenProjectBuilder.buildFromRepository(DefaultMavenProjectBuilder.java:255) at org.apache.maven.plugin.DefaultPluginManager.checkRequiredMavenVersion(DefaultPluginManager.java:270) ... 20 more Caused by: org.apache.maven.artifact.resolver.ArtifactNotFoundException: Unable to download the artifact from any repository fr.mycompany.myentity.myproject.pdg:myentity-pdg-jboss:pom:1.1.0-M1-SNAPSHOT from the specified remote repositories: mycompany-mirror (http: //maven-proxy.groupe.mycompany.fr/all) at org.apache.maven.artifact.resolver.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:228) at org.apache.maven.artifact.resolver.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:90) at org.apache.maven.project.DefaultMavenProjectBuilder.findModelFromRepository(DefaultMavenProjectBuilder.java:558) ... 26 more Caused by: org.apache.maven.wagon.ResourceDoesNotExistException: Unable to download the artifact from any repository at org.apache.maven.artifact.manager.DefaultWagonManager.getArtifact(DefaultWagonManager.java:349) at org.apache.maven.artifact.resolver.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:216) ... 28 more [INFO] ------------------------------------------------------------------------ [INFO] Total time: 2 seconds [INFO] Finished at: Tue Jun 09 10:59:16 CEST 2009 [INFO] Final Memory: 3M/254M [INFO] ------------------------------------------------------------------------
          Benjamin Bentmann made changes -
          Link This issue is related to MNG-4181 [ MNG-4181 ]
          Hide
          Benjamin Bentmann added a comment -

          Usage of properties from settings.xml to define the path to system-scope dependencies is another case that gets hit by this.

          Show
          Benjamin Bentmann added a comment - Usage of properties from settings.xml to define the path to system-scope dependencies is another case that gets hit by this.
          Benjamin Bentmann made changes -
          Link This issue is related to MNG-2626 [ MNG-2626 ]
          Brett Porter made changes -
          Link This issue supercedes MNG-2626 [ MNG-2626 ]
          Hide
          Gabriel added a comment -

          Please consider these votes/watchers:

          Bug MNG-3553 has:
          Votes: 17
          Watchers: 10

          Bug MNG-2626 has:
          Votes: 16
          Watchers: 14

          Show
          Gabriel added a comment - Please consider these votes/watchers: Bug MNG-3553 has: Votes: 17 Watchers: 10 Bug MNG-2626 has: Votes: 16 Watchers: 14
          John Casey made changes -
          Fix Version/s 2.2.2 [ 15472 ]
          Fix Version/s 2.2.x [ 13141 ]
          John Casey made changes -
          Link This issue is related to MNG-4347 [ MNG-4347 ]
          Benjamin Bentmann made changes -
          Description When we declare a profile in the settings.xml, it will never be applied to POMs loaded from the Maven repository. This means that overriding the central repository definition - for instance - cannot be done without using mirror definitions, since transitive dependencies (any dependency of a direct dependency) will skip the modified definition and use the original from the super-POM instead.

          I'm attaching a testing setup that was originally reported for MNG-3553, which exhibits this problem when dealing with scope == import. The instructions for using it are as follows:

          {noformat}
          I installed locally a nexus server (1.3.3 Open Source) and I'm using maven 2.1.0 (I reproduced the issue with 2.0.10).
          In the releases repository of nexus you upload all artifacts given in the toUpload directory :

              * parent 1.0.0 pom
              * dependencies 1.0.0 pom
              * module 1.0.0 pom and jar

          You'll find in the root of the archive my settings. It defines to use nexus for the central repository.
          You launch a build of the project and you'll have :

          [INFO] Scanning for projects...
          [INFO] ------------------------------------------------------------------------
          [INFO] Building Unnamed - org.apache.maven.it.mng3553:project:jar:1.0.0-SNAPSHOT
          [INFO] task-segment: [install]
          [INFO] ------------------------------------------------------------------------
          [INFO] [resources:resources]
          [WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
          [INFO] skip non existing resourceDirectory E:\jtb\workspaces\tests\test-mng3553\project\src\main\resources
          Downloading: http://localhost:8081/nexus/content/groups/public//org/apache/maven/it/mng3553/module/1.0.0/module-1.0.0.pom
          867b downloaded (module-1.0.0.pom)
          Downloading: http://repo1.maven.org/maven2/org/apache/maven/it/mng3553/dependencies/1.0.0/dependencies-1.0.0.pom
          [WARNING] Unable to get resource 'org.apache.maven.it.mng3553:dependencies:pom:1.0.0' from repository central (http://repo1.maven.org/maven2): Authorization fai
          led: Access denied to: http://repo1.maven.org/maven2/org/apache/maven/it/mng3553/dependencies/1.0.0/dependencies-1.0.0.pom
          [INFO] ------------------------------------------------------------------------
          [ERROR] BUILD ERROR
          [INFO] ------------------------------------------------------------------------
          [INFO] Failed to resolve artifact.
          GroupId: org.apache.maven.it.mng3553
          ArtifactId: dependencies
          Version: 1.0.0
          Reason: Unable to download the artifact from any repository
            org.apache.maven.it.mng3553:dependencies:pom:1.0.0
          from the specified remote repositories:
            central (http://repo1.maven.org/maven2)
          [INFO] ------------------------------------------------------------------------
          [INFO] For more information, run Maven with the -e switch
          [INFO] ------------------------------------------------------------------------
          [INFO] Total time: 1 second
          [INFO] Finished at: Thu Apr 30 15:19:47 CEST 2009
          [INFO] Final Memory: 6M/254M
          [INFO] ------------------------------------------------------------------------


          You can see that the project downloads successfully the module-1.0.0 from nexus but it fails for depencencies which is an import. It tries to download it from the real central repository and not from the one I defined in my settings.
          The behavior is inconsistent...
          {noformat}
          When we declare a profile in the settings.xml, it will never be applied to POMs loaded from the Maven repository. This means that overriding the central repository definition - for instance - cannot be done without using mirror definitions, since transitive dependencies (any dependency of a direct dependency) will skip the modified definition and use the original from the super-POM instead.

          I'm attaching a testing setup that was originally reported for MNG-3553, which exhibits this problem when dealing with scope == import. The instructions for using it are as follows:

          {noformat}
          I installed locally a nexus server (1.3.3 Open Source) and I'm using maven 2.1.0 (I reproduced the issue with 2.0.10).
          In the releases repository of nexus you upload all artifacts given in the toUpload directory :

              * parent 1.0.0 pom
              * dependencies 1.0.0 pom
              * module 1.0.0 pom and jar

          You'll find in the root of the archive my settings. It defines to use nexus for the central repository.
          You launch a build of the project and you'll have :

          [INFO] Scanning for projects...
          [INFO] ------------------------------------------------------------------------
          [INFO] Building Unnamed - org.apache.maven.it.mng3553:project:jar:1.0.0-SNAPSHOT
          [INFO] task-segment: [install]
          [INFO] ------------------------------------------------------------------------
          [INFO] [resources:resources]
          [WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
          [INFO] skip non existing resourceDirectory E:\jtb\workspaces\tests\test-mng3553\project\src\main\resources
          Downloading: http://localhost:8081/nexus/content/groups/public//org/apache/maven/it/mng3553/module/1.0.0/module-1.0.0.pom
          867b downloaded (module-1.0.0.pom)
          Downloading: http://repo1.maven.org/maven2/org/apache/maven/it/mng3553/dependencies/1.0.0/dependencies-1.0.0.pom
          [WARNING] Unable to get resource 'org.apache.maven.it.mng3553:dependencies:pom:1.0.0'
          from repository central (http://repo1.maven.org/maven2): Authorization failed: Access denied to:
            http://repo1.maven.org/maven2/org/apache/maven/it/mng3553/dependencies/1.0.0/dependencies-1.0.0.pom
          [INFO] ------------------------------------------------------------------------
          [ERROR] BUILD ERROR
          [INFO] ------------------------------------------------------------------------
          [INFO] Failed to resolve artifact.
          GroupId: org.apache.maven.it.mng3553
          ArtifactId: dependencies
          Version: 1.0.0
          Reason: Unable to download the artifact from any repository
            org.apache.maven.it.mng3553:dependencies:pom:1.0.0
          from the specified remote repositories:
            central (http://repo1.maven.org/maven2)
          [INFO] ------------------------------------------------------------------------
          [INFO] For more information, run Maven with the -e switch
          [INFO] ------------------------------------------------------------------------
          [INFO] Total time: 1 second
          [INFO] Finished at: Thu Apr 30 15:19:47 CEST 2009
          [INFO] Final Memory: 6M/254M
          [INFO] ------------------------------------------------------------------------


          You can see that the project downloads successfully the module-1.0.0 from nexus but
          it fails for depencencies which is an import. It tries to download it from the real central repository
          and not from the one I defined in my settings.
          The behavior is inconsistent...
          {noformat}
          John Casey made changes -
          Assignee John Casey [ jdcasey ]
          Resolution Fixed [ 1 ]
          Status Open [ 1 ] Closed [ 6 ]
          Benjamin Bentmann made changes -
          Link This issue relates to MNG-3612 [ MNG-3612 ]
          Benjamin Bentmann made changes -
          Link This issue relates to MNG-3782 [ MNG-3782 ]
          Hide
          Brett Porter added a comment -

          this solution needs review before being released, per http://www.mail-archive.com/dev@maven.apache.org/msg82166.html

          At the least, I Think it might be inconsistent with 3.0, and we don't want people being bitten by it existing and then being taken away.

          Show
          Brett Porter added a comment - this solution needs review before being released, per http://www.mail-archive.com/dev@maven.apache.org/msg82166.html At the least, I Think it might be inconsistent with 3.0, and we don't want people being bitten by it existing and then being taken away.
          Brett Porter made changes -
          Resolution Fixed [ 1 ]
          Status Closed [ 6 ] Reopened [ 4 ]
          Brett Porter made changes -
          Link This issue is duplicated by MNG-4538 [ MNG-4538 ]
          Hide
          Brett Porter added a comment -

          This also needs to go into the compatibility wiki if it is not going to be allowed going forward.

          Show
          Brett Porter added a comment - This also needs to go into the compatibility wiki if it is not going to be allowed going forward.
          Paul Gier made changes -
          Link This issue is related to MNG-3537 [ MNG-3537 ]
          Hide
          abhishek misra added a comment -

          I just tried using $

          {settings.localRepository}

          in systemPath with Maven 3.0 Beta 3 and it still complains about absolute path. Will this be fixed with version 3?

          Show
          abhishek misra added a comment - I just tried using $ {settings.localRepository} in systemPath with Maven 3.0 Beta 3 and it still complains about absolute path. Will this be fixed with version 3?
          Benjamin Bentmann made changes -
          Link This issue relates to MNG-4809 [ MNG-4809 ]
          Hide
          Aurélien Girardeau added a comment -

          Hi all,
          My company deals with the same issue.
          I don't understand one thing : why this is only append when scope == import, not for other scope?

          regards

          Show
          Aurélien Girardeau added a comment - Hi all, My company deals with the same issue. I don't understand one thing : why this is only append when scope == import, not for other scope? regards
          Benjamin Bentmann made changes -
          Link This issue is duplicated by MNG-4930 [ MNG-4930 ]
          Hide
          Tibor Varga added a comment -

          I read through the discussion Bratt linked to and tried to apply the concepts expressed there to the case I reported in MNG-4930, where the value to the given property was only supplied by settings.xml.

          Then I read that discussion again, as well as the original bug report here, and found that the overriding concern has been (excuse the pun) that allowing properties from settings.xml or any source external to the POMs to override properties defined in POMs may have serious, and unintended, consequences.

          Maven's current approach it to simply ignore any property coming from settings.xml even if it would not override anything but supply the only value to a property.

          In light of that, how about this: do not allow properties coming from outside the POMs to override properties defined in the POMs, only allow them to supply original values?

          Would that make sense?

          It would certainly solve my case, which in real life, actually, had to do with the systemPath of a system scope dependency that depended on a property defined in settings.xml.

          Show
          Tibor Varga added a comment - I read through the discussion Bratt linked to and tried to apply the concepts expressed there to the case I reported in MNG-4930 , where the value to the given property was only supplied by settings.xml . Then I read that discussion again, as well as the original bug report here, and found that the overriding concern has been (excuse the pun) that allowing properties from settings.xml or any source external to the POMs to override properties defined in POMs may have serious, and unintended, consequences. Maven's current approach it to simply ignore any property coming from settings.xml even if it would not override anything but supply the only value to a property. In light of that, how about this: do not allow properties coming from outside the POMs to override properties defined in the POMs, only allow them to supply original values ? Would that make sense? It would certainly solve my case, which in real life, actually, had to do with the systemPath of a system scope dependency that depended on a property defined in settings.xml .
          Hide
          Ben Tomasini added a comment -

          I have created a plugin which depends on a jar in a heavyweight application server which has a number of hard coded class path entries in the jar's manifest. Uploading all of the jar files to our internal repository is simply not practical.

          Using a systemPath in the dependency declaration of the plugin with a property to set the directory of the app server would be ideal in this case.

          Show
          Ben Tomasini added a comment - I have created a plugin which depends on a jar in a heavyweight application server which has a number of hard coded class path entries in the jar's manifest. Uploading all of the jar files to our internal repository is simply not practical. Using a systemPath in the dependency declaration of the plugin with a property to set the directory of the app server would be ideal in this case.
          Jason van Zyl made changes -
          Resolution Won't Fix [ 2 ]
          Status Reopened [ 4 ] Closed [ 6 ]
          Hide
          Jason van Zyl added a comment -

          I think profiles are specifically build time, with the possible exception of platform and JDK which is really more of an environment. If we are moving toward a consumption-time POM we want to avoid the processing of profiles as much as possible.

          Show
          Jason van Zyl added a comment - I think profiles are specifically build time, with the possible exception of platform and JDK which is really more of an environment. If we are moving toward a consumption-time POM we want to avoid the processing of profiles as much as possible.
          Michael Osipov made changes -
          Fix Version/s 2.2.2 [ 15472 ]

            People

            • Assignee:
              John Casey
              Reporter:
              John Casey
            • Votes:
              27 Vote for this issue
              Watchers:
              28 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: