Skip to content

Commit e1fa3cc

Browse files
author
TheSnoozer
committed
git-commit-id/git-commit-id-maven-plugin#535: add POC that allows to generate for all git-directories for a reactor-project
1 parent 8e2afc8 commit e1fa3cc

File tree

1 file changed

+101
-0
lines changed

1 file changed

+101
-0
lines changed

pom.xml

+101
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
<!--<git-commit-id-version>2.2.5</git-commit-id-version> -->
4646
<git-commit-id-version>3.0.0</git-commit-id-version>
4747
<sonar.projectVersion>${project.version}-${git.branch}</sonar.projectVersion>
48+
<git-commit-plugin-prefix>git</git-commit-plugin-prefix>
4849
</properties>
4950

5051
<dependencies>
@@ -80,6 +81,105 @@
8081
</plugins>
8182
</build>
8283
<profiles>
84+
<profile>
85+
<id>setup-git-prefix-for-submodule</id>
86+
<activation>
87+
<file>
88+
<exists>../pom.xml</exists>
89+
</file>
90+
</activation>
91+
<properties>
92+
<git-commit-plugin-prefix>git.${project.artifactId}</git-commit-plugin-prefix>
93+
</properties>
94+
</profile>
95+
<profile>
96+
<id>generate-git-props</id>
97+
<activation>
98+
<file>
99+
<exists>${basedir}/.git</exists>
100+
</file>
101+
</activation>
102+
<build>
103+
<plugins>
104+
<plugin>
105+
<groupId>pl.project13.maven</groupId>
106+
<artifactId>git-commit-id-plugin</artifactId>
107+
<version>${git-commit-id-version}</version>
108+
<executions>
109+
<execution>
110+
<id>get-the-git-infos</id>
111+
<goals>
112+
<goal>revision</goal>
113+
</goals>
114+
<phase>initialize</phase>
115+
</execution>
116+
<execution>
117+
<id>validate-the-git-infos</id>
118+
<goals>
119+
<goal>validateRevision</goal>
120+
</goals>
121+
<phase>compile</phase>
122+
</execution>
123+
</executions>
124+
<configuration>
125+
<prefix>${git-commit-plugin-prefix}</prefix>
126+
<!-- <prefix>git.${project.artifactId}</prefix> -->
127+
<skipPoms>false</skipPoms>
128+
<verbose>false</verbose>
129+
<dotGitDirectory>${project.basedir}/.git</dotGitDirectory>
130+
<injectAllReactorProjects>true</injectAllReactorProjects>
131+
<generateGitPropertiesFile>true</generateGitPropertiesFile>
132+
<generateGitPropertiesFilename>${project.build.outputDirectory}/${project.artifactId}_git.properties</generateGitPropertiesFilename>
133+
</configuration>
134+
</plugin>
135+
<plugin>
136+
<groupId>org.apache.maven.plugins</groupId>
137+
<artifactId>maven-antrun-plugin</artifactId>
138+
<version>1.8</version>
139+
<executions>
140+
<execution>
141+
<phase>package</phase>
142+
<configuration>
143+
<target>
144+
<echo>===========================================================================</echo>
145+
<echo>Found .git-Folder assuming we need to generate git.properties!</echo>
146+
<echo>Set prefix to: ${git-commit-plugin-prefix}</echo>
147+
<echo>Set dotGitDirectory to: ${project.basedir}/.git</echo>
148+
<echo>Set generateGitPropertiesFilename to: ${project.build.outputDirectory}/${project.artifactId}_git.properties</echo>
149+
</target>
150+
</configuration>
151+
<goals>
152+
<goal>run</goal>
153+
</goals>
154+
</execution>
155+
</executions>
156+
</plugin>
157+
<plugin>
158+
<groupId>org.codehaus.gmaven</groupId>
159+
<artifactId>gmaven-plugin</artifactId>
160+
<version>1.5</version>
161+
<executions>
162+
<execution>
163+
<id>out-put-dynamic-property</id>
164+
<phase>package</phase>
165+
<goals>
166+
<goal>execute</goal>
167+
</goals>
168+
<configuration>
169+
<source>
170+
String prefix = project.properties.getProperty("git-commit-plugin-prefix")
171+
System.out.println(
172+
"Commit-Generated for " + project.artifactId + " : " +
173+
project.properties.getProperty(prefix + ".commit.id")
174+
)
175+
</source>
176+
</configuration>
177+
</execution>
178+
</executions>
179+
</plugin>
180+
</plugins>
181+
</build>
182+
</profile>
83183
<profile>
84184
<id>git-with-parent</id>
85185
<build>
@@ -134,6 +234,7 @@
134234
<target>
135235
<echo>===========================================================================</echo>
136236
<echo>git.commit.id.describe: ${git.commit.id.describe}</echo>
237+
<echo>git.commit.id.describe: ${git.commit.id.describe}</echo>
137238
<echo>git.commit.id.describe.withoutdirty: ${git.commit.id.describe.withoutdirty}</echo>
138239
</target>
139240
</configuration>

0 commit comments

Comments
 (0)