Skip to content

Extra directories created when default <generateGitPropertiesFilename> is used #124

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

Closed
keheliya opened this issue Jun 23, 2014 · 8 comments
Milestone

Comments

@keheliya
Copy link

In my plugin configuration I'm not specifically setting the <generateGitPropertiesFilename> property. But looks like it creates an extra directory structure for writing the GitPropertiesFile. For example if my project directory is: /home/foo/dev/projectABC, the files are written in following locations for the submodules:
/home/foo/dev/projectABC/module1/home/foo/dev/projectABC/module1/target/classes/git.properties
/home/foo/dev/projectABC/module2/home/foo/dev/projectABC/module2/target/classes/git.properties

Although this is harmless in linux/OS X (except few extra directories are created) it causes problems in Windows as follows:

[ERROR] Failed to execute goal pl.project13.maven:git-commit-id-plugin:2.1.9:revision
 (default) on project crawljax-core: Execution default of goal pl.project13.maven:
git-commit-id-plugin:2.1.9:revision failed: Cannot create custom git properties file: 
C:\Users\foo\Documents\GitHub\projectABC\module1\C:\Users\foo\Documents\GitHub
\projectABC\module1\target\classes\git.properties: 
The filename, directory name, or volume label syntax is incorrect

Looks like it's a bug when resolving ${project.basedir}

My plugin configuration is as follows:

<plugin>
                    <groupId>pl.project13.maven</groupId>
                    <artifactId>git-commit-id-plugin</artifactId>
                    <version>2.1.9</version>
                    <executions>
                        <execution>
                            <goals>
                                <goal>revision</goal>
                            </goals>
                        </execution>
                    </executions>
                    <configuration>
                        <dateFormat>yyyy-MM-dd HH:mm:ss z</dateFormat>
                        <verbose>false</verbose>
                        <generateGitPropertiesFile>true</generateGitPropertiesFile>
                        <gitDescribe>
                            <always>true</always>
                            <abbrev>7</abbrev>
                            <dirty>-dirty</dirty>
                        </gitDescribe>
                    </configuration>
                </plugin>

Please let me know if I have configured it wrong.

@TheSnoozer
Copy link
Collaborator

Hi,
this seems to be related to #73 and #81.

Can you try to add

<generateGitPropertiesFilename>${project.basedir}/yourpath/git.properties</generateGitPropertiesFilename>

to your config and try again?

According to a the comment from here #81 (comment) with this option the plugin will "behaves as expected".

@keheliya
Copy link
Author

Hi @TheSnoozer

Thanks for the tip. Following is the result of find . -name git.properties command inside the project directory when different values are set to generateGitPropertiesFilename property.

Case 1: generateGitPropertiesFilename property is not set. (Using the default value)

~/dev/crawljax $ find . -name git.properties
./core/home/keheliya/dev/crawljax/core/target/classes/git.properties
./cli/home/keheliya/dev/crawljax/cli/target/classes/git.properties
./test-utils/home/keheliya/dev/crawljax/test-utils/target/classes/git.properties
./plugins/crawloverview-plugin/home/keheliya/dev/crawljax/plugins/crawloverview-plugin/target/classes/git.properties
./plugin-archetype/home/keheliya/dev/crawljax/plugin-archetype/target/classes/git.properties

Case 2: generateGitPropertiesFilename property is set to ${project.basedir}/target/classes/git.properties

~/dev/crawljax $ find . -name git.properties
./core/home/keheliya/dev/crawljax/core/target/classes/git.properties
./cli/home/keheliya/dev/crawljax/cli/target/classes/git.properties
./test-utils/home/keheliya/dev/crawljax/test-utils/target/classes/git.properties
./plugins/crawloverview-plugin/home/keheliya/dev/crawljax/plugins/crawloverview-plugin/target/classes/git.properties
./plugin-archetype/home/keheliya/dev/crawljax/plugin-archetype/target/classes/git.properties

Case 3: generateGitPropertiesFilename property is set to target/classes/git.properties

~/dev/crawljax $ find . -name git.properties
./core/target/classes/git.properties
./cli/target/classes/git.properties
./test-utils/target/classes/git.properties
./plugins/crawloverview-plugin/target/classes/git.properties
./plugin-archetype/target/classes/git.properties

Case 3 is my intended behavior. Hope these will help to track down the issue and fix the default behavior for the plugin (specially for Windows). Thanks

@keheliya
Copy link
Author

Hi @ktoso

I'd like replicate this bug in https://github.com/ktoso/git-commit-id-debugging as well, for you to fix the issue. But I'm unable to build that project. Probably because versions in ktoso/git-commit-id-debugging and ktoso/maven-git-commit-id-plugin are not in sync.

@TheSnoozer
Copy link
Collaborator

Hi @keheliya,
you can test with
https://github.com/TheSnoozer/git-commit-id-debugging/
in the mean-time.

Case 1: generateGitPropertiesFilename property is not set. (Using the default value)

 mvn clean package && find . -name "git.properties"
./submodule-two/home/snoozer/git/git-commit-id-debugging/submodule-two/target/classes/git.properties
./submodule-one/home/snoozer/git/git-commit-id-debugging/submodule-one/target/classes/git.properties

Case 2: generateGitPropertiesFilename property is set to ${project.basedir}/target/classes/git.properties

 mvn clean package && find . -name "git.properties"
./submodule-two/home/snoozer/git/git-commit-id-debugging/submodule-two/target/classes/git.properties
./submodule-one/home/snoozer/git/git-commit-id-debugging/submodule-one/target/classes/git.properties

Case 3: generateGitPropertiesFilename property is set to target/classes/git.properties

 mvn clean package && find . -name "git.properties"
./submodule-two/target/classes/git.properties
./submodule-one/target/classes/git.properties

This results show the same behaviour as in #124 (comment)

PS: tested with v2.1.10

PSS: the default-value for generateGitPropertiesFilename is ${project.build.outputDirectory}/git.properties

It seems that all the trouble comes from

GitCommitIdMojo LN 323 generatePropertiesFile(properties, project.getBasedir(), generateGitPropertiesFilename);

GitCommitIdMojo LN 493 File gitPropsFile = new File(base, propertiesFilename);
will result in "project.getBasedir()\${project.build.outputDirectory}/git.properties"
with the default value.
Fix will be change default value to "git.properties"

ktoso added a commit that referenced this issue Jul 20, 2014
@ktoso
Copy link
Collaborator

ktoso commented Jul 20, 2014

This should be resolved in #125

Cheers!

@ktoso ktoso closed this as completed Jul 20, 2014
@drdamour
Copy link

drdamour commented Aug 4, 2014

I'm a bit confused. In spring boot's latest (1.1.4), the plugin config is like so:

<configuration>
    <verbose>true</verbose>
    <dateFormat>yyyy-MM-dd'T'HH:mm:ssZ</dateFormat>
    <generateGitPropertiesFile>true</generateGitPropertiesFile>
<generateGitPropertiesFilename>${basedir}/src/main/resources/git.properties</generateGitPropertiesFilename>
</configuration>

so i'm guessing that should be switched with

<generateGitPropertiesFilename>src/main/resources/git.properties</generateGitPropertiesFilename>

Yes? or is this a bug in 2.1.8-2.1.10 and will be resolved in 2.1.11?

@TheSnoozer
Copy link
Collaborator

Hi @drdamour,
there is (was) a bug in the versions up to 2.1.10.
When you configured your plugin like

<generateGitPropertiesFilename>${basedir}/src/main/resources/git.properties</generateGitPropertiesFilename>

the git-commit-id-plugin created a directory/propertiesFile like

${basedir}/${basedir}/src/main/resources/git.properties

which resulted in this bug ticket (pay atention to the double basedir-Variable).

In later versions you need to set

<generateGitPropertiesFilename>src/main/resources/git.properties</generateGitPropertiesFilename>

to get a directory/propertiesFile like

${basedir}/src/main/resources/git.properties

The Bug should be resolved in the next Version (likely the 2.1.11) where you can configure your Plugin both ways. In both ways (either a full path or a relative path in the generateGitPropertiesFilename) the plugin should create a directory/propertiesFile like

${basedir}/src/main/resources/git.properties

@iPolish
Copy link

iPolish commented Sep 26, 2014

Help who have the code please give me :((

@TheSnoozer TheSnoozer added this to the 2.11 milestone Jul 17, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants