ahauschulte commented on pull request #28:
URL: 
https://github.com/apache/netbeans-mavenutils-nbm-maven-plugin/pull/28#issuecomment-1081030849


   I think there are three different cases regarding dependency scopes in maven 
(https://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html#Dependency_Scope)
 that need to be taken into account here:
   
   - Dependencies with scope "compile" are necessary to compile and run the 
module. Those dependencies need to be put on the compile and runtime classpaths 
and they need to be bundled. The current implementation of the nbm maven plugin 
handles this correctly.
   - Dependencies with scope "provided" are necessary to run the module and 
might also be necessary to compile it. However, they are indeed supplied by the 
runtime environment. Thus, there is no need to include them in the module’s nbm 
file. The current implementation of the nbm maven plugin handles this correctly 
as well.
   - Dependencies with scope "runtime" need to be on the runtime classpath for 
the module to work properly but they are not required to compile the module. 
This might be the case for one reason or another. For example, classes could be 
loaded manually, which is commonly done for JDBC drivers. (Something like 
`Class.forName("com.mysql.cj.jdbc.Driver")`) This is where the current 
implementation of the nbm maven plugin causes me some trouble, since those 
runtime dependencies are not bundled with the module’s nbm file. If, in this 
example, the dependency for the MySQL driver has the scope "runtime", and is 
not, by chance, provided by the runtime environment, the JDBC driver will just 
be missing, which will cause trouble at runtime.
   
   While the problem described in the simplistic example above could be easily 
resolved by just changing the scope of the MySQL driver dependency from 
"runtime" to "compile", there are other constellations where this causes much 
more trouble. Consider large third-party libraries that make extensive use of 
scope "runtime" for their own dependencies. This is often the case when these 
libraries are built using gradle because gradle provides finer-grained control 
whether a library should "leak" its own dependencies to its client. This is 
done by making liberate use of the scope "runtime". 
(https://docs.gradle.org/current/userguide/java_library_plugin.html#sec:java_library_separation)
   
   An example is the kafka library (https://github.com/apache/kafka; 
https://repo1.maven.org/maven2/org/apache/kafka/kafka_2.13/3.1.0/kafka_2.13-3.1.0.pom),
 which has quite a lot of runtime dependencies. If such a library is a 
dependency of your Netbeans module, a huge number of libs will be missing in 
the nbm file. In this case, though, you’ll get warnings from the nbm maven 
plugin if the verifyRuntime option hasn’t been deactivated. Anyway, with the 
current implementation, you’ll need to manually add all the missing transitive 
dependencies to your module’s pom file. 
   


-- 
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]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists

Reply via email to