-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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 configuration to skip in Maven plugin #865
Comments
Hi @ahaeber , thanks for the feature suggestion! Adding |
For local development workflow, are you assuming a team would use this plugin to replace local development? It definitely makes sense to not skip during a CI build, however I could see skipping the push to a docker repository when doing local development, especially if the tag is overwritten. Are there any examples of jib working for a team of a couple of developers? |
Think of a Maven multi-module project. For example 'statistics-lib',
'web-app' and 'docs'. Here I would like the jib plugin to be invoked only
for the 'web-app' module. It currently is possible to add the jib plugin to
only that module, but then it is not possible to use it from the root
project because it doesn't know about that plugin. So you need to do
something like 'mvn -pl web-app jib:build'.
On the other hand, if jib supported skip option then I could set skip=true
as default and bind it to the package phase in the parent pom. Then set
skip=false in the web-app module. Next I only need to do 'mvn package' and
everything builds as it should. Jib would only be executed for the web-app
module.
Hope it makes more sense now.
BR, Andreas
…On Sat, Aug 25, 2018, 16:13 RJ Seibert ***@***.***> wrote:
For local development workflow, are you assuming a team would use this
plugin to replace local development? It definitely makes sense to not skip
during a CI build, however I could see skipping the push to a docker
repository when doing local development, especially if the tag is
overwritten. Are there any examples of jib working for a team of a couple
of developers?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#865 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAz1gHx7lbsME_aYdXV2mH8gz4Vhnxs3ks5uUVuIgaJpZM4WHq6j>
.
|
Ideally a module wouldn't have jib on it if it is not using it (using skip is a hack workaround to Maven config). Why not just use pluginManagement at the root level and then either bind the jib task to lifecycle phase 'package' (or something) or use module specific executions (-pl on commandline) |
I am not sure that adding a skip option is a hack since it is a standard for many Maven plugins. As the example by @ahaeber pointed out, one might have a multi-module project that a build could be done by a simple Just like dependencies, it would be nice to configure a plugin in the parent pom and then utilize it only in the projects that need it. |
For the reason given by @ahaeber, the point raised by @loosebazooka IMHO is a cleaner approach. You can still define the plugin in the parent pom via pluginManagement and then use it only in modules that need it. But... there may be other scenarios where this is useful. Although you can still argue with running this only to a specific maven lifecycle and avoid the skip config. |
So you can configure it in the parent and use it only on the children, using pluginManagement: https://maven.apache.org/pom.html#Plugin_Management. You can still do common configuration in the parent as you would like, and you wouldn't have to reference the plugin at all on modules that don't use it. If the simple case that you are running Perhaps hack is overly aggressive in this situation, but applying the plugin everywhere and then disabling it selectively seems like a less meaningful pattern than only enabling it when necessary. Perhaps I'm missing something though? |
Sorry if I was not clear in my original message. It currently does not work
to simply add the plugin to pluginManagement in the parent-pom and add the
plugin (without version etc) to modules that need it. In this case it fails
with the following error message:
"[ERROR] Failed to execute goal
com.google.cloud.tools:jib-maven-plugin:0.9.9:build (default-cli) on
project my-library: Missing target image parameter, perhaps you should add
a <to><image> configuration parameter to your pom.xml or set the parameter
via the commandline (e.g. 'mvn compile jib:build -Dimage=<your image
name>'). -> [Help 1]
In this case my project is a parent-pom with two modules, library and app.
The app module depends on the library module and is a Spring Boot
application. In the parent-pom pluginManagement I've added the Jib plugin
with version and default configuration (like base image and container
args). Then in the app-module I've added executions for the Jib plugin.
As can be seen from the Maven error message it will try to execute the
plugin for the library-module now because there is no way to tell Maven to
skip the plugin for that module. The parent-pom is skipped but that is
because Jib always skips pom modules.
BR, Andreas
…On Tue, Aug 28, 2018 at 3:58 AM Appu ***@***.***> wrote:
So you can configure it in the parent and use it only on the children,
using pluginManagement:
https://maven.apache.org/pom.html#Plugin_Management. You can still do
common configuration in the parent as you would like, and you wouldn't have
to reference the plugin at all on modules that don't use it.
If the simple case that you are running mvn package, you bind the jib
goal to the package phase (you can even go as far as to unbind the jar/war
goal) and it all works the same.
Perhaps *hack* is overly aggressive in this situation, but applying the
plugin everywhere and then disabling it selectively seems like a less
meaningful pattern than only enabling it when necessary.
Perhaps I'm missing something though?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#865 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAz1gLnbFTIzagbB8budB1Q_NysOkstbks5uVKOxgaJpZM4WHq6j>
.
|
Do you happen to have the plugin also defined in the <build> tag of your
parent pom?
|
No, only in pluginManagement. The command I use is:
mvn package jib:build
BR, Andreas
On Tue, Aug 28, 2018 at 1:06 PM Darth Binamira <notifications@github.com>
wrote:
… Do you happen to have the plugin also defined in the <build> tag of your
parent pom?
On Tue, Aug 28, 2018 at 6:19 PM Andreas Häber ***@***.***>
wrote:
> Sorry if I was not clear in my original message. It currently does not
work
> to simply add the plugin to pluginManagement in the parent-pom and add
the
> plugin (without version etc) to modules that need it. In this case it
fails
> with the following error message:
> "[ERROR] Failed to execute goal
> com.google.cloud.tools:jib-maven-plugin:0.9.9:build (default-cli) on
> project my-library: Missing target image parameter, perhaps you should
add
> a <to><image> configuration parameter to your pom.xml or set the
parameter
> via the commandline (e.g. 'mvn compile jib:build -Dimage=<your image
> name>'). -> [Help 1]
>
> In this case my project is a parent-pom with two modules, library and
app.
> The app module depends on the library module and is a Spring Boot
> application. In the parent-pom pluginManagement I've added the Jib plugin
> with version and default configuration (like base image and container
> args). Then in the app-module I've added executions for the Jib plugin.
>
> As can be seen from the Maven error message it will try to execute the
> plugin for the library-module now because there is no way to tell Maven
to
> skip the plugin for that module. The parent-pom is skipped but that is
> because Jib always skips pom modules.
>
> BR, Andreas
>
>
>
> On Tue, Aug 28, 2018 at 3:58 AM Appu ***@***.***> wrote:
>
> > So you can configure it in the parent and use it only on the children,
> > using pluginManagement:
> > https://maven.apache.org/pom.html#Plugin_Management. You can still do
> > common configuration in the parent as you would like, and you wouldn't
> have
> > to reference the plugin at all on modules that don't use it.
> >
> > If the simple case that you are running mvn package, you bind the jib
> > goal to the package phase (you can even go as far as to unbind the
> jar/war
> > goal) and it all works the same.
> >
> > Perhaps *hack* is overly aggressive in this situation, but applying the
> > plugin everywhere and then disabling it selectively seems like a less
> > meaningful pattern than only enabling it when necessary.
> >
> > Perhaps I'm missing something though?
> >
> > —
> > You are receiving this because you were mentioned.
> > Reply to this email directly, view it on GitHub
> > <
>
#865 (comment)
> >,
> > or mute the thread
> > <
>
https://github.com/notifications/unsubscribe-auth/AAz1gLnbFTIzagbB8budB1Q_NysOkstbks5uVKOxgaJpZM4WHq6j
> >
> > .
> >
>
> —
> You are receiving this because you commented.
> Reply to this email directly, view it on GitHub
> <
#865 (comment)
>,
> or mute the thread
> <
https://github.com/notifications/unsubscribe-auth/AHoJzY1q5Ic9XPvHtPedSvH4FgRG0Cfuks5uVRlIgaJpZM4WHq6j
>
> .
>
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#865 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAz1gLEyvNbMkFOymRH2mPXq7oXl9qUyks5uVSRFgaJpZM4WHq6j>
.
|
Ahhh got it. Can you instead bind the package lifecycle in your web module with the plugin, that way you don't have to run with 'mvn package jib:build'. That is causing to run the plugin in all the modules. |
Hm.. so this is how the plugin is configured: parent-pom
library-module app-module
As you can see I've tried binding to phase 'package' but that didn't help. Actually nothing in the app-module's pom.xml matters here because the build fails in the library-module before the app-module is processed by Maven. And many Maven plugins support a skip configuration property to handle this. |
Except for the commented package phase, I don't see anything wrong with your configs. Can you uncomment and remove the other none phase. When running from the root dir, just do 'mvn package'. That should not run the jib plugin on your library module. |
Yes, @darthbinamira's #865 (comment) is what you want. Just If you wanted to run jib:build from the command line, you would be required to use the -pl flag to directly reference a single (or comma separated list of) modules (cli reference here). If you are not building all modules using a single command, I believe you need to install the package to correctly reference it. Might need to play around with that a little. $ mvn install -pl lib-module && mvn prepare-package jib:build -pl app-module |
Having said all that, skip might make sense for non-(jar/war) maven builds. Perhaps having everyone bend maven around is the wrong way to make builds easier. We should just add it in and let people do whatever. |
Oh great, when I bind the executions to the package phase it works :) |
@ahaeber Glad to hear it works for you now! :) @loosebazooka Yeah true, there may be other scenarios as well, I just can’t think of one off the top of my head. |
Hi @ahaeber @alephnot0 @vonnagy @darthbinamira , we have released version |
In multi-module projects usually the parent POM is used to specify plugin and dependency versions to be used in child modules. Then, there are build plugins that are not desired to be enabled for all modules. Therefore it has become a common practice by Maven plugin to support a 'skip' configuration item. If skip = true then the plugin should skip that module. Then we can for example set skip = true as default and enable it (skip = false) for modules that need that plugin.
So it would be awesome if the jib-maven-plugin also could support such a 'skip' configuration.
The text was updated successfully, but these errors were encountered: