Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dependencies inside of the JAR file #98

Open
hasys opened this issue Sep 23, 2021 · 2 comments
Open

Dependencies inside of the JAR file #98

hasys opened this issue Sep 23, 2021 · 2 comments

Comments

@hasys
Copy link
Contributor

hasys commented Sep 23, 2021

Compilation in my application failing due to duplicate classes including duplication inside of the mapper-xml dependencies as well, for an instance:

  Found in:
    org.treblereel.gwt.xml.mapper:api:jar:0.5-SNAPSHOT:compile
    org.treblereel.gwt.xml.mapper:common:jar:0.5-SNAPSHOT:compile
    org.treblereel.gwt.xml.mapper:processor:jar:0.5-SNAPSHOT:compile
  Duplicate classes:
    org/treblereel/gwt/xml/mapper/api/exception/XMLSerializationException.class
    org/treblereel/gwt/xml/mapper/api/deser/bean/MapLike.class
    org/treblereel/gwt/xml/mapper/api/exception/XMLDeserializationException.class
    org/treblereel/gwt/xml/mapper/api/exception/XMLMappingException.class
    org/treblereel/gwt/xml/mapper/api/deser/bean/Instance.class

Looks like it is not possible to exclude duplicated dependencies because dependencies are included in the JAR files itself:
image

Some modules have classes with same name:

  Found in:
    org.treblereel.gwt.xml.mapper:jre-backend:jar:0.5-SNAPSHOT:test
    org.treblereel.gwt.xml.mapper:gwt-backend:jar:0.5-SNAPSHOT:compile
  Duplicate classes:
    org/treblereel/gwt/xml/mapper/api/DefaultXMLDeserializationContext$Builder.class
    org/treblereel/gwt/xml/mapper/api/DefaultXMLDeserializationContext$1.class
    org/treblereel/gwt/xml/mapper/api/DefaultXMLSerializationContext$DefaultBuilder.class
    org/treblereel/gwt/xml/mapper/api/DefaultXMLSerializationContext$Builder.class
    org/treblereel/gwt/xml/mapper/api/DefaultXMLSerializationContext$1.class
    org/treblereel/gwt/xml/mapper/api/DefaultXMLSerializationContext.class
    org/treblereel/gwt/xml/mapper/api/DefaultXMLDeserializationContext$DefaultBuilder.class
    org/treblereel/gwt/xml/mapper/api/AbstractObjectMapper.class
    org/treblereel/gwt/xml/mapper/api/DefaultXMLDeserializationContext.class

I can use -Denforcer.skip=true due to work, but issues should be fixed before push to production.

Is it possible to split dependencies from JAR files and have different names/packages for classes in different mapper-xml modules or it is some design requirement?

Thank you @treblereel!

@hasys
Copy link
Contributor Author

hasys commented Sep 23, 2021

All messages about duplication in my app (I cut duplicated from long lists as google.guava):

[WARNING] Rule 0: org.apache.maven.plugins.enforcer.BanDuplicateClasses failed with message:
Duplicate classes found:

  Found in:
    org.treblereel.gwt.xml.mapper:processor:jar:0.5-SNAPSHOT:compile
    com.google.jsinterop:jsinterop-annotations:jar:2.0.0:compile
  Duplicate classes:
    jsinterop/annotations/JsType.class
    jsinterop/annotations/JsMethod.class
    jsinterop/annotations/JsProperty.class
    jsinterop/annotations/JsFunction.class
    jsinterop/annotations/JsOverlay.class

  Found in:
    org.treblereel.gwt.xml.mapper:common:jar:0.5-SNAPSHOT:compile
    org.treblereel.gwt.xml.mapper:processor:jar:0.5-SNAPSHOT:compile
  Duplicate classes:
    org/treblereel/gwt/xml/mapper/api/MapperContext.class
    org/treblereel/gwt/xml/mapper/api/deser/bean/HasDeserializer.class
    org/treblereel/gwt/xml/mapper/api/DefaultXMLDeserializerParameters.class
    org/treblereel/gwt/xml/mapper/api/utils/Pair.class
    org/treblereel/gwt/xml/mapper/api/PropertyType.class
    org/treblereel/gwt/xml/mapper/api/stream/XMLIterator$Scanner.class
    org/treblereel/gwt/xml/mapper/api/Inheritance.class
    org/treblereel/gwt/xml/mapper/api/MapperContext$StringArrayReader.class
    org/treblereel/gwt/xml/mapper/api/utils/NumberUtils.class
    org/treblereel/gwt/xml/mapper/api/stream/XMLIterator.class
    org/treblereel/gwt/xml/mapper/api/deser/bean/HasDeserializerAndParameters.class
    java/util/UUID.class
   [...]


  Found in:
    org.treblereel.gwt.xml.mapper:processor:jar:0.5-SNAPSHOT:compile
    com.google.jsinterop:base:jar:1.0.0:compile
  Duplicate classes:
    jsinterop/base/JsConstructorFn.class
    jsinterop/base/Any.class
    jsinterop/base/Js.class
    jsinterop/base/JsArrayLike.class
    jsinterop/base/InternalJsUtil.class
    jsinterop/base/JsPropertyMap.class
    jsinterop/base/JsForEachCallbackFn.class
    jsinterop/base/InternalPreconditions.class

  Found in:
    org.treblereel.gwt.xml.mapper:common:jar:0.5-SNAPSHOT:compile
    xml-apis:xml-apis:jar:1.4.01:test
  Duplicate classes:
    org/w3c/dom/Element.class
    javax/xml/stream/XMLStreamConstants.class
    javax/xml/XMLConstants.class

  Found in:
    org.treblereel.gwt.xml.mapper:processor:jar:0.5-SNAPSHOT:compile
    org.apache.commons:commons-lang3:jar:3.9:compile
  Duplicate classes:
    org/apache/commons/lang3/ArrayUtils.class
    org/apache/commons/lang3/text/StrTokenizer.class
    org/apache/commons/lang3/text/translate/LookupTranslator.class
    org/apache/commons/lang3/builder/EqualsBuilder.class
    org/apache/commons/lang3/BooleanUtils.class
    org/apache/commons/lang3/mutable/MutableObject.class
   [...]

  Found in:
    org.treblereel.gwt.xml.mapper:common:jar:0.5-SNAPSHOT:compile
    org.treblereel.gwt.xml.mapper:processor:jar:0.5-SNAPSHOT:compile
    xml-apis:xml-apis:jar:1.4.01:test
  Duplicate classes:
    javax/xml/stream/XMLStreamException.class
    javax/xml/stream/Location.class
    javax/xml/namespace/QName.class

  Found in:
    com.google.elemental2:elemental2-core:jar:1.1.0:compile
    org.treblereel.gwt.xml.mapper:processor:jar:0.5-SNAPSHOT:compile
  Duplicate classes:
    elemental2/core/JsArray$SortCompareFn.class
    elemental2/core/Function.class
    elemental2/core/JsObject$EntriesArrayArrayUnionType.class
    elemental2/core/JsObject$DefinePropertyPropUnionType.class
    elemental2/core/JsArray$FromMapFn.class
    elemental2/core/JsObject.class
    [...]

  Found in:
    org.treblereel.gwt.xml.mapper:jre-backend:jar:0.5-SNAPSHOT:test
    org.treblereel.gwt.xml.mapper:gwt-backend:jar:0.5-SNAPSHOT:compile
  Duplicate classes:
    org/treblereel/gwt/xml/mapper/api/DefaultXMLDeserializationContext$Builder.class
    org/treblereel/gwt/xml/mapper/api/DefaultXMLDeserializationContext$1.class
    org/treblereel/gwt/xml/mapper/api/DefaultXMLSerializationContext$DefaultBuilder.class
    org/treblereel/gwt/xml/mapper/api/DefaultXMLSerializationContext$Builder.class
    org/treblereel/gwt/xml/mapper/api/DefaultXMLSerializationContext$1.class
    org/treblereel/gwt/xml/mapper/api/DefaultXMLSerializationContext.class
    org/treblereel/gwt/xml/mapper/api/DefaultXMLDeserializationContext$DefaultBuilder.class
    org/treblereel/gwt/xml/mapper/api/AbstractObjectMapper.class
    org/treblereel/gwt/xml/mapper/api/DefaultXMLDeserializationContext.class

  Found in:
    org.treblereel.gwt.xml.mapper:api:jar:0.5-SNAPSHOT:compile
    org.treblereel.gwt.xml.mapper:common:jar:0.5-SNAPSHOT:compile
    org.treblereel.gwt.xml.mapper:processor:jar:0.5-SNAPSHOT:compile
  Duplicate classes:
    org/treblereel/gwt/xml/mapper/api/exception/XMLSerializationException.class
    org/treblereel/gwt/xml/mapper/api/deser/bean/MapLike.class
    org/treblereel/gwt/xml/mapper/api/exception/XMLDeserializationException.class
    org/treblereel/gwt/xml/mapper/api/exception/XMLMappingException.class
    org/treblereel/gwt/xml/mapper/api/deser/bean/Instance.class

  Found in:
    org.treblereel.gwt.xml.mapper:processor:jar:0.5-SNAPSHOT:compile
    com.google.errorprone:error_prone_annotations:jar:2.3.4:compile
  Duplicate classes:
    com/google/errorprone/annotations/concurrent/LazyInit.class
    com/google/errorprone/annotations/CompatibleWith.class
    com/google/errorprone/annotations/IncompatibleModifiers.class
    com/google/errorprone/annotations/DoNotCall.class
    com/google/errorprone/annotations/DoNotMock.class
    com/google/errorprone/annotations/ForOverride.class
    com/google/errorprone/annotations/concurrent/GuardedBy.class
    com/google/errorprone/annotations/CanIgnoreReturnValue.class

  Found in:
    org.treblereel.gwt.xml.mapper:processor:jar:0.5-SNAPSHOT:compile
    com.google.j2objc:j2objc-annotations:jar:1.3:compile
  Duplicate classes:
    com/google/j2objc/annotations/Weak.class
    com/google/j2objc/annotations/RetainedWith.class

  Found in:
    org.treblereel.gwt.xml.mapper:processor:jar:0.5-SNAPSHOT:compile
    com.google.guava:guava:jar:30.1-jre:compile
  Duplicate classes:
    com/google/common/collect/ImmutableMapValues$1.class
    com/google/common/math/package-info.class
    com/google/common/collect/AbstractNavigableMap.class
    com/google/common/collect/Synchronized$SynchronizedTable.class
    com/google/common/collect/Count.class
    [...]

  Found in:
    org.treblereel.gwt.xml.mapper:processor:jar:0.5-SNAPSHOT:compile
    org.checkerframework:checker-qual:jar:3.5.0:compile
  Duplicate classes:
    org/checkerframework/framework/qual/DefaultQualifierInHierarchy.class
    org/checkerframework/framework/qual/SubtypeOf.class
    [...]

  Found in:
    org.treblereel.gwt.xml.mapper:common:jar:0.5-SNAPSHOT:compile
    org.jboss.spec.javax.xml.bind:jboss-jaxb-api_2.3_spec:jar:1.0.1.Final:test
  Duplicate classes:
    javax/xml/bind/annotation/XmlMixed.class
    javax/xml/bind/annotation/DomHandler.class
    [..]

  Found in:
    org.treblereel.gwt.xml.mapper:api:jar:0.5-SNAPSHOT:compile
    org.treblereel.gwt.xml.mapper:processor:jar:0.5-SNAPSHOT:compile
  Duplicate classes:
    org/treblereel/gwt/xml/mapper/api/deser/collection/LinkedHashSetXMLDeserializer.class
    org/treblereel/gwt/xml/mapper/api/ser/BaseNumberXMLSerializer$IntegerXMLSerializer.class
    org/treblereel/gwt/xml/mapper/api/deser/collection/BaseCollectionXMLDeserializer.class
    org/treblereel/gwt/xml/mapper/api/deser/array/PrimitiveCharacterArrayXMLDeserializer.class
    [...]

  Found in:
    org.treblereel.gwt.xml.mapper:common:jar:0.5-SNAPSHOT:compile
    org.treblereel.gwt.xml.mapper:processor:jar:0.5-SNAPSHOT:compile
    org.jboss.spec.javax.xml.bind:jboss-jaxb-api_2.3_spec:jar:1.0.1.Final:test
  Duplicate classes:
    javax/xml/bind/annotation/XmlElement$DEFAULT.class
    javax/xml/bind/annotation/XmlElements.class
    javax/xml/bind/annotation/XmlEnumValue.class
    javax/xml/bind/annotation/XmlElementWrapper.class
    [...]

@treblereel
Copy link
Owner

treblereel commented Sep 23, 2021

@hasys thank you for your interest !

Processor is a shaded module and it contains all deps it needs, some of them could be presented in your application, but shading is nessesary for j2cl-m-p.

As for backend/frontend, yes, they contain classes with the same names, but for different envs. Maybe it could be replaced with ServiceLoader, i need to think about it.

For now, the best option is to exclude mapper deps from your maven-enforcer-plugin at , if i remember correctly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants