GitHub user aprelev opened a pull request:

    https://github.com/apache/ant-ivy/pull/73

    Enable XML report parser to produce qualified extra attributes

    ### Issue
    `${ivy.deps.changed}` is always `true` for dependencies with extra 
attributes.
    
    ### Problem
    `XmlReportParser::startElement()` creates revision IDs [as 
follows](https://github.com/apache/ant-ivy/blob/5918182e0d6836d89c42260da9de4428d4cbcec0/src/java/org/apache/ivy/plugins/report/XmlReportParser.java#L96):
    ```Java
    mrid = ModuleRevisionId.newInstance(organisation, module, branch, revision,
        ExtendableItemHelper.getExtraAttributes(attributes, "extra-"));
    ```
    Here, `ExtendableItemHelper::getExtraAttributes()` method returns 
*unqualified* attributes of previously resolved dependencies, which are then 
compared with *qualified* attributes of currently resolved dependencies in 
`ConfigurationResolveReport::checkIfChanged()` [as 
follows](https://github.com/apache/ant-ivy/blob/5918182e0d6836d89c42260da9de4428d4cbcec0/src/java/org/apache/ivy/core/report/ConfigurationResolveReport.java#L101):
    ```Java
    Set<ModuleRevisionId> previousDepSet = new HashSet<>(
        Arrays.asList(parser.getDependencyRevisionIds()));
    hasChanged = !previousDepSet.equals(getModuleRevisionIds());
    ```
    which effectively renders sets of dependecies *unequal*.
    
    ### Solutions
    One solution would be to compare unqualified attributes when [testing 
revision IDs for 
equality](https://github.com/apache/ant-ivy/blob/5918182e0d6836d89c42260da9de4428d4cbcec0/src/java/org/apache/ivy/core/module/id/ModuleRevisionId.java#L237);
 another one would be to [produce qualified 
attributes](https://github.com/aprelev/ant-ivy/blob/1d508c14bbc68411b9b215f2e4e552fe20d3ae1a/src/java/org/apache/ivy/util/extendable/ExtendableItemHelper.java#L37)
 when parsing XML report.
    I've implemented second solution (it seemed cleaner to me), and included 
unit-test to demonstrate the issue. 

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/aprelev/ant-ivy master

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/ant-ivy/pull/73.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #73
    
----
commit 1d508c14bbc68411b9b215f2e4e552fe20d3ae1a
Author: aprelev <arseny.aprelev@...>
Date:   2018-07-31T14:15:26Z

    Enable XML report parser to produce qualified extra attributes

----


---

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@ant.apache.org
For additional commands, e-mail: dev-h...@ant.apache.org

Reply via email to