Howdy,

just a quick idea: introduce your own packaging "quipsy-zip"? (yes, you'd
need your extension to be added to build, but it's worth it, trust me).

Look here:
https://github.com/apache/maven/blob/master/maven-artifact/src/main/java/org/apache/maven/artifact/handler/ArtifactHandler.java#L58

So, your packaging defines (name="quipsy-zip", extension="zip",
addedToClasspath=false...  it should work, and you'd depend on this zip as

<dependency>
  <groupId>org.group</groupId>
  <artifactId>artifact</artifactId>
  <version>1.0</version>
  <type>quipsy-zip</type>
</dependency>

See
https://medium.com/javarevisited/create-your-own-maven-packaging-2d69ad832720
(note: if you are NOT building this ZIP with maven, then you do not need
lifecycle mapping, only the ArtifactHandler )

https://github.com/apache/maven/blob/master/maven-artifact/src/main/java/org/apache/maven/artifact/handler/ArtifactHandler.java#L31


HTH
T


On Fri, Jun 10, 2022 at 10:54 AM [Quipsy] Markus Karg <k...@quipsy.de>
wrote:

> How can I keep a dependency out of all classpaths?
>
> I do have a dependency in my project that produces a ZIP full of
> resources. None of those resources is actually of any use for the Java
> compiler; they solely serve as an input to third party plugins (not dealing
> with Java at all). Unfortunately the Maven Compiler plugin sees that ZIP
> and tries to read it, leading to error messages as the ZIP is in an
> "unexpected" format (for now let's just say, it is intentionally
> incompatible). So the question is, how to tell Maven to not put that
> dependency on ANY Java classpath?
>
>
>   1.  "runtime" Scope: compile is happy now, but test-compile still fails
>   2.  Moving the dependency from being a project dependency to being a
> plugin-specific dependency: compile and test-compile are happy now, but -am
> doesn't build the dependency anymore and dependency:tree (and other
> scanners) does not tell me about the existence oft hat dependency at all
>   3.  "resource" Scope: would be exactly what I like to do, but Maven does
> not have such a scope: compile and test-compile would be happy, and -am
> still would build the dependency just like other scanners it would still
> see the dependency
>
> In the end, the bigger question actually is, how to tell ANY plugin to
> ignore particular dependencies of my POM? Just because my project is of
> type WAR does not mean that EVERYTING it depends upon shall be processed by
> the Java toolchain... Maybe it would be better if the Maven Compiler Plugin
> JUST puts those dependencies on the classpath that actually are JARs...?
>
> Thanks a lot!
> -Markus
>
>

Reply via email to