Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add parameter classes to Cache mojo #510

Merged
merged 5 commits into from
Aug 6, 2021

Conversation

HGuillemet
Copy link
Contributor

When using

mvn org.bytedeco:javacpp:cache -Djavacpp.platform=linux-x86_64

from a project using, e.g., opencv, the cache plugin walks through all classes in the opencv presets and attempts to load the javacpp-annotated ones.
This will try to load and cache a lot of libraries, potentially from other presets like cpython, while the project may use only a subset of them.
This PR adds a classes parameter to limit the scope of the class walk:

mvn -Dclasses=org.bytedeco.opencv.global.opencv_core,org.bytedeco.opencv.global.opencv_imgproc org.bytedeco:javacpp:cache -Djavacpp.platform=linux-x86_64

Does it make sense ?

There is probably smarter but more complex alternatives, like using jdeps or similar to automatically cache what is actually used by the project.

@saudet
Copy link
Member

saudet commented Aug 5, 2021

Sure, that makes sense, but let's name the property "javacpp.classOrPackageNames" to make it consistent with BuildMojo, and be aware that it's not possible to populate arrays like that with system properties on the command line or elsewhere... In any case, please fix the formatting! Thanks

@HGuillemet
Copy link
Contributor Author

Fixed formatting and property name.
What do you mean by it's not possible to populate arrays ? It seems to work for me:

$ mvn -Djavacpp.classOrPackageNames=org.bytedeco.opencv.global.opencv_core,org.bytedeco.opencv.global.opencv_imgproc org.bytedeco:javacpp:1.5.7-SNAPSHOT:cache -Djavacpp.platform=linux-x86_64
...
Info: Loading class org.bytedeco.opencv.global.opencv_core
Info: Loading class org.bytedeco.opencv.global.opencv_imgproc

@saudet
Copy link
Member

saudet commented Aug 5, 2021

Ok, that must be a new feature of Maven I'm not aware of... Let's also put a single String property "javacpp.classOrPackageName" at least for older versions of Maven and to be consistent with Builder?

@HGuillemet
Copy link
Contributor Author

Done.
Some properties are prefixed with the fqdn like org.bytedeco.javacpp.cachedir. What is the logic behind the naming ?

@saudet
Copy link
Member

saudet commented Aug 6, 2021

The system properties with long names are typically used at runtime, when many other libraries may be loaded, with their own system properties that we can't control. Maven plugins on the other hand are typically not so numerous in any given build and something we can also control, so to reduce typing on the command line, the names of their properties are typically short, that's all.

@saudet saudet merged commit 5d56bc6 into bytedeco:master Aug 6, 2021
@HGuillemet HGuillemet deleted the hg_cache_classes branch August 6, 2021 06:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants