Thrift IDL and Maven don't work well together in IDEA

Using IDEA X. In a Maven project, I have a structure as the following:
[/Volumes/source/cirrus/jammer]$ tree

.
|____.git
| |____COMMIT_EDITMSG
| |____config
| |____description
| |____HEAD
| |____hooks
| |____index
| |____info
| |____logs
| |____MERGE_RR
| |____objects
| |____ORIG_HEAD
| |____packed-refs
| |____refs
| |____rr-cache
| |____svn
|____.gitignore
|____idl
| |____.gitignore
| |____cpp
| | |____.options.cache.darwin
| | |____.scons-signatures.dblite
| | |____pom.xml
| | |____SConscript
| | |____SConstruct
| |____java
| | |____pom.xml
| |____pom.xml
| |____py
| | |____build
| | | |____lib
| | | | |____cirrus
| | | | | |______init__.py
| | | | | |____idl
| | | | | | |______init__.py
| | | | | | |____jammer
| | | | | | | |______init__.py
| | | | | | | |____agent
| | | | | | | | |______init__.py
| | | | | | | | |____Agent.py
| | | | | | | | |____constants.py
| | | | | | | | |____ttypes.py
| | |____pom.xml
| | |____setup.py
| |____thrift_gen
| | |____.options.cache.darwin
| | |____.scons-signatures.dblite
| | |____pom.xml
| | |____SConscript
| | |____SConstruct
| | |____src
| | | |____Agent.thrift
|____jammer
| |____pom.xml
| |____src
| | |____main
| | | |____java
| | | | |____net
| | | | | |____digby
| | | | | | |____cirrus
| | | | | | | |____jammer
| | | | | | | | |____agent
| | | | | | | | | |____AgentHandler.java
| | | | | | | | | |____AgentServer.java
| | | | | | | | |____common
| | | | | | | | | |____JammerProps.java
| | | | | | | | | |____JedisCounterWrapper.java
| | | | | | | | |____console
| | | | | | | | | |____Console.java
| | | | | | | | |____worker
| | | | | | | | | |____Worker.java
| | |____test
| | | |____java
| | | | |____net
| | | | | |____digby
| | | | | | |____cirrus
| | | | | | | |____jammer
| | | | | | | | |____test
| | | | | | | | | |____LifecycleTest.java
| | | | | | | | | |____TestWorker.java
| | | |____resources
| | | | |____LifecycleTest.properties
| | | | |____log4j.properties
|____pom.xml

The IDL folder contains a Thrift file called Agent.thrift. All other folders are used for generation of the Thrift source into various languages.

Jammer is the the Java source. Even though I am referencing the depenency in the dependencies section of Maven:
<dependency>
            <groupId>net.digby.cirrus.services.jammer</groupId>
            <artifactId>jammer-idl-java</artifactId>
            <type>bundle</type>
        </dependency>

the import (import net.digby.cirrus.idl.jammer.agent.Agent;) will still be red, where IDEA states that it cannot find the package. The package is built and in my repository:

[~/.m2/repository/net/digby/cirrus/services/jammer/jammer-idl-java/1.0.0-SNAPSHOT]$ ls
total 192
drwxr-xr-x  7 mikeho  staff    238 Mar 24 09:18 ./
drwxr-xr-x  4 mikeho  staff    136 Mar 24 09:18 ../
-rw-r--r--  1 mikeho  staff    245 Mar 24 09:18 _maven.repositories
-rw-r--r--  1 mikeho  staff   8201 Mar 24 09:18 jammer-idl-java-1.0.0-SNAPSHOT-sources.jar
-rw-r--r--  1 mikeho  staff  70259 Mar 24 09:18 jammer-idl-java-1.0.0-SNAPSHOT.jar
-rw-r--r--  1 mikeho  staff   2571 Mar 23 12:24 jammer-idl-java-1.0.0-SNAPSHOT.pom
-rw-r--r--  1 mikeho  staff    938 Mar 24 09:18 maven-metadata-local.xml

If the IDL exists outside as a separate maven project, then it works fine, but not when it's integrated. For reasons including keeping relevant sources together, I cannot move the IDL out (everyone else on my team is using Eclipse and doesn't have this problem).

I'm suspecting that either IDEA can't handle Thrift or dependencies of type bundle. We're using the maven-bundle-plugin which wraps these modules into OSGi bundles.

<build>
        <plugins>
            <plugin>
                <groupId>org.apache.felix</groupId>
                <artifactId>maven-bundle-plugin</artifactId>
                <extensions>true</extensions>
            </plugin>
        </plugins>
    </build>

Anyone have any thoughts? Can this be fixed in 10.0.3? It's prevent me from working effectively. I've also been trying to promote IDEA as a replacement to Eclipse, but it's things like these (and Eclipse will eventually have built-in Maven support) that others from being willing to try.

1 comment
Comment actions Permalink

I found a quick solution and something I wish it would do directly; I added a new library and pointed the Classes and Sources to the respective generated versions by Maven. This removed all my red highlights and fixed the issue. But how come it can't be seen automatically? Is it because Thrift Java classes are auto-generated and don't exist as actual Java sources?

0

Please sign in to leave a comment.