Skip to content

How to configure plugin execution so that maven sequence do not break? #392

Closed

Description

@dishesh

Description

Hi I am using git commit plugin to store details of commit in a properties file and then read this file to compute some logic. I am using jgit flow plugin to manage git cycles in my development process. When I feature finish my branch it does all the process but it throws exception as the plugin have changed the file which is not committed and hence breaks the process. I can not ignore the file as I need it inside some specific resources package.

Expected behavior

  • I want the plugin to update the file without breaking the process, as I will need updated commit details when feature finish or release finish.

Activity

  1. TheSnoozer commented on Oct 22, 2018

    @TheSnoozer
    Collaborator

    Hi,
    thanks for reporting your issue here.
    Based on the context provided I don't quite understand what is not working (within the plugin) and especially what you expect differently. I don't quite understand yet how the plugin would fail based on the git workflow being used.

    but it throws exception as the plugin have changed the file which is not committed and hence breaks the process.

    What process throws what exception?
    Is it the plugin or the jgit flow plugin?

    Is there a (public) project where this issue can be reproduced?
    Please include any stack-traces or any error messages and furthermore please provide a description of what you expected to happen.

  2. dishesh commented on Oct 23, 2018

    @dishesh
    Author

    The problem is not the plugin, but how can we skip it for some specific goals of maven execution ?
    Problem is that when merging my branch to develop using jgitflow plugin , plugin even stores commit values for that operation, hence making the execution goal failure for feature finish.

    Checkout Conflict Exception at the end of process. Sorry there is not any public project to reproduce the event.

  3. TheSnoozer commented on Oct 23, 2018

    @TheSnoozer
    Collaborator

    how can we skip it for some specific goals of maven execution ?

    That sounds like you need maven profiles, where different things happen based on a different context.

    One way to achieve something like this with profiles (really basic example) could be achieved with leveraging the skip parameter of the plugin configuration and define a global property that is getting overwritten by the profile when it is activated (in the following case this would be runGitCommitIdPlugin).

    <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    .....
        <properties>
            <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
            <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
            <runGitCommitIdPlugin>true</runGitCommitIdPlugin>
        </properties>
    .....
        <profiles>
            <profile>
                <id>skipPlugin</id>
                <properties>
                    <runGitCommitIdPlugin>false</runGitCommitIdPlugin>
                </properties>
            </profile>
        </profiles>
    .....
        <build>
            <resources>
                <resource>
                    <directory>src/main/resources</directory>
                    <filtering>true</filtering>
                </resource>
            </resources>
    
            <plugins>
                <!-- GIT COMMIT ID PLUGIN CONFIGURATION -->
                <plugin>
                    <groupId>pl.project13.maven</groupId>
                    <artifactId>git-commit-id-plugin</artifactId>
                    <version>2.2.5</version>
                    <executions>
                        <execution>
                            <id>get-the-git-infos</id>
                            <goals>
                                <goal>revision</goal>
                            </goals>
                        </execution>
                    </executions>
                    <configuration>
                        <skip>${runGitCommitIdPlugin}</skip>
                        <!-- whatever other config -->
                        <dotGitDirectory>${project.basedir}/.git</dotGitDirectory>
                    </configuration>
                </plugin>
            </plugins>
        </build>
    ...
    </project>

    I understand this example is somewhat not complete, but takes advantage that you use this plugin on a global level and have it disabled when a specific profile is activated. Once the profile is active it should overwrite the custom skip property and make the plugin skip the execution.

    There are various ways on activate profiles (either by command line mvn clean package -P<profile-name> or by some sort of activation rules when a file is present).

    Alternatively with version 2.2.3 you can also skip the plugin by using the command line option -Dmaven.gitcommitid.skip=true.

    See https://maven.apache.org/guides/introduction/introduction-to-profiles.html for further information on profiles.

  4. TheSnoozer commented on Nov 1, 2018

    @TheSnoozer
    Collaborator

    I would assume you solved the issue by now.
    Feel free to reopen the issue if you have further questions about 'how to exclude the plugin'

  5. added this to the 3.0 milestone on Nov 1, 2018
  6. added a commit that references this issue on Jun 5, 2024
  7. added a commit that references this issue on Sep 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions