Issue
I used git-crypt (https://github.com/AGWA/git-crypt) to encrypt a property file containing sensitive data (passwords etc.) in my Java Maven project.
Preparing of the release run without problems. But the execution of "mvn release:perform" failed because this operation do an automated:
- checkout release tag from SCM
- build and deploy released code
The problem is, that my property file is checked out encrypted and so the execution of some integration test failed.
It should be possible somehow to decrypt my file automatically during the release:perform process.
I need a solution kind of this:
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.6.0</version>
<executions>
<execution>
<phase>deploy</phase>
<goals>
<goal>exec</goal>
</goals>
</execution>
</executions>
<configuration>
<executable>cmd</executable>
<arguments>
<argument>/c</argument>
<argument>git-crypt unlock my-unlock-keyfile</argument>
</arguments>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>2.5.3</version>
<configuration>
<completionGoals>exec:exec</completionGoals>
</configuration>
</plugin>
</plugins>
</build>
But sadly this code works only for preparing releases.
Solution
I found a working solution now:
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.6.0</version>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>exec</goal>
</goals>
</execution>
</executions>
<configuration>
<executable>cmd</executable>
<arguments>
<argument>/c</argument>
<argument>git-crypt unlock path\to\my-unlock-keyfile</argument>
</arguments>
<successCodes>
<successCode>0</successCode>
<successCode>1</successCode> <!-- while release preparation exit code 1 it thrown because of unsaved changes; this is only a workaround; -->
</successCodes>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>2.5.3</version>
</plugin>
</plugins>
</build>
Answered By - ban