You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ant.apache.org by "Martin von Gagern (JIRA)" <ji...@apache.org> on 2008/11/21 14:32:46 UTC

[jira] Created: (IVY-974) Dependencies don't inherit exclusions from dependencyManagement

Dependencies don't inherit exclusions from dependencyManagement
---------------------------------------------------------------

                 Key: IVY-974
                 URL: https://issues.apache.org/jira/browse/IVY-974
             Project: Ivy
          Issue Type: Bug
          Components: Maven Compatibility
    Affects Versions: 2.0-RC2
            Reporter: Martin von Gagern


In Maven 2, exclusions for a dependency can be given in the dependencyManagement element of an ancestor pom. These exclusions aren't correctly reproduced by Ivy.

I have several projects here managed by Maven 2, and inheriting from a common ancestor. The pom of this ancestor includes the following fragment:

 <dependencyManagement>
  <dependencies>
   <dependency>
    <groupId>log4j</groupId><artifactId>log4j</artifactId><version>1.2.15</version>
    <exclusions>
     <exclusion><groupId>javax.mail</groupId><artifactId>mail</artifactId></exclusion>
     <exclusion><groupId>javax.jms</groupId><artifactId>jms</artifactId></exclusion>
     <exclusion><groupId>com.sun.jdmk</groupId><artifactId>jmxtools</artifactId></exclusion>
     <exclusion><groupId>com.sun.jmx</groupId><artifactId>jmxri</artifactId></exclusion>
    </exclusions>
   </dependency>
  </dependencies>
 </dependencyManagement>

So in any inheriting project I can simply depend on log4j and get the correct version without the listed dependencies. This is important as some of these dependencies cannot be resolved from the main Maven repository. They are in fact optional, but not listed as such in the log4j pom. It is also Maven practice to list such exclusions in the common ancestor instead of repeating them in every module depending on log4j.

Ivy 2 doesn't reproduce this kind of inherited exclusions. When I have an ivy project depending on one of my projects, the modules are not excluded, resulting in download errors for obscure packages. Looking at the ivy descriptors in cache I find the missing exclusions.

To fix this, PomDependencyMgtElement in PomReader.java would have to learn to look out for exclusions. This information could than be used by PomModuleDescriptorBuilder. More precisely, addDependencyMgt would have to store it with the desciptor, and addDependency could then incorporate in its inheritance calculations. The whole setup with extra information, with keys calculated using getDependencyMgtExtraInfoKeyFor* and values restricted to strings, seems ill suited to express the structure of the dependency management information. I would prefer the ivy.xml to contain a m2:dependencyManagement element, and use Maven POM syntax within that element. I guess this approach would require larger modifications, though, so I doubt that's a good idea for 2.0 at least.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (IVY-974) Dependencies don't inherit exclusions from dependencyManagement

Posted by "John Gibson (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/IVY-974?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

John Gibson updated IVY-974:
----------------------------

    Attachment: parent_dependency_mgt_excludes.patch

I too found this to be troublesome.  Here is a patch that fixes it.  Martin's original assessment that "keys calculated using getDependencyMgtExtraInfoKeyFor* and values restricted to strings, seems ill suited to express the structure of the dependency management information" is correct.  This feels like a big hack, but it works.

There are a few caveats with this patch.  PomPluginElement in PomReader and PomModuleDescriptorBuilder both implement PomDependencyMgt, but they don't support the exclusions.  I only use the maven ant tasks and so I have no experience with maven plugins, so I really have no idea if exclusions are supported or how they should behave.  Second, when I encounter errors when parsing the exclusions in the extraInfo area of an ivy file, I just signal an error using the Message class.  I'm not sure if this is the right way to handle these problems.

The final issue is a corner case that I'm not sure about.  Imagine that a child POM inherits some exclusions for dependency A.  If the child specifies an empty <exclusions> for dependency A then what should happen?  Should A have no exclusions or should it still inherit from the parent?  As written it will inherit from the parent.  If this isn't the correct behavior then it could be fixed by making PomReader.PomDependencyData.getExcludedModules() return null if no <exclusions> is present and a list only when <exclusions> has been explicitly declared.


> Dependencies don't inherit exclusions from dependencyManagement
> ---------------------------------------------------------------
>
>                 Key: IVY-974
>                 URL: https://issues.apache.org/jira/browse/IVY-974
>             Project: Ivy
>          Issue Type: Bug
>          Components: Maven Compatibility
>    Affects Versions: 2.0-RC2
>            Reporter: Martin von Gagern
>         Attachments: parent_dependency_mgt_excludes.patch
>
>
> In Maven 2, exclusions for a dependency can be given in the dependencyManagement element of an ancestor pom. These exclusions aren't correctly reproduced by Ivy.
> I have several projects here managed by Maven 2, and inheriting from a common ancestor. The pom of this ancestor includes the following fragment:
>  <dependencyManagement>
>   <dependencies>
>    <dependency>
>     <groupId>log4j</groupId><artifactId>log4j</artifactId><version>1.2.15</version>
>     <exclusions>
>      <exclusion><groupId>javax.mail</groupId><artifactId>mail</artifactId></exclusion>
>      <exclusion><groupId>javax.jms</groupId><artifactId>jms</artifactId></exclusion>
>      <exclusion><groupId>com.sun.jdmk</groupId><artifactId>jmxtools</artifactId></exclusion>
>      <exclusion><groupId>com.sun.jmx</groupId><artifactId>jmxri</artifactId></exclusion>
>     </exclusions>
>    </dependency>
>   </dependencies>
>  </dependencyManagement>
> So in any inheriting project I can simply depend on log4j and get the correct version without the listed dependencies. This is important as some of these dependencies cannot be resolved from the main Maven repository. They are in fact optional, but not listed as such in the log4j pom. It is also Maven practice to list such exclusions in the common ancestor instead of repeating them in every module depending on log4j.
> Ivy 2 doesn't reproduce this kind of inherited exclusions. When I have an ivy project depending on one of my projects, the modules are not excluded, resulting in download errors for obscure packages. Looking at the ivy descriptors in cache I find the missing exclusions.
> To fix this, PomDependencyMgtElement in PomReader.java would have to learn to look out for exclusions. This information could than be used by PomModuleDescriptorBuilder. More precisely, addDependencyMgt would have to store it with the desciptor, and addDependency could then incorporate in its inheritance calculations. The whole setup with extra information, with keys calculated using getDependencyMgtExtraInfoKeyFor* and values restricted to strings, seems ill suited to express the structure of the dependency management information. I would prefer the ivy.xml to contain a m2:dependencyManagement element, and use Maven POM syntax within that element. I guess this approach would require larger modifications, though, so I doubt that's a good idea for 2.0 at least.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Resolved: (IVY-974) Dependencies don't inherit exclusions from dependencyManagement

Posted by "Maarten Coene (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/IVY-974?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Maarten Coene resolved IVY-974.
-------------------------------

       Resolution: Fixed
    Fix Version/s: trunk
         Assignee: Maarten Coene

I've applied the patch to SVN trunk and added a junit test.
Thanks a lot for the contribution!

Maarten

> Dependencies don't inherit exclusions from dependencyManagement
> ---------------------------------------------------------------
>
>                 Key: IVY-974
>                 URL: https://issues.apache.org/jira/browse/IVY-974
>             Project: Ivy
>          Issue Type: Bug
>          Components: Maven Compatibility
>    Affects Versions: 2.0-RC2
>            Reporter: Martin von Gagern
>            Assignee: Maarten Coene
>             Fix For: trunk
>
>         Attachments: parent_dependency_mgt_excludes.patch, parent_dependency_mgt_excludes_2.patch, parent_dependency_mgt_excludes_3.patch
>
>
> In Maven 2, exclusions for a dependency can be given in the dependencyManagement element of an ancestor pom. These exclusions aren't correctly reproduced by Ivy.
> I have several projects here managed by Maven 2, and inheriting from a common ancestor. The pom of this ancestor includes the following fragment:
>  <dependencyManagement>
>   <dependencies>
>    <dependency>
>     <groupId>log4j</groupId><artifactId>log4j</artifactId><version>1.2.15</version>
>     <exclusions>
>      <exclusion><groupId>javax.mail</groupId><artifactId>mail</artifactId></exclusion>
>      <exclusion><groupId>javax.jms</groupId><artifactId>jms</artifactId></exclusion>
>      <exclusion><groupId>com.sun.jdmk</groupId><artifactId>jmxtools</artifactId></exclusion>
>      <exclusion><groupId>com.sun.jmx</groupId><artifactId>jmxri</artifactId></exclusion>
>     </exclusions>
>    </dependency>
>   </dependencies>
>  </dependencyManagement>
> So in any inheriting project I can simply depend on log4j and get the correct version without the listed dependencies. This is important as some of these dependencies cannot be resolved from the main Maven repository. They are in fact optional, but not listed as such in the log4j pom. It is also Maven practice to list such exclusions in the common ancestor instead of repeating them in every module depending on log4j.
> Ivy 2 doesn't reproduce this kind of inherited exclusions. When I have an ivy project depending on one of my projects, the modules are not excluded, resulting in download errors for obscure packages. Looking at the ivy descriptors in cache I find the missing exclusions.
> To fix this, PomDependencyMgtElement in PomReader.java would have to learn to look out for exclusions. This information could than be used by PomModuleDescriptorBuilder. More precisely, addDependencyMgt would have to store it with the desciptor, and addDependency could then incorporate in its inheritance calculations. The whole setup with extra information, with keys calculated using getDependencyMgtExtraInfoKeyFor* and values restricted to strings, seems ill suited to express the structure of the dependency management information. I would prefer the ivy.xml to contain a m2:dependencyManagement element, and use Maven POM syntax within that element. I guess this approach would require larger modifications, though, so I doubt that's a good idea for 2.0 at least.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (IVY-974) Dependencies don't inherit exclusions from dependencyManagement

Posted by "John Gibson (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/IVY-974?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

John Gibson updated IVY-974:
----------------------------

    Attachment: parent_dependency_mgt_excludes_3.patch

I did some experiments with the maven ant tasks, and it looks like the empty <exclusions> behaves as if it is not present.  So the current behavior is correct.  I simplified the code somewhat and fixed the improper indentation in this final version of the patch.


> Dependencies don't inherit exclusions from dependencyManagement
> ---------------------------------------------------------------
>
>                 Key: IVY-974
>                 URL: https://issues.apache.org/jira/browse/IVY-974
>             Project: Ivy
>          Issue Type: Bug
>          Components: Maven Compatibility
>    Affects Versions: 2.0-RC2
>            Reporter: Martin von Gagern
>         Attachments: parent_dependency_mgt_excludes.patch, parent_dependency_mgt_excludes_2.patch, parent_dependency_mgt_excludes_3.patch
>
>
> In Maven 2, exclusions for a dependency can be given in the dependencyManagement element of an ancestor pom. These exclusions aren't correctly reproduced by Ivy.
> I have several projects here managed by Maven 2, and inheriting from a common ancestor. The pom of this ancestor includes the following fragment:
>  <dependencyManagement>
>   <dependencies>
>    <dependency>
>     <groupId>log4j</groupId><artifactId>log4j</artifactId><version>1.2.15</version>
>     <exclusions>
>      <exclusion><groupId>javax.mail</groupId><artifactId>mail</artifactId></exclusion>
>      <exclusion><groupId>javax.jms</groupId><artifactId>jms</artifactId></exclusion>
>      <exclusion><groupId>com.sun.jdmk</groupId><artifactId>jmxtools</artifactId></exclusion>
>      <exclusion><groupId>com.sun.jmx</groupId><artifactId>jmxri</artifactId></exclusion>
>     </exclusions>
>    </dependency>
>   </dependencies>
>  </dependencyManagement>
> So in any inheriting project I can simply depend on log4j and get the correct version without the listed dependencies. This is important as some of these dependencies cannot be resolved from the main Maven repository. They are in fact optional, but not listed as such in the log4j pom. It is also Maven practice to list such exclusions in the common ancestor instead of repeating them in every module depending on log4j.
> Ivy 2 doesn't reproduce this kind of inherited exclusions. When I have an ivy project depending on one of my projects, the modules are not excluded, resulting in download errors for obscure packages. Looking at the ivy descriptors in cache I find the missing exclusions.
> To fix this, PomDependencyMgtElement in PomReader.java would have to learn to look out for exclusions. This information could than be used by PomModuleDescriptorBuilder. More precisely, addDependencyMgt would have to store it with the desciptor, and addDependency could then incorporate in its inheritance calculations. The whole setup with extra information, with keys calculated using getDependencyMgtExtraInfoKeyFor* and values restricted to strings, seems ill suited to express the structure of the dependency management information. I would prefer the ivy.xml to contain a m2:dependencyManagement element, and use Maven POM syntax within that element. I guess this approach would require larger modifications, though, so I doubt that's a good idea for 2.0 at least.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (IVY-974) Dependencies don't inherit exclusions from dependencyManagement

Posted by "John Gibson (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/IVY-974?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

John Gibson updated IVY-974:
----------------------------

    Attachment: parent_dependency_mgt_excludes_2.patch

I simplified the original patch.  Originally I separated the group and artifact of each exclusion into separate extraInfo entries to avoid having to delimit the group and artifact.  Then I realized that the keys were delimited themselves and used the same approach for the values.

> Dependencies don't inherit exclusions from dependencyManagement
> ---------------------------------------------------------------
>
>                 Key: IVY-974
>                 URL: https://issues.apache.org/jira/browse/IVY-974
>             Project: Ivy
>          Issue Type: Bug
>          Components: Maven Compatibility
>    Affects Versions: 2.0-RC2
>            Reporter: Martin von Gagern
>         Attachments: parent_dependency_mgt_excludes.patch, parent_dependency_mgt_excludes_2.patch
>
>
> In Maven 2, exclusions for a dependency can be given in the dependencyManagement element of an ancestor pom. These exclusions aren't correctly reproduced by Ivy.
> I have several projects here managed by Maven 2, and inheriting from a common ancestor. The pom of this ancestor includes the following fragment:
>  <dependencyManagement>
>   <dependencies>
>    <dependency>
>     <groupId>log4j</groupId><artifactId>log4j</artifactId><version>1.2.15</version>
>     <exclusions>
>      <exclusion><groupId>javax.mail</groupId><artifactId>mail</artifactId></exclusion>
>      <exclusion><groupId>javax.jms</groupId><artifactId>jms</artifactId></exclusion>
>      <exclusion><groupId>com.sun.jdmk</groupId><artifactId>jmxtools</artifactId></exclusion>
>      <exclusion><groupId>com.sun.jmx</groupId><artifactId>jmxri</artifactId></exclusion>
>     </exclusions>
>    </dependency>
>   </dependencies>
>  </dependencyManagement>
> So in any inheriting project I can simply depend on log4j and get the correct version without the listed dependencies. This is important as some of these dependencies cannot be resolved from the main Maven repository. They are in fact optional, but not listed as such in the log4j pom. It is also Maven practice to list such exclusions in the common ancestor instead of repeating them in every module depending on log4j.
> Ivy 2 doesn't reproduce this kind of inherited exclusions. When I have an ivy project depending on one of my projects, the modules are not excluded, resulting in download errors for obscure packages. Looking at the ivy descriptors in cache I find the missing exclusions.
> To fix this, PomDependencyMgtElement in PomReader.java would have to learn to look out for exclusions. This information could than be used by PomModuleDescriptorBuilder. More precisely, addDependencyMgt would have to store it with the desciptor, and addDependency could then incorporate in its inheritance calculations. The whole setup with extra information, with keys calculated using getDependencyMgtExtraInfoKeyFor* and values restricted to strings, seems ill suited to express the structure of the dependency management information. I would prefer the ivy.xml to contain a m2:dependencyManagement element, and use Maven POM syntax within that element. I guess this approach would require larger modifications, though, so I doubt that's a good idea for 2.0 at least.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (IVY-974) Dependencies don't inherit exclusions from dependencyManagement

Posted by "Maarten Coene (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/IVY-974?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Maarten Coene updated IVY-974:
------------------------------

    Fix Version/s:     (was: trunk)
                   2.0.1

> Dependencies don't inherit exclusions from dependencyManagement
> ---------------------------------------------------------------
>
>                 Key: IVY-974
>                 URL: https://issues.apache.org/jira/browse/IVY-974
>             Project: Ivy
>          Issue Type: Bug
>          Components: Maven Compatibility
>    Affects Versions: 2.0-RC2
>            Reporter: Martin von Gagern
>            Assignee: Maarten Coene
>             Fix For: 2.0.1
>
>         Attachments: parent_dependency_mgt_excludes.patch, parent_dependency_mgt_excludes_2.patch, parent_dependency_mgt_excludes_3.patch
>
>
> In Maven 2, exclusions for a dependency can be given in the dependencyManagement element of an ancestor pom. These exclusions aren't correctly reproduced by Ivy.
> I have several projects here managed by Maven 2, and inheriting from a common ancestor. The pom of this ancestor includes the following fragment:
>  <dependencyManagement>
>   <dependencies>
>    <dependency>
>     <groupId>log4j</groupId><artifactId>log4j</artifactId><version>1.2.15</version>
>     <exclusions>
>      <exclusion><groupId>javax.mail</groupId><artifactId>mail</artifactId></exclusion>
>      <exclusion><groupId>javax.jms</groupId><artifactId>jms</artifactId></exclusion>
>      <exclusion><groupId>com.sun.jdmk</groupId><artifactId>jmxtools</artifactId></exclusion>
>      <exclusion><groupId>com.sun.jmx</groupId><artifactId>jmxri</artifactId></exclusion>
>     </exclusions>
>    </dependency>
>   </dependencies>
>  </dependencyManagement>
> So in any inheriting project I can simply depend on log4j and get the correct version without the listed dependencies. This is important as some of these dependencies cannot be resolved from the main Maven repository. They are in fact optional, but not listed as such in the log4j pom. It is also Maven practice to list such exclusions in the common ancestor instead of repeating them in every module depending on log4j.
> Ivy 2 doesn't reproduce this kind of inherited exclusions. When I have an ivy project depending on one of my projects, the modules are not excluded, resulting in download errors for obscure packages. Looking at the ivy descriptors in cache I find the missing exclusions.
> To fix this, PomDependencyMgtElement in PomReader.java would have to learn to look out for exclusions. This information could than be used by PomModuleDescriptorBuilder. More precisely, addDependencyMgt would have to store it with the desciptor, and addDependency could then incorporate in its inheritance calculations. The whole setup with extra information, with keys calculated using getDependencyMgtExtraInfoKeyFor* and values restricted to strings, seems ill suited to express the structure of the dependency management information. I would prefer the ivy.xml to contain a m2:dependencyManagement element, and use Maven POM syntax within that element. I guess this approach would require larger modifications, though, so I doubt that's a good idea for 2.0 at least.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (IVY-974) Dependencies don't inherit exclusions from dependencyManagement

Posted by "Maarten Coene (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/IVY-974?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12676787#action_12676787 ] 

Maarten Coene commented on IVY-974:
-----------------------------------

John, thanks a lot for the patch!

Could you or someone else try out how maven behaves when the child POM also specifies such an <exclusion> element?
I think we should try to have the same behaviour as maven when we commit this patch.

Once we know we behave the same as maven and have a junit test for this, we can commit it (and maybe include it in the upcoming 2.0.1 release if we are quick)

> Dependencies don't inherit exclusions from dependencyManagement
> ---------------------------------------------------------------
>
>                 Key: IVY-974
>                 URL: https://issues.apache.org/jira/browse/IVY-974
>             Project: Ivy
>          Issue Type: Bug
>          Components: Maven Compatibility
>    Affects Versions: 2.0-RC2
>            Reporter: Martin von Gagern
>         Attachments: parent_dependency_mgt_excludes.patch, parent_dependency_mgt_excludes_2.patch
>
>
> In Maven 2, exclusions for a dependency can be given in the dependencyManagement element of an ancestor pom. These exclusions aren't correctly reproduced by Ivy.
> I have several projects here managed by Maven 2, and inheriting from a common ancestor. The pom of this ancestor includes the following fragment:
>  <dependencyManagement>
>   <dependencies>
>    <dependency>
>     <groupId>log4j</groupId><artifactId>log4j</artifactId><version>1.2.15</version>
>     <exclusions>
>      <exclusion><groupId>javax.mail</groupId><artifactId>mail</artifactId></exclusion>
>      <exclusion><groupId>javax.jms</groupId><artifactId>jms</artifactId></exclusion>
>      <exclusion><groupId>com.sun.jdmk</groupId><artifactId>jmxtools</artifactId></exclusion>
>      <exclusion><groupId>com.sun.jmx</groupId><artifactId>jmxri</artifactId></exclusion>
>     </exclusions>
>    </dependency>
>   </dependencies>
>  </dependencyManagement>
> So in any inheriting project I can simply depend on log4j and get the correct version without the listed dependencies. This is important as some of these dependencies cannot be resolved from the main Maven repository. They are in fact optional, but not listed as such in the log4j pom. It is also Maven practice to list such exclusions in the common ancestor instead of repeating them in every module depending on log4j.
> Ivy 2 doesn't reproduce this kind of inherited exclusions. When I have an ivy project depending on one of my projects, the modules are not excluded, resulting in download errors for obscure packages. Looking at the ivy descriptors in cache I find the missing exclusions.
> To fix this, PomDependencyMgtElement in PomReader.java would have to learn to look out for exclusions. This information could than be used by PomModuleDescriptorBuilder. More precisely, addDependencyMgt would have to store it with the desciptor, and addDependency could then incorporate in its inheritance calculations. The whole setup with extra information, with keys calculated using getDependencyMgtExtraInfoKeyFor* and values restricted to strings, seems ill suited to express the structure of the dependency management information. I would prefer the ivy.xml to contain a m2:dependencyManagement element, and use Maven POM syntax within that element. I guess this approach would require larger modifications, though, so I doubt that's a good idea for 2.0 at least.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.