JavaMoney / jsr354-ri

JSR 354 - Moneta: Reference Implementation
Other
344 stars 101 forks source link

overlappping classes #316

Closed jjaimez closed 5 years ago

jjaimez commented 5 years ago

Hello, I found that there are overlapping classes, this is a problem when you want to create a single jar, because only one single version of the class is copied into the jar. Then when you execute the flowing code an error rise: Invalid ExchangeRateProvider (not found): ECB


 ExchangeRateProvider rateProvider = MonetaryConversions.getExchangeRateProvider("ECB", "IMF");
CurrencyConversion conversion = rateProvider.getCurrencyConversion(currency);
MonetaryAmount convertedAmount = fromMoney.with(conversion);

It happens with all providers.

A solution is create a jar with a lib folder like this https://stackoverflow.com/questions/55533164/moneta-1-3-exchangerateprovider-getexchangeratebase-term-returns-null

overlapping details:

moneta-convert-imf-1.3.jar, moneta-convert-ecb-1.3.jar, money-api-1.0.3.jar, moneta-core-1.3.jar, moneta-convert-1.3.jar define 1 overlapping classes

+- org.javamoney:moneta:pom:1.3:compile | +- org.javamoney.moneta:moneta-core:jar:1.3:compile | | +- (javax.money:money-api:jar:1.0.3:compile - omitted for duplicate) | | - (javax.annotation:javax.annotation-api:jar:1.3.2:compile - omitted for duplicate) | +- org.javamoney.moneta:moneta-convert:jar:1.3:compile | | +- (org.javamoney.moneta:moneta-core:jar:1.3:compile - omitted for duplicate) | | +- (javax.money:money-api:jar:1.0.3:compile - omitted for duplicate) | | - (javax.annotation:javax.annotation-api:jar:1.3.2:compile - omitted for duplicate) | +- org.javamoney.moneta:moneta-convert-imf:jar:1.3:compile | | +- (org.javamoney.moneta:moneta-core:jar:1.3:compile - omitted for duplicate) | | +- (org.javamoney.moneta:moneta-convert:jar:1.3:compile - omitted for duplicate) | | +- (javax.money:money-api:jar:1.0.3:compile - omitted for duplicate) | | - (javax.annotation:javax.annotation-api:jar:1.3.2:compile - omitted for duplicate) | +- org.javamoney.moneta:moneta-convert-ecb:jar:1.3:compile | | +- (org.javamoney.moneta:moneta-core:jar:1.3:compile - omitted for duplicate) | | +- (org.javamoney.moneta:moneta-convert:jar:1.3:compile - omitted for duplicate) | | +- (javax.money:money-api:jar:1.0.3:compile - omitted for duplicate) | | - (javax.annotation:javax.annotation-api:jar:1.3.2:compile - omitted for duplicate) | +- javax.money:money-api:jar:1.0.3:compile | - javax.annotation:javax.annotation-api:jar:1.3.2:compile

        <dependency>
            <groupId>org.javamoney</groupId>
            <artifactId>moneta</artifactId>
            <version>1.3</version>
            <type>pom</type>
        </dependency>
keilw commented 5 years ago

Hi, Why would you want to create a single JAR? The whole idea of modularization also following what the JDK did (although it has some strange giant modules file of over 100 MB, the 71 jmods for each module show, how many small modules exist there now) is the way forward. The only case I could imagine would be a "Fat JAR" or "Fat WAR" with containers like Spring Boot. The console output does not say anything about classes defined in Moneta, it only mentions direct or indirect dependencies like Money API or Java/Jakarta Annotations, that is normal. Or can you state a class that would really be redundant in Moneta Core and the sub-modules?

jjaimez commented 5 years ago

Fat JAR was the case. I resolved it creating a lib folder.

keilw commented 5 years ago

That is sort of what our Spring Boot packagers in a client project also do. Thanks for confirming, so we can close this.