forked from danielflower/multi-module-maven-release-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow to ignore certain files from the Git repo change detection
This commit realign Fixes danielflower#77
- Loading branch information
1 parent
a29c38d
commit 68b7e43
Showing
9 changed files
with
303 additions
and
144 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,10 @@ | ||
package com.github.danielflower.mavenplugins.release; | ||
|
||
import static java.lang.String.format; | ||
|
||
import java.util.List; | ||
import java.util.Set; | ||
|
||
import org.apache.maven.artifact.factory.ArtifactFactory; | ||
import org.apache.maven.artifact.repository.ArtifactRepository; | ||
import org.apache.maven.artifact.resolver.ArtifactResolver; | ||
|
@@ -16,41 +21,38 @@ | |
import org.eclipse.jgit.transport.JschConfigSessionFactory; | ||
import org.eclipse.jgit.transport.UsernamePasswordCredentialsProvider; | ||
|
||
import java.util.List; | ||
|
||
import static java.lang.String.format; | ||
|
||
/** | ||
* @author Roland Hauser [email protected] | ||
* | ||
*/ | ||
public abstract class BaseMojo extends AbstractMojo { | ||
/** | ||
* The Maven Project. | ||
*/ | ||
@Parameter(property = "project", required = true, readonly = true, defaultValue = "${project}") | ||
protected MavenProject project; | ||
|
||
@Parameter(property = "projects", required = true, readonly = true, defaultValue = "${reactorProjects}") | ||
protected List<MavenProject> projects; | ||
|
||
/** | ||
* <p> | ||
* The build number to use in the release version. Given a snapshot version | ||
* of "1.0-SNAPSHOT" and a buildNumber value of "2", the actual released | ||
* version will be "1.0.2". | ||
* </p> | ||
* <p> | ||
* By default, the plugin will automatically find a suitable build number. | ||
* It will start at version 0 and increment this with each release. | ||
* </p> | ||
* <p> | ||
* This can be specified using a command line parameter ("-DbuildNumber=2") | ||
* or in this plugin's configuration. | ||
* </p> | ||
*/ | ||
@Parameter(property = "buildNumber") | ||
protected Long buildNumber; | ||
|
||
/** | ||
* The Maven Project. | ||
*/ | ||
@Parameter(property = "project", required = true, readonly = true, defaultValue = "${project}") | ||
protected MavenProject project; | ||
|
||
@Parameter(property = "projects", required = true, readonly = true, defaultValue = "${reactorProjects}") | ||
protected List<MavenProject> projects; | ||
|
||
/** | ||
* <p> | ||
* The build number to use in the release version. Given a snapshot version | ||
* of "1.0-SNAPSHOT" and a buildNumber value of "2", the actual released | ||
* version will be "1.0.2". | ||
* </p> | ||
* <p> | ||
* By default, the plugin will automatically find a suitable build number. | ||
* It will start at version 0 and increment this with each release. | ||
* </p> | ||
* <p> | ||
* This can be specified using a command line parameter ("-DbuildNumber=2") | ||
* or in this plugin's configuration. | ||
* </p> | ||
*/ | ||
@Parameter(property = "buildNumber") | ||
protected Long buildNumber; | ||
|
||
|
||
/** | ||
|
@@ -61,20 +63,20 @@ public abstract class BaseMojo extends AbstractMojo { | |
@Parameter(property = "versionNamer") | ||
protected VersionNamer versionNamer = new VersionNamer("."); | ||
|
||
/** | ||
* The modules to release, or no value to to release the project from the | ||
* root pom, which is the default. The selected module plus any other | ||
* modules it needs will be built and released also. When run from the | ||
* command line, this can be a comma-separated list of module names. | ||
*/ | ||
@Parameter(alias = "modulesToRelease", property = "modulesToRelease") | ||
protected List<String> modulesToRelease; | ||
|
||
/** | ||
* A module to force release on, even if no changes has been detected. | ||
*/ | ||
@Parameter(alias = "forceRelease", property = "forceRelease") | ||
protected List<String> modulesToForceRelease; | ||
/** | ||
* The modules to release, or no value to to release the project from the | ||
* root pom, which is the default. The selected module plus any other | ||
* modules it needs will be built and released also. When run from the | ||
* command line, this can be a comma-separated list of module names. | ||
*/ | ||
@Parameter(alias = "modulesToRelease", property = "modulesToRelease") | ||
protected List<String> modulesToRelease; | ||
|
||
/** | ||
* A module to force release on, even if no changes has been detected. | ||
*/ | ||
@Parameter(alias = "forceRelease", property = "forceRelease") | ||
protected List<String> modulesToForceRelease; | ||
|
||
/** | ||
* Determines the action to take when no module changes are detected. Possible values: | ||
|
@@ -108,40 +110,40 @@ public abstract class BaseMojo extends AbstractMojo { | |
@Parameter(property = "localRepository", required = true, readonly = true, defaultValue = "${localRepository}") | ||
protected ArtifactRepository localRepository; | ||
|
||
@Parameter(property = "disableSshAgent") | ||
private boolean disableSshAgent; | ||
@Parameter(property = "disableSshAgent") | ||
private boolean disableSshAgent; | ||
|
||
@Parameter(defaultValue = "${settings}", readonly = true, required = true) | ||
private Settings settings; | ||
@Parameter(defaultValue = "${settings}", readonly = true, required = true) | ||
private Settings settings; | ||
|
||
/** | ||
* <p>If set, the identityFile and passphrase will be read from the Maven settings file.</p> | ||
/** | ||
* <p>If set, the identityFile and passphrase will be read from the Maven settings file.</p> | ||
* <p>See <a href="https://maven.apache.org/guides/mini/guide-deployment-security-settings.html">https://maven.apache.org/guides/mini/guide-deployment-security-settings.html</a> | ||
* for more information on configuring servers in Maven.</p> | ||
*/ | ||
@Parameter(property = "serverId") | ||
private String serverId; | ||
|
||
/** | ||
* If set, this file will be used to specify the known_hosts. This will | ||
* override any default value. | ||
*/ | ||
@Parameter(property = "knownHosts") | ||
private String knownHosts; | ||
|
||
/** | ||
* Specifies the private key to be used for SSH URLs. By default it will use <code>~/.ssh/id_rsa</code> | ||
*/ | ||
@Parameter(property = "privateKey") | ||
private String privateKey; | ||
|
||
/** | ||
* <p>Specifies the passphrase to be used with the identityFile specified for SSH where the private key requires a pass phrase.</p> | ||
*/ | ||
@Parameter(property = "serverId") | ||
private String serverId; | ||
|
||
/** | ||
* If set, this file will be used to specify the known_hosts. This will | ||
* override any default value. | ||
*/ | ||
@Parameter(property = "knownHosts") | ||
private String knownHosts; | ||
|
||
/** | ||
* Specifies the private key to be used for SSH URLs. By default it will use <code>~/.ssh/id_rsa</code> | ||
*/ | ||
@Parameter(property = "privateKey") | ||
private String privateKey; | ||
|
||
/** | ||
* <p>Specifies the passphrase to be used with the identityFile specified for SSH where the private key requires a pass phrase.</p> | ||
* <p>To avoid specifying a passphrase in your pom, you could instead specify a <code>server</code> in your | ||
* maven settings file and then set the <code>serverId</code> property.</p> | ||
*/ | ||
@Parameter(property = "passphrase") | ||
private String passphrase; | ||
*/ | ||
@Parameter(property = "passphrase") | ||
private String passphrase; | ||
|
||
/** | ||
* Fetch tags from remote repository to determine the next build number. If | ||
|
@@ -161,35 +163,52 @@ public abstract class BaseMojo extends AbstractMojo { | |
@Parameter(property = "arguments") | ||
public String arguments; | ||
|
||
/** | ||
* <p>List of relative file system paths to ignore when detecting changes in the project(s).</p> | ||
* <p>The primary purpose is to skip creating new releases if only "infrastructure" files such as | ||
* <code>.gitignore</code>, <code>.editorconfig</code> and the like changed. Very basic wild cards are supported as | ||
* follows: | ||
* <ul> | ||
* <li><code>foo.txt</code> - matches <code>foo.txt</code> in the root of the top-level project</li> | ||
* <li><code>bar/foo.txt</code> - matches <code>foo.txt</code> in the root of the <code>bar</code> directory</li> | ||
* <li><code>bar</code> - matches the <code>foo</code> directory and ignores everything below</li> | ||
* <li><code>**.txt</code> - matches all paths ending in <code>.txt</code> (suffix match)</li> | ||
* <li><code>**.editorconfig</code> - matches all <code>.editorconfig</code> files in all (sub)directories; a special case of suffix matching</li> | ||
* <ul/> | ||
* <p/> | ||
*/ | ||
@Parameter(property = "ignoredPaths") | ||
Set<String> ignoredPaths; | ||
|
||
final void setSettings(final Settings settings) { | ||
this.settings = settings; | ||
} | ||
this.settings = settings; | ||
} | ||
|
||
final Settings getSettings() { | ||
return settings; | ||
} | ||
|
||
final void setServerId(final String serverId) { | ||
this.serverId = serverId; | ||
} | ||
final void setServerId(final String serverId) { | ||
this.serverId = serverId; | ||
} | ||
|
||
final void setKnownHosts(final String knownHosts) { | ||
this.knownHosts = knownHosts; | ||
} | ||
final void setKnownHosts(final String knownHosts) { | ||
this.knownHosts = knownHosts; | ||
} | ||
|
||
final void setPrivateKey(final String privateKey) { | ||
this.privateKey = privateKey; | ||
} | ||
final void setPrivateKey(final String privateKey) { | ||
this.privateKey = privateKey; | ||
} | ||
|
||
final void setPassphrase(final String passphrase) { | ||
this.passphrase = passphrase; | ||
} | ||
final void setPassphrase(final String passphrase) { | ||
this.passphrase = passphrase; | ||
} | ||
|
||
final void disableSshAgent() { | ||
disableSshAgent = true; | ||
} | ||
final void disableSshAgent() { | ||
disableSshAgent = true; | ||
} | ||
|
||
protected CredentialsProvider getCredentialsProvider(final Log log) throws ValidationException { | ||
protected CredentialsProvider getCredentialsProvider(final Log log) throws ValidationException { | ||
if (serverId != null) { | ||
Server server = settings.getServer(serverId); | ||
if (server == null) { | ||
|
@@ -204,21 +223,21 @@ protected CredentialsProvider getCredentialsProvider(final Log log) throws Valid | |
return null; | ||
} | ||
|
||
protected final void configureJsch(final Log log) { | ||
if (!disableSshAgent) { | ||
if (serverId != null) { | ||
final Server server = settings.getServer(serverId); | ||
if (server != null) { | ||
privateKey = privateKey == null ? server.getPrivateKey() : privateKey; | ||
passphrase = passphrase == null ? server.getPassphrase() : passphrase; | ||
} else { | ||
log.warn(format("No server configuration in Maven settings found with id %s", serverId)); | ||
} | ||
} | ||
|
||
JschConfigSessionFactory.setInstance(new SshAgentSessionFactory(log, knownHosts, privateKey, passphrase)); | ||
} | ||
} | ||
protected final void configureJsch(final Log log) { | ||
if (!disableSshAgent) { | ||
if (serverId != null) { | ||
final Server server = settings.getServer(serverId); | ||
if (server != null) { | ||
privateKey = privateKey == null ? server.getPrivateKey() : privateKey; | ||
passphrase = passphrase == null ? server.getPassphrase() : passphrase; | ||
} else { | ||
log.warn(format("No server configuration in Maven settings found with id %s", serverId)); | ||
} | ||
} | ||
|
||
JschConfigSessionFactory.setInstance(new SshAgentSessionFactory(log, knownHosts, privateKey, passphrase)); | ||
} | ||
} | ||
|
||
static void printBigErrorMessageAndThrow(Log log, String terseMessage, List<String> linesToLog) throws MojoExecutionException { | ||
log.error(""); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.