Skip to content

Generating file in "json" format fails when file in "properties" format already exists #99

Open
@PontusPih

Description

@PontusPih

Describe the bug (required)

It seems that the code that generates the json formatted file tries to open and parse the existing file. If the existing file is not valid json, it fails.

Tell us about your plugin configuration (required)

            <plugin>
                <groupId>io.github.git-commit-id</groupId>
                <artifactId>git-commit-id-maven-plugin</artifactId>
                <version>6.0.0</version>
                <executions>
                    <execution>
                        <id>get-the-git-infos</id>
                        <goals>
                            <goal>revision</goal>
                        </goals>
                        <phase>initialize</phase>
                    </execution>
                </executions>
                <configuration>
                    <generateGitPropertiesFile>true</generateGitPropertiesFile>
                    <generateGitPropertiesFilename>${project.build.outputDirectory}/git.properties</generateGitPropertiesFilename>
                    <format>json</format>
                </configuration>
            </plugin>

Tell us about the Plugin version used (required)

6.0.0

Tell us about the Maven version used (required)

mvn --version
Apache Maven 3.5.4 (1edded0938998edf8bf061f1ceb3cfdeccf443fe; 2018-06-17T20:33:14+02:00)
Maven home: /home/pontus/.m2/wrapper/dists/apache-maven-3.5.4-bin/4lcg54ki11c6mp435njk296gm5/apache-maven-3.5.4
Java version: 11.0.19, vendor: Red Hat, Inc., runtime: /usr/lib/jvm/java-11-openjdk-11.0.19.0.7-1.fc37.x86_64
Default locale: en_GB, platform encoding: UTF-8
OS name: "linux", version: "6.3.12-100.fc37.x86_64", arch: "amd64", family: "unix"

Steps to Reproduce (required)

  1. Set properties
  2. run mvn io.github.git-commit-id:git-commit-id-maven-plugin:6.0.0:revision
  3. Set json
  4. run mvn io.github.git-commit-id:git-commit-id-maven-plugin:6.0.0:revision

Are there any stacktraces or any error messages? (required)

WARNING You may NOT want to paste all the output that is produced with verbose publicly,
since it MAY contain information you deem sensitive.
Review this CAREFULLY before posting your issue!

[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.877 s
[INFO] Finished at: 2023-09-13T10:55:21+02:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal io.github.git-commit-id:git-commit-id-maven-plugin:6.0.0:revision (default-cli) on project secret-project: Execution default-cli of goal io.github.git-commit-id:git-commit-id-maven-plugin:6.0.0:revision failed: Unexpected char 35 at (line no=1, column no=1, offset=0) -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginExecutionException
[ERROR] 
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR]   mvn <goals> -rf :secret-project

Is there a (public) project where this issue can be reproduced? (optional)

No response

Your Environment (optional)

No response

Context (optional)

There is an easy work arround: Just delete the generated properties file before generating it again in a different format.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions