gephi / gephi-plugins

Repository for Gephi Plugins maintained by the team. Each plugin has it's branch.
270 stars 623 forks source link

maven dependence conflict with core-library-wrapper #115

Closed songjinghe closed 2 years ago

songjinghe commented 8 years ago

I was developing a preview plugin, my dependencies contains:

        <dependency>
            <groupId>org.gephi</groupId>
            <artifactId>preview-api</artifactId>
        </dependency>
        <dependency>
            <groupId>org.gephi</groupId>
            <artifactId>core-library-wrapper</artifactId>
        </dependency>

but the org.gephi:core-library-wrapper reference to com.google.collections:google-collections:1.0, while my plugin heavily depend on com.google.guava:guava:18.0. guava can be seen as an new version of com.google.collections:google-collections:1.0 because they the same class name and path( say, /com/google/common/base/SomeClassWithSameName ). So when I debug my plugin, it crashs because it seems it is using classes from google-collections, not guava.

I wonder if this would be solved, and how? Any tips maught be helpfull.

eduramiba commented 8 years ago

Hi, this might work, try to set your dependency like this:

<dependency>
    <groupId>org.gephi</groupId>
    <artifactId>core-library-wrapper</artifactId>
    <exclusions>
        <exclusion>
            <groupId>om.google.collections</groupId>
            <artifactId>google-collections</artifactId>
        </exclusion>
    </exclusions> 
</dependency>
songjinghe commented 8 years ago

@eduramiba thanks, I've tried it, but it doesn't work. I think it's because core-library is a vitual package ( it doesn't appear in the finally generated nbm file, here's part of maven package output)

[INFO] --- nbm-maven-plugin:3.14:manifest (default-manifest) @ gephi-plugin-tgraph-demo ---
[INFO] NBM Plugin generates manifest
[INFO] Adding on module's Class-Path:
[INFO]     org.act:neo4j-temporal-demo:jar:2.2.3-SNAPSHOT
[INFO]     org.neo4j:neo4j-kernel:jar:2.2.3-SNAPSHOT
[INFO]     org.neo4j:neo4j-primitive-collections:jar:2.2.3-SNAPSHOT
[INFO]     org.neo4j:neo4j-unsafe:jar:2.2.3-SNAPSHOT
[INFO]     org.neo4j:neo4j-io:jar:2.2.3-SNAPSHOT
[INFO]     org.neo4j:neo4j-csv:jar:2.2.3-SNAPSHOT
[INFO]     org.act:temporal-graph:jar:0.2.1-SNAPSHOT
[INFO]     com.google.guava:guava:jar:18.0
[INFO]     org.neo4j:neo4j-lucene-index:jar:2.2.3-SNAPSHOT
[INFO]     org.apache.lucene:lucene-core:jar:3.6.2
[INFO]     org.neo4j:neo4j-graphviz:jar:2.2.3-SNAPSHOT
[INFO]     org.slf4j:slf4j-log4j12:jar:1.7.9
[INFO]     org.slf4j:slf4j-api:jar:1.7.9
[INFO]     log4j:log4j:jar:1.2.17
[INFO] 

and I think core-library-wrapper provider access to google-collections through netbeans module mechanism at runtime. I wonder the only way to avoid this is to NOT include core-library-wrapper? However, if I do not include core-library-wrapper as dependency, it throw an error when package:

[INFO] --- nbm-maven-plugin:3.14:manifest (default-manifest) @ gephi-plugin-tgraph-demo ---
[INFO] NBM Plugin generates manifest
[INFO] Adding on module's Class-Path:
[INFO]     org.act:neo4j-temporal-demo:jar:2.2.3-SNAPSHOT
[INFO]     org.neo4j:neo4j-kernel:jar:2.2.3-SNAPSHOT
[INFO]     org.neo4j:neo4j-primitive-collections:jar:2.2.3-SNAPSHOT
[INFO]     org.neo4j:neo4j-unsafe:jar:2.2.3-SNAPSHOT
[INFO]     org.neo4j:neo4j-io:jar:2.2.3-SNAPSHOT
[INFO]     org.neo4j:neo4j-csv:jar:2.2.3-SNAPSHOT
[INFO]     org.act:temporal-graph:jar:0.2.1-SNAPSHOT
[INFO]     org.neo4j:neo4j-lucene-index:jar:2.2.3-SNAPSHOT
[INFO]     org.apache.lucene:lucene-core:jar:3.6.2
[INFO]     org.neo4j:neo4j-graphviz:jar:2.2.3-SNAPSHOT
[INFO]     org.slf4j:slf4j-log4j12:jar:1.7.9
[INFO]     org.slf4j:slf4j-api:jar:1.7.9
[INFO]     log4j:log4j:jar:1.2.17
[INFO]     com.google.guava:guava:jar:18.0
[ERROR] Project uses classes from transitive module org.gephi:core-library-wrapper:jar:0.9.1 which will not be accessible at runtime.
[INFO]     To fix the problem, add this module as direct dependency. For OSGi bundles that are supposed to be wrapped in NetBeans modules, use the useOSGiDependencies=false parameter
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO] 
[INFO] TGraph Demo ........................................ FAILURE [  4.897 s]
[INFO] gephi-plugins ...................................... SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 5.409 s
[INFO] Finished at: 2016-05-29T21:15:57+08:00
[INFO] Final Memory: 30M/441M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.codehaus.mojo:nbm-maven-plugin:3.14:manifest (default-manifest) on project gephi-plugin-tgraph-demo: See above for failures in runtime NetBeans dependencies verification. -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
eduramiba commented 8 years ago

Right, probably one of your dependencies uses something from core library wrapper and you have to include it. We probably should update Gephi to use Guava instead of the old google collections, I think it's not heavily used in Gephi anyway.

songjinghe commented 8 years ago

My problem disappeared if I modify my code NOT to use classes org.apache.batik.ext.awt.g2d.DefaultGraphics2D which is provide by core-library-wrapper(eg. my plugin project don't denpend on core-library-wrapper any more). Then there's no conflict. But this problem may still remains for those whose dependencies conflict with core-library-wrapper.

I think the best way to solve this is to tell netbeans module manager/container's classes loader to first search the module's local dependencies, then classes provided by other modules. Is there any way to do this?

eduramiba commented 8 years ago

I searched a bit before and I am not sure that is possible unfortunately.

songjinghe commented 8 years ago

So, there is nothing we can do about it, and I should mark it as CLOSED ?

eduramiba commented 8 years ago

Maybe we can leave it open so I remember to update google collections to guava.

songjinghe commented 8 years ago

OK~

mbastian commented 2 years ago

Thanks for the report. I (finally) created a ticket in Gephi so we can fix this. I'll close this one as no workaround could be found. There might be a way to hack Netbeans dependencies to do this but probably not from a plugin.