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

invoking lifecycles before direct goals #315

Open
jgangemi opened this issue Oct 25, 2015 · 15 comments
Open

invoking lifecycles before direct goals #315

jgangemi opened this issue Oct 25, 2015 · 15 comments
Assignees
Labels
Milestone

Comments

@jgangemi
Copy link
Collaborator

i know this has been a discussion before...did we ever come to any resolution on this, i can't remember.

if we didn't, guess what i just found/realized! the source:jar goal invokes the generate-sources lifecycle phase before it execute itself, which is what i want the docker:* commands to do. now i can go digging through that code to see how it's done.

if we did figure something out, sheepish grin for not remembering and having to ask what we came up w/. :)

@rhuss
Copy link
Collaborator

rhuss commented Oct 25, 2015

I think its because of line 34 in SourceJarMojo.

Which lifecycle phase do you want to call before the direct commands ? I wonder whether this is always that what is needed or whether calling and whether a goal is called twice when e.g. called with mvn install docker:build and docker:build calling out the install phase.

@jgangemi
Copy link
Collaborator Author

i want the initialize phase to run automatically, that way i can have the maven-remote-resources-plugin, properties-maven-plugin, and buildnumber-maven-plugin plugins all run prior in order to leverage what they do in standalone call to build the container. from the looks of the documentation, i think this can be controlled w/ executionStrategy but i would need to test.

the source plugin re-runs the initialize phase before it executes, even when called from a lifecycle, so i'm guessing there's no harm there.

also - while in this discussion, whats' the reason for the javadoc annoations vs vs real annotations? was that to support an older version of the jdk and just a carry over now that the project requires 1.7 to run?

@jgangemi
Copy link
Collaborator Author

also, as an aside, i can find no way to do this in maven configuration itself, otherwise i would.

@rhuss
Copy link
Collaborator

rhuss commented Oct 25, 2015

Yeah, now I remember ;)

There is no particular reason now for using comments instead of annotations except to allow older Maven versions. There is still an issue open (don't remember exactly which) where support for older Maven versions is requested. It seems, which should be careful which Maven versions to support, since in enterprise there are often only really ancient Maven installations allowed. So its not so much about Java 7.

@rhuss
Copy link
Collaborator

rhuss commented Oct 25, 2015

It's #290 which needs 3.0.3. Unfortunately I didn't had time yet to check what exactly we need from new Maven versions ...

@jgangemi
Copy link
Collaborator Author

hrm - i guess we'll have to decide where the cut off is for maven version support like we have for docker api versions so the plugin can move forward.

i will look into this by the end of day tomorrow and report back my finding and hopefully a PR. also - at some point, i wonder if we will need to start maintaining two lines that support an older version of maven. i can see the argument that it's not fair to exclude users on what may be a fringe edge case.

i wonder if older versions of maven would just ignore the annotation if they didn't know what to do w/ it.

also - the compiler plugin in the pom sets the source/target version to 1.7, which means java 7 is required. i'm not sure what version of java 3.0.3 requires and i've spent the maximum amount of time i'm going to on it. :)

@rhuss
Copy link
Collaborator

rhuss commented Oct 25, 2015

Completely agreed: If it's not to hard and we won't lose opportunities I would stay as backward compatible as possible. E.g. when the usage of annotations over javadoc comments has a substantial functional advantage I would go for it. If it is only a matter of taste and because since such annotations doesn't have to be written very often, I would leave it then.

We can always then say: This version of d-m-p is the latest supporting this and this. I definitely do not want to maintain two lines of development and also don't hesitate to go on (with some care). After all, we want to have fun, too :)

@jgangemi
Copy link
Collaborator Author

i'll report back my findings soon.

@rhuss
Copy link
Collaborator

rhuss commented Oct 26, 2015

Since I'm currently working on a 'docker:source' for attaching the docker build tar to the Maven repo, I found out that these class level comments work nicely for calling another phase before calling oneself (even only once in a session)

* @goal source
 * @phase package
 * @execute phase="generate-sources"
 * @executionStrategy once-per-session

See also https://maven.apache.org/plugin-tools/maven-plugin-tools-java/index.html

@jgangemi
Copy link
Collaborator Author

perfect - so we can change the other mojos to rely on the initialization phase and open up a whole new realm of integration possibilities. it's still unfortunate this can't be done directly through xml configuration though.

@rhuss
Copy link
Collaborator

rhuss commented Oct 29, 2015

yep.

btw next week I'm on vacations and the November will be busy for me. 'happy to integrate PRs, though ;-)

@jgangemi
Copy link
Collaborator Author

lol - ok. i'll keep that in mind. the new job has me swamped trying to fix a build that hasn't seen any kind of love in a long time. i'm slowing starting to climb out of that hole, so change is coming. :)

enjoy your vacation!!

@vberruchon
Copy link

About annotations, you can use Java5 annotations to generate the plugin descriptor file since Maven version 3.0. ;)
https://maven.apache.org/plugin-tools/maven-plugin-plugin/examples/using-annotations.html#POM_configuration

@jgangemi jgangemi self-assigned this Jul 6, 2016
@jgangemi jgangemi added this to the 0.15.10 milestone Jul 6, 2016
@rhuss
Copy link
Collaborator

rhuss commented Jul 7, 2016

See #505 (comment) for a discussion why forking the lifecycle is not so trivial and can cause issues.

@rhuss
Copy link
Collaborator

rhuss commented Jul 7, 2016

See #448 for a real world issue of this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants