Jib should handle the absence of source files gracefully
See original GitHub issueThe behaviour of Jib
and java
plugins differs if a project does not have any source files. Cosnider the following difference.
Java plugin handles the absence of source files gracefully by skipping the compileJava
task:
> Task :root-project:sub-project:compileJava NO-SOURCE
file or directory '<project_path>/src/main/java', not found
Skipping task ':root-project:sub-project:compileJava' as it has no source files and no previous output files.
Jib, on the other hand, terminates gradle execution:
warning: Could not find build output <project_path>/build/classes/java/main'
warning: No classes files were found - did you compile your project?
> Task :jibDockerBuild FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':jibDockerBuild'.
> Main class was not found, perhaps you should add a `mainClass` configuration to jib
Caused by: com.google.cloud.tools.jib.frontend.MainClassInferenceException: Main class was not found, perhaps you should add a `mainClass` configuration to jib
at com.google.cloud.tools.jib.frontend.MainClassFinder.resolveMainClass(MainClassFinder.java:96)
It would be convenient to be able to acheive the same no-source handling behaviour in both plugins for a simpler configuration.
I would suggest to either hardcode the improvement or add a configuration option such as lenient=true/false
, where in case of true
the plugin would skip the task with no source files and in case of false
Jib would terminate as it does now.
Issue Analytics
- State:
- Created 5 years ago
- Comments:18 (11 by maintainers)
Top Results From Across the Web
Top 10 Most Common Mistakes That Java Developers Make
Dominant in many ways, Java offers a lot for developers: strict object-oriented paradigm, architecturally agnostic virtual machine, garbage collection - all ...
Read more >Challenge solutions - Pwning OWASP Juice Shop
Provoke an error that is neither very gracefully nor consistently handled. Any request that cannot be properly handled by the server will eventually...
Read more >How to Fire an Employee: Tips for Letting Go
Firing someone too hastily or without taking the proper steps could lead to an uncomfortable situation or even legal issues that could damage...
Read more >3 Common Tasks — The Yocto Project ® 4.1.999 documentation
The meta-yocto-bsp/conf/layer.conf file in the Yocto Project Source Repositories ... During the build process, BitBake displays an error on starting if it ...
Read more >Why It's OK to Quit Your Job - TopResume
If your gut is telling you you're not where you should be in 2021, quitting your job is OK. Just consider these tips...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This is intended. Please see #578 and #413.
Yeah, since maven is assuming we’re calling the goal on all modules, to avoid this you can use one of two options:
-pl
which will only execute on a specific module.<modules>
and the parent pom patterns. And lets assume we want the jib goal to execute in the package phase our lifecycle. pom.xml (in our jib module)to execute this with almost the same results as
mvn clean compile jib:build
We’re skipping tests, because previously
compile jib:build
didn’t even activate thetest
phase.I must also say that the pattern of the plugin enabling/disabling itself appears in the maven ecosystem. And while it may be strange, I can’t deny that people seem to want to use it. Let me know how this works for you, and if it doesn’t we can work on another solution that fits within the standard maven model.