pan3793 edited a comment on issue #1131:
URL: 
https://github.com/apache/incubator-kyuubi/issues/1131#issuecomment-943163597


   I find some clues after investigation.
   
   It's a long-standing bug of IDEA over 9 years, see 
https://youtrack.jetbrains.com/issue/IDEA-93855.
   
   If the module `b` depends on the module `a`, `mvn` will add packaged jar of 
`a` to its classpath, but IDEA always adds `a/target/classes` instead of jar, 
that why IDEA always see unrelocated classes.
   
   We can use `build-helper-maven-plugin` to make IDEA see packaged jar in the 
classpath, but the `a/target/classes` always be included and has a high 
priority.
   
   ```
   <!--
     This is to ensure references to shaded Hive classes can be resolved in 
IDEs such as Intellij.
     For reference: https://youtrack.jetbrains.com/issue/IDEA-126596
     -->
   <plugin>
       <groupId>org.codehaus.mojo</groupId>
       <artifactId>build-helper-maven-plugin</artifactId>
       <executions>
           <execution>
               <id>compile</id>
               <phase>package</phase>
               <goals>
                   <goal>attach-artifact</goal>
               </goals>
               <configuration>
                   <artifacts>
                       <artifact>
                           
<file>${basedir}/target/${project.artifactId}-${project.version}.jar</file>
                           <type>jar</type>
                           <classifier>optional</classifier>
                       </artifact>
                   </artifacts>
               </configuration>
           </execution>
       </executions>
   </plugin>
   ```
   
   ```
   
/Users/chengpan/.sdkman/candidates/java/8.0.272.fx-zulu/zulu-8.jdk/Contents/Home/bin/java
 "-javaagent:
   /Users/chengpan/Library/Application 
Support/JetBrains/Toolbox/apps/IDEA-U/ch-0/212.5284.40/IntelliJ 
IDEA.app/Contents/lib/idea_rt.jar=60442:
   /Users/chengpan/Library/Application 
Support/JetBrains/Toolbox/apps/IDEA-U/ch-0/212.5284.40/IntelliJ 
IDEA.app/Contents/bin" -Dfile.encoding=UTF-8 -classpath "
   ...
   
/Users/chengpan/Projects/apache-kyuubi/kyuubi-hive-jdbc/target/scala-2.12/classes:
   
/Users/chengpan/Projects/apache-kyuubi/kyuubi-hive-jdbc/target/kyuubi-hive-jdbc-1.4.0-SNAPSHOT.jar:
   ...
   "
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to