Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting IntelliJ to import shaded dependencies in a multi-module maven project

I have two modules, Component and Application. The Component module is shaded due to a dependency conflict (google protocol buffers) later in the build process.

<!-- snip from Component's pom.xml -->
<plugin>
     <groupId>org.apache.maven.plugins</groupId>
     <artifactId>maven-shade-plugin</artifactId>
     <version>2.3</version>
     <configuration>
         <relocations>
             <relocation>
                 <pattern>com.google.protobuf</pattern>                                
                 <shadedPattern>my.package.protocols.shaded.com.google.protobuf</shadedPattern>
             </relocation>
         </relocations>
     </configuration>
     <executions>
         <execution>
             <phase>package</phase>
             <goals>
                 <goal>shade</goal>
             </goals>
         </execution>
    </executions>
</plugin> 

The Application depends on the Component module. However, source files in the Application cannot reference the shaded library that the Component depends on. This is critical for interacting with the Component.

     <-- snip from Application's pom.xml -->   
     <dependency>
          <groupId>my-group</groupId>
          <artifactId>component</artifactId>
          <version>${project.version}</version>
     </dependency>

Even though the import can't be found by IntelliJ, the Maven build works fine. What am I missing/doing-wrong?

like image 661
Andrew White Avatar asked May 22 '15 23:05

Andrew White


1 Answers

Too bad, after opening a ticket with JetBrains, this problem has been previously reported and is currently not supported in IntelliJ.

  • https://youtrack.jetbrains.com/issue/IDEA-126596
  • https://youtrack.jetbrains.com/issue/IDEA-93855
like image 130
Jane Wayne Avatar answered Oct 05 '22 19:10

Jane Wayne