Skip to content

Commit f5af67c

Browse files
author
TheSnoozer
committed
add a more sophisticated configuration that allows to run the plugin either from the parent or submodule (configurable via profiles)
1 parent a1f04a4 commit f5af67c

File tree

2 files changed

+108
-51
lines changed

2 files changed

+108
-51
lines changed

pom.xml

Lines changed: 56 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,9 @@
4242
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
4343
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
4444
<java.target>1.8</java.target>
45-
46-
<git-commit-id-version>2.2.5</git-commit-id-version>
45+
<!--<git-commit-id-version>2.2.5</git-commit-id-version> -->
46+
<git-commit-id-version>3.0.0-SNAPSHOT</git-commit-id-version>
47+
<sonar.projectVersion>${project.version}-${git.branch}</sonar.projectVersion>
4748
</properties>
4849

4950
<dependencies>
@@ -57,6 +58,11 @@
5758
<artifactId>maven-release-plugin</artifactId>
5859
<version>2.5.3</version>
5960
</plugin>
61+
<plugin>
62+
<groupId>org.sonarsource.scanner.maven</groupId>
63+
<artifactId>sonar-maven-plugin</artifactId>
64+
<version>3.6.0.1398</version>
65+
</plugin>
6066
</plugins>
6167
</pluginManagement>
6268
<plugins>
@@ -73,5 +79,53 @@
7379
</plugin>
7480
</plugins>
7581
</build>
82+
<profiles>
83+
<profile>
84+
<id>git-with-parent</id>
85+
<build>
86+
<plugins>
87+
<plugin>
88+
<groupId>pl.project13.maven</groupId>
89+
<artifactId>git-commit-id-plugin</artifactId>
90+
<version>${git-commit-id-version}</version>
91+
<executions>
92+
<execution>
93+
<id>get-the-git-infos</id>
94+
<goals>
95+
<goal>revision</goal>
96+
</goals>
97+
<phase>initialize</phase>
98+
</execution>
99+
<execution>
100+
<id>validate-the-git-infos</id>
101+
<goals>
102+
<goal>validateRevision</goal>
103+
</goals>
104+
<phase>compile</phase>
105+
</execution>
106+
</executions>
107+
<configuration>
108+
<prefix>git</prefix>
109+
<skipPoms>false</skipPoms>
110+
<verbose>true</verbose>
111+
<dotGitDirectory>${project.basedir}/.git</dotGitDirectory>
112+
<injectAllReactorProjects>true</injectAllReactorProjects>
113+
<generateGitPropertiesFile>true</generateGitPropertiesFile>
114+
<evaluateOnCommit>HEAD</evaluateOnCommit>
115+
<generateGitPropertiesFilename>${project.build.outputDirectory}/git.properties</generateGitPropertiesFilename>
116+
<replacementProperties>
117+
<replacementProperty>
118+
<property>sonar.projectVersion</property>
119+
<token>^.*$</token>
120+
<value>${project.version}-${git.branch}</value>
121+
<regex>false</regex>
122+
</replacementProperty>
123+
</replacementProperties>
124+
</configuration>
125+
</plugin>
126+
</plugins>
127+
</build>
128+
</profile>
129+
</profiles>
76130
</project>
77131

submodule-one/pom.xml

Lines changed: 52 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -26,56 +26,9 @@
2626

2727
<plugins>
2828
<!-- GIT COMMIT ID PLUGIN CONFIGURATION -->
29-
<plugin>
30-
<groupId>pl.project13.maven</groupId>
31-
<artifactId>git-commit-id-plugin</artifactId>
32-
<version>${git-commit-id-version}</version>
33-
<executions>
34-
<execution>
35-
<id>get-the-git-infos-validate</id>
36-
<goals>
37-
<goal>revision</goal>
38-
</goals>
39-
</execution>
40-
</executions>
41-
<configuration>
42-
<!--
43-
<excludeProperties>
44-
<excludeProperty>git.*.user.*</excludeProperty>
45-
</excludeProperties>
46-
-->
47-
<prefix>git</prefix>
48-
<verbose>true</verbose>
49-
<skipPoms>false</skipPoms>
50-
<!-- <runOnlyOnce>true</runOnlyOnce> -->
51-
<dotGitDirectory>${project.basedir}/../.git</dotGitDirectory>
52-
<injectAllReactorProjects>true</injectAllReactorProjects>
53-
<generateGitPropertiesFile>true</generateGitPropertiesFile>
54-
<evaluateOnCommit>HEAD^1</evaluateOnCommit>
55-
<generateGitPropertiesFilename>${project.build.outputDirectory}/git.properties</generateGitPropertiesFilename>
56-
</configuration>
57-
</plugin>
58-
59-
<plugin>
60-
<groupId>org.apache.maven.plugins</groupId>
61-
<artifactId>maven-assembly-plugin</artifactId>
62-
<version>3.1.1</version>
63-
<configuration>
64-
<descriptorRefs>
65-
<descriptorRef>jar-with-dependencies</descriptorRef>
66-
</descriptorRefs>
67-
</configuration>
68-
<executions>
69-
<execution>
70-
<id>make-assembly</id> <!-- this is used for inheritance merges -->
71-
<phase>package</phase> <!-- bind to the packaging phase -->
72-
<goals>
73-
<goal>single</goal>
74-
</goals>
75-
</execution>
76-
</executions>
77-
</plugin>
29+
<!--
7830
31+
-->
7932
<plugin>
8033
<groupId>org.apache.maven.plugins</groupId>
8134
<artifactId>maven-antrun-plugin</artifactId>
@@ -99,4 +52,54 @@
9952
</plugin>
10053
</plugins>
10154
</build>
55+
<profiles>
56+
<profile>
57+
<id>git-with-submodule</id>
58+
<build>
59+
<plugins>
60+
<plugin>
61+
<groupId>pl.project13.maven</groupId>
62+
<artifactId>git-commit-id-plugin</artifactId>
63+
<version>${git-commit-id-version}</version>
64+
<executions>
65+
<execution>
66+
<phase>initialize</phase>
67+
<id>get-the-git-infos-for-repository-one</id>
68+
<goals>
69+
<goal>revision</goal>
70+
</goals>
71+
<configuration>
72+
<prefix>git1</prefix>
73+
<dotGitDirectory>${project.basedir}/../.git</dotGitDirectory>
74+
<generateGitPropertiesFilename>${project.build.outputDirectory}/repository_one_git.properties</generateGitPropertiesFilename>
75+
</configuration>
76+
</execution>
77+
<execution>
78+
<phase>initialize</phase>
79+
<id>get-the-git-infos-for-repository-two</id>
80+
<goals>
81+
<goal>revision</goal>
82+
</goals>
83+
<configuration>
84+
<prefix>git2</prefix>
85+
<dotGitDirectory>${project.basedir}/../.git</dotGitDirectory>
86+
<generateGitPropertiesFilename>${project.build.outputDirectory}/repository_two_git.properties</generateGitPropertiesFilename>
87+
</configuration>
88+
</execution>
89+
</executions>
90+
<configuration>
91+
<prefix>git</prefix>
92+
<verbose>true</verbose>
93+
<skipPoms>false</skipPoms>
94+
<dotGitDirectory>${project.basedir}/../.git</dotGitDirectory>
95+
<injectAllReactorProjects>true</injectAllReactorProjects>
96+
<generateGitPropertiesFile>true</generateGitPropertiesFile>
97+
<evaluateOnCommit>HEAD</evaluateOnCommit>
98+
<generateGitPropertiesFilename>${project.build.outputDirectory}/git.properties</generateGitPropertiesFilename>
99+
</configuration>
100+
</plugin>
101+
</plugins>
102+
</build>
103+
</profile>
104+
</profiles>
102105
</project>

0 commit comments

Comments
 (0)