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

System user property to skip? #268

Closed
vorburger opened this issue Dec 14, 2016 · 3 comments
Closed

System user property to skip? #268

vorburger opened this issue Dec 14, 2016 · 3 comments

Comments

@vorburger
Copy link

It would be nice to have if this Maven plugin had a -D user system property to skip its execution...

I realize that you can use the following in a POM, but can't see how to do this from CLI w.o. changing code:

<configuration>
  <skip>true</skip>
</configuration>

As far as I understand Maven, support for being able to do something like mvn -Dmaven.gitcommitid.skip=true package would have to be coded into the Mojo (although I may be wrong).

FYI: The *.skip suffix naming convention seems to be what all of the core Maven plugins use; e.g. maven.javadoc.ski, maven.source.skip etc. or also checkstyle.skip, findbugs.skip, pmd.skip, cpd.skip, etc.

@ktoso
Copy link
Collaborator

ktoso commented Dec 14, 2016

If that's implemented this way by these other plugins it seems we should do it too.
Would you be able to send in a PR?

The plugin is not very actively developed by myself, however I'm happy to review/merge/and release if you'd provide a PR for this.

@TheSnoozer
Copy link
Collaborator

Should be super easy to add this.
maven-surefire-plugin has this option:
https://maven.apache.org/surefire/maven-surefire-plugin/examples/skipping-test.html

Magic is hidden here:
https://github.com/apache/maven-surefire/blob/master/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java#L152

Based on https://maven.apache.org/guides/plugin/guide-java-plugin-development#Parameters

Defining a parameter is as simple as creating an instance variable in the mojo and adding the proper annotations. Listed below is an example of a parameter for the simple mojo:

        /**
         * The greeting to display.
         */
        @Parameter( property = "sayhi.greeting", defaultValue = "Hello World!" )
        private String greeting;

The portion before the annotations is the description of the parameter. The parameter annotation identifies the variable as a mojo parameter. The defaultValue parameter of the annotation defines the default value for the variable. This value can include expressions which reference the project, such as "${project.version}" (more can be found in the "Parameter Expressions" document). The property parameter can be used to allow configuration of the mojo parameter from the command line by referencing a system property that the user sets via the -D option.

welcor pushed a commit to welcor/maven-git-commit-id-plugin that referenced this issue Mar 16, 2017
@ktoso ktoso closed this as completed Mar 16, 2017
@ktoso ktoso added this to the 2.2.3 milestone Mar 16, 2017
@shague
Copy link

shague commented Mar 16, 2017

This is great, was just looking for something like this. Any idea when the 2.2.3 version will be released to Maven Central?

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

No branches or pull requests

4 participants