diff --git a/README.md b/README.md
index cbc5f46..b85daaf 100644
--- a/README.md
+++ b/README.md
@@ -7,7 +7,7 @@ It does so by:
* Enforcing [gitflow](http://nvie.com/posts/a-successful-git-branching-model/) version heuristics in [Maven](http://maven.apache.org/) projects.
* Coercing Maven to gracefully support the gitflow workflow without imposing complex CI job configurations or complex Maven setups.
* Setting distributionManagement repositories (for things like [maven-deploy-plugin](https://maven.apache.org/plugins/maven-deploy-plugin/)) based upon the current git branch.
- * SCM tagging builds for master and support branches. You can use the project SCM definition, or if you omit it, you can resolve the CI server's repository connection information. (Zero Maven scm configuration necessary)
+ * SCM tagging builds for master and support branches. You can use the project SCM definition, or if you omit it, you canO resolve the CI server's repository connection information. (Zero Maven scm configuration necessary)
* Promoting existing tested (staged) artifacts for release, rather than re-building the artifacts. Eliminates the risk of accidental master merges or commits resulting in untested code being released, and provides digest hash traceability for the history of artifacts.
* Enabling the decoupling of repository deployment and execution environment delivery based on the current git branch.
* Allowing for long-running non-release branches to be deployed to snapshots, automatically reversioning the artifacts based off the branch name.
@@ -98,19 +98,12 @@ All of the solutions to these issues are implemented independently in different
${gitflow.helper.plugin.version}
true
-
+
localnexus-releases
localnexus-stage
localnexus-snapshots
- (origin/)feature/poc/.*
+ (origin/)?feature/poc/.*
@@ -207,28 +200,48 @@ plugins in the build process (deploy, site-deploy, etc.) will use the repositori
**The repository properties should follow the following format**, `id::layout::url::uniqueVersion`.
-When using this plugin, the `` repository definitions can be completely removed from your pom.xml
-The following configuration block:
+When using this plugin, the `` repository definitions should be removed from your pom.xml
+This block, is replaced by defining 'normal' repositories which are then referenced by the `` and used by the gitflow-helper-maven-plugin to retarget artifact repository deployment and resolution.
snapshots
default
https://some.server.path/content/repositories/snapshots
- true
releases
default
https://some.server.path/content/repositories/releases
- false
-Can be replaced with the following plugin configuration, which also introduces the stage repository.
+Keep in mind repositories can be defined in a user settings.xml as part of your development profiles to keep from repeating yourself in project files.
+Below is an example configuration for the gitflow-helper-maven-plugin.
...
+
+
+ snapshots
+ https://some.server.path/content/repositories/snapshots
+ true
+ false
+
+
+ test-releases
+ https://some.server.path/content/repositories/test-releases
+ false
+ true
+
+
+ releases
+ https://some.server.path/content/repositories/releases
+ false
+ true
+
+
+ ...
@@ -236,9 +249,9 @@ Can be replaced with the following plugin configuration, which also introduces t
gitflow-helper-maven-plugin
${gitflow.helper.plugin.version}
- releases::default::https://some.server.path/content/repositories/releases::false
- stage::default::https://some.server.path/content/repositories/stage::false
- snapshots::default::https://some.server.path/content/repositories/snapshots::true
+ releases
+ stage
+ snapshots
@@ -405,7 +418,7 @@ You can then connect a remote debugger and step through the plugin code.
## Building with IntelliJ IDEA notes
### To Debug Test Code:
Configure the Maven commandline to include
-`-DforkMode=never` You will likely get warnings when you run maven with this argument.
+`-DforkCount=0`
### To inspect code-coverage results from Integration Tests:
* Select the **Analyze** -> **Show Coverage Data** menu.
diff --git a/pom.xml b/pom.xml
index 32d30af..42ca27e 100644
--- a/pom.xml
+++ b/pom.xml
@@ -3,12 +3,12 @@
4.0.0
- 3.1
+ 3.6.0
com.e-gineering
gitflow-helper-maven-plugin
- 2.2.0
+ 3.0.0
maven-plugin
@@ -49,8 +49,8 @@
- 1.7
- 1.7
+ 1.8
+ 1.8
UTF-8
${project.build.directory}/it-repositories
${project.version}
@@ -78,52 +78,30 @@
org.apache.maven
maven-core
- 3.1.0
+ 3.6.0
provided
-
- org.apache.maven
- maven-compat
- 3.1.0
- provided
-
-
- org.apache.maven
- maven-plugin-api
- 3.1.0
-
org.apache.maven.scm
maven-scm-api
- 1.11.1
+ 1.11.2
org.apache.maven.scm
maven-scm-manager-plexus
- 1.11.1
+ 1.11.2
org.apache.maven.scm
maven-scm-provider-gitexe
- 1.11.1
+ 1.11.2
org.apache.maven.plugin-tools
maven-plugin-annotations
- 3.1
+ 3.6.0
provided
-
- org.apache.maven
- maven-aether-provider
- 3.1.0
- provided
-
-
- org.eclipse.aether
- aether-util
- 0.9.0.M2
-
@@ -196,7 +174,7 @@
org.jacoco
jacoco-maven-plugin
- 0.8.1
+ 0.8.4
default-prepare-agent
@@ -224,7 +202,7 @@
org.apache.maven.plugins
maven-surefire-plugin
- 2.22.0
+ 2.22.2
${argLine}
@@ -237,7 +215,7 @@
org.apache.maven.plugins
maven-failsafe-plugin
- 2.22.0
+ 2.22.2
diff --git a/src/main/java/com/e_gineering/maven/gitflowhelper/AbstractGitflowBasedRepositoryMojo.java b/src/main/java/com/e_gineering/maven/gitflowhelper/AbstractGitflowBasedRepositoryMojo.java
index 01be97d..d091c57 100644
--- a/src/main/java/com/e_gineering/maven/gitflowhelper/AbstractGitflowBasedRepositoryMojo.java
+++ b/src/main/java/com/e_gineering/maven/gitflowhelper/AbstractGitflowBasedRepositoryMojo.java
@@ -1,20 +1,23 @@
package com.e_gineering.maven.gitflowhelper;
+import org.apache.maven.RepositoryUtils;
import org.apache.maven.artifact.Artifact;
+import org.apache.maven.artifact.InvalidRepositoryException;
import org.apache.maven.artifact.repository.ArtifactRepository;
-import org.apache.maven.artifact.repository.ArtifactRepositoryFactory;
-import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
-import org.apache.maven.model.Repository;
+import org.apache.maven.bridge.MavenRepositorySystem;
+import org.apache.maven.model.DeploymentRepository;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.plugins.annotations.Component;
import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.project.MavenProjectHelper;
+import org.apache.maven.shared.utils.StringUtils;
+import org.codehaus.plexus.component.annotations.Requirement;
import org.codehaus.plexus.util.FileUtils;
import org.eclipse.aether.DefaultRepositorySystemSession;
+import org.eclipse.aether.RepositorySystem;
import org.eclipse.aether.RepositorySystemSession;
import org.eclipse.aether.artifact.DefaultArtifact;
-import org.eclipse.aether.impl.ArtifactResolver;
import org.eclipse.aether.internal.impl.EnhancedLocalRepositoryManagerFactory;
import org.eclipse.aether.repository.LocalRepository;
import org.eclipse.aether.repository.RemoteRepository;
@@ -22,7 +25,6 @@
import org.eclipse.aether.resolution.ArtifactRequest;
import org.eclipse.aether.resolution.ArtifactResolutionException;
import org.eclipse.aether.resolution.ArtifactResult;
-import org.eclipse.aether.util.repository.AuthenticationBuilder;
import javax.annotation.Nullable;
import java.io.BufferedReader;
@@ -36,175 +38,70 @@
import java.io.PrintWriter;
import java.nio.file.Files;
import java.util.ArrayList;
-import java.util.Collections;
+import java.util.Arrays;
import java.util.List;
-import java.util.Map;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
+import java.util.Objects;
+import java.util.Optional;
-import static com.google.common.base.Preconditions.checkNotNull;
import static java.nio.charset.StandardCharsets.UTF_8;
/**
* Common configuration and plumbing (support methods) for Repository operations on Gitflow Mojo.
*/
abstract class AbstractGitflowBasedRepositoryMojo extends AbstractGitflowBranchMojo {
-
- private static final Pattern ALT_REPO_SYNTAX_PATTERN = Pattern.compile("(.+)::(.+)::(.+)::(.+)");
private static final String CATALOG_HEADER = "[artifacts]";
- /**
- * Returns the policy or a default policy if {@code policy} is null.
- *
- * @param policy the policy to check
- * @return the {@link org.apache.maven.model.RepositoryPolicy}
- */
- private static org.apache.maven.model.RepositoryPolicy ensureRepositoryPolicy(
- @Nullable org.apache.maven.model.RepositoryPolicy policy) {
- if (policy == null) {
- return new org.apache.maven.model.RepositoryPolicy();
- }
- return policy;
- }
-
private static PrintWriter newPrintWriter(File catalog) throws FileNotFoundException {
- checkNotNull(catalog, "catalog must not be null");
+ Objects.requireNonNull(catalog, "catalog must not be null");
return new PrintWriter(new OutputStreamWriter(new FileOutputStream(catalog), UTF_8));
}
-
- @Parameter(property = "releaseDeploymentRepository", required = true)
+
+ @Parameter(property = "releaseDeploymentRepositoryId", required = true)
String releaseDeploymentRepository;
- @Parameter(property = "stageDeploymentRepository", required = true)
+ @Parameter(property = "stageDeploymentRepositoryId", required = true)
String stageDeploymentRepository;
- @Parameter(property = "snapshotDeploymentRepository", required = true)
+ @Parameter(property = "snapshotDeploymentRepositoryId", required = true)
String snapshotDeploymentRepository;
-
- @Parameter(defaultValue = "${repositorySystemSession}", required = true)
- RepositorySystemSession session;
-
+
@Parameter(property = "otherDeployBranchPattern", required = false)
String otherDeployBranchPattern;
@Parameter(defaultValue = "+", required = true)
String otherBranchVersionDelimiter;
-
- @Component
- private EnhancedLocalRepositoryManagerFactory localRepositoryManagerFactory;
-
+
+ @Parameter(defaultValue = "${repositorySystemSession}", required = true)
+ RepositorySystemSession repositorySystemSession;
+
@Parameter(defaultValue = "${project.build.directory}", required = true)
private File buildDirectory;
-
+
@Component
- private ArtifactRepositoryFactory repositoryFactory;
-
+ private RepositorySystem repositorySystem;
+
@Component
- private ArtifactResolver artifactResolver;
-
+ private EnhancedLocalRepositoryManagerFactory localRepositoryManagerFactory;
+
@Component
private MavenProjectHelper projectHelper;
-
- @Component(role = ArtifactRepositoryLayout.class)
- private Map repositoryLayouts;
-
- @Component
- private GavCoordinateHelperFactory gavCoordinateFactory;
-
- private GavCoordinateHelper gavCoordinateHelper;
-
- @Override
- public void execute() throws MojoExecutionException, MojoFailureException {
- gavCoordinateHelper = gavCoordinateFactory.using(session);
-
- super.execute();
- }
-
+
/**
- * Builds an ArtifactRepository for targeting deployments.
+ * Creates a Maven ArtifactRepository for targeting deployments.
*
- * @param altRepository the repository identifier or alt-syntax specification
+ * @param id the repository identifier
* @return the resolved repository
- * @throws MojoExecutionException if the provided repository specification defines an invalid repository layout
- * @throws MojoFailureException if the provided repository specification is invalid
- */
- ArtifactRepository getDeploymentRepository(final String altRepository)
- throws MojoExecutionException, MojoFailureException {
- Matcher matcher = ALT_REPO_SYNTAX_PATTERN.matcher(altRepository);
- Repository candidate = null;
- if (!matcher.matches()) {
- for (int i = 0; i < project.getRepositories().size(); i++) {
- candidate = project.getRepositories().get(i);
- getLog().debug("Checking defined repository ID: " + candidate.getId().trim() + " against: " + altRepository.trim());
- if (candidate.getId().trim().equals(altRepository.trim())) {
- break;
- }
- candidate = null;
- }
-
- if (candidate == null) {
- throw new MojoFailureException(altRepository, "Invalid syntax for repository or repository id not resolved..",
- "Invalid syntax for repository. Use \"id::layout::url::unique\" or only specify the \"id\"." +
- " For the \"id\", make sure that the corresponding element has been defined (e.g. in the ~/.m2/settings.xml file)");
- }
- }
-
- if (getLog().isDebugEnabled()) {
- getLog().debug("Getting maven deployment repository (to target artifacts) for: " + altRepository);
- }
-
- if (candidate == null) {
- String id = matcher.group(1).trim();
- String layout = matcher.group(2).trim();
- String url = matcher.group(3).trim();
- boolean unique = Boolean.parseBoolean(matcher.group(4).trim());
-
- ArtifactRepositoryLayout repoLayout = getLayout(layout);
-
- return repositoryFactory.createDeploymentArtifactRepository(id, url, repoLayout, unique);
- } else {
- return repositoryFactory.createDeploymentArtifactRepository(
- candidate.getId(),
- candidate.getUrl(),
- getLayout(candidate.getLayout()),
- ensureRepositoryPolicy(candidate.getSnapshots()).isEnabled()
- );
- }
- }
-
- /**
- * Builds a RemoteRepository for resolving artifacts.
*
- * @param altRepository the repository identifier or alt-syntax specification
- * @return the resolve remote repository
- * @throws MojoExecutionException if the provided repository specification defines an invalid repository layout
- * @throws MojoFailureException if the provided repository specification is invalid
+ * @throws MojoFailureException if the repository id is not defined.
*/
- RemoteRepository getRepository(final String altRepository) throws MojoExecutionException, MojoFailureException {
- if (getLog().isDebugEnabled()) {
- getLog().debug("Creating remote Aether repository (to resolve remote artifacts) for: " + altRepository);
- }
- // Get an appropriate injected ArtifactRepository. (This resolves authentication in the 'normal' manner from Maven)
- ArtifactRepository remoteArtifactRepo = getDeploymentRepository(altRepository);
-
- if (getLog().isDebugEnabled()) {
- getLog().debug("Resolved maven deployment repository. Transcribing to Aether Repository...");
- }
-
- RemoteRepository.Builder remoteRepoBuilder = new RemoteRepository.Builder(remoteArtifactRepo.getId(), remoteArtifactRepo.getLayout().getId(), remoteArtifactRepo.getUrl());
+ ArtifactRepository getDeploymentRepository(final String id) throws MojoFailureException {
+ Objects.requireNonNull(id, "A repository id must be specified.");
+ Optional repo = project.getRemoteArtifactRepositories().stream().filter(r -> r.getId().equals(id)).findFirst();
- // Add authentication.
- if (remoteArtifactRepo.getAuthentication() != null) {
- if (getLog().isDebugEnabled()) {
- getLog().debug("Maven deployment repsoitory has Authentication. Transcribing to Aether Authentication...");
- }
- remoteRepoBuilder.setAuthentication(new AuthenticationBuilder().addUsername(remoteArtifactRepo.getAuthentication().getUsername())
- .addPassword(remoteArtifactRepo.getAuthentication().getPassword())
- .addPrivateKey(remoteArtifactRepo.getAuthentication().getPrivateKey(), remoteArtifactRepo.getAuthentication().getPassphrase())
- .build());
+ if (!repo.isPresent()) {
+ throw new MojoFailureException("No Repository with id `" + id + "` is defined.");
}
-
- return remoteRepoBuilder.build();
+ return repo.get();
}
/**
@@ -260,7 +157,7 @@ void attachArtifactCatalog() throws MojoExecutionException {
}
private void catalogArtifact(PrintWriter writer, Artifact artifact) {
- String coords = gavCoordinateHelper.getCoordinates(artifact);
+ String coords = getCoordinates(artifact);
getLog().info("Cataloging: " + coords);
writer.println(coords);
}
@@ -269,31 +166,31 @@ private void catalogArtifact(PrintWriter writer, Artifact artifact) {
* Resolves artifacts from the given sourceRepository by first resolving and processing the artifact catalog
* created by the promote-master mojo.
*
- * @param sourceRepository the repository identifier or alt-syntax specification
- * @param disableLocal if the staged artifacts should be downloaded to an isolated repository
+ * @param sourceRepository An ArtifactRepository to use as a RemoteRepository when supplied. Otherwise, only the local repository will be used.
+ * @param disableLocal if artifacts should be downloaded from a remote to an isolated repository, bypassing the 'standard' maven local repo.
+ *
* @throws MojoExecutionException for any unhandled maven exception
- * @throws MojoFailureException if the provided repository specification is invalid
*/
- void attachExistingArtifacts(final String sourceRepository, final boolean disableLocal)
+ void attachExistingArtifacts(@Nullable final String sourceRepository, final boolean disableLocal)
throws MojoExecutionException, MojoFailureException {
- List remoteRepositories = new ArrayList<>();
-
- if (sourceRepository == null) {
+
+ List remoteArtifactRepositories = new ArrayList<>();
+ Optional repo = project.getRemoteArtifactRepositories().stream().filter(r -> r.getId().equals(sourceRepository)).findFirst();
+ if (repo.isPresent()) {
+ remoteArtifactRepositories.add(repo.get());
+ } else {
if (disableLocal) {
throw new MojoExecutionException("Cannot resolve artifacts from 'null' repository if the local repository is also disabled.");
}
getLog().debug("Resolving existing artifacts from local repository only.");
- } else {
- // Add the remote repository.
- remoteRepositories.addAll(Collections.singletonList(getRepository(sourceRepository)));
}
-
+ List remoteRepositories = RepositoryUtils.toRepos(remoteArtifactRepositories);
+
// A place to store our resolved files...
List resolvedArtifacts = new ArrayList<>();
-
- // Use a custom repository session, setup to force a few behaviors we like.
- DefaultRepositorySystemSession tempSession = new DefaultRepositorySystemSession(session);
+ // Use a customized repository session, setup to force a few behaviors we like.
+ DefaultRepositorySystemSession tempSession = new DefaultRepositorySystemSession(repositorySystemSession);
tempSession.setUpdatePolicy(RepositoryPolicy.UPDATE_POLICY_ALWAYS);
File tempRepo = null;
@@ -308,6 +205,7 @@ void attachExistingArtifacts(final String sourceRepository, final boolean disabl
getLog().warn("Failed to disable local repository path.", ex);
}
}
+ tempSession.setReadOnly();
List requiredArtifacts = new ArrayList<>();
@@ -318,7 +216,7 @@ void attachExistingArtifacts(final String sourceRepository, final boolean disabl
project.getGroupId(), project.getArtifactId(), "catalog", "txt", project.getVersion()
);
ArtifactRequest request = new ArtifactRequest(artifact, remoteRepositories, null);
- ArtifactResult catalogResult = artifactResolver.resolveArtifact(tempSession, request);
+ ArtifactResult catalogResult = repositorySystem.resolveArtifact(tempSession, request);
resolvedArtifacts.add(catalogResult);
if (catalogResult.isResolved()) {
@@ -357,14 +255,13 @@ void attachExistingArtifacts(final String sourceRepository, final boolean disabl
// Resolve the artifacts from the catalog (if there are any)
try {
- resolvedArtifacts.addAll(artifactResolver.resolveArtifacts(tempSession, requiredArtifacts));
+ resolvedArtifacts.addAll(repositorySystem.resolveArtifacts(tempSession, requiredArtifacts));
} catch (ArtifactResolutionException are) {
- throw new MojoExecutionException("Failed to resolve the required project files from: " +
- sourceRepository, are);
+ throw new MojoExecutionException("Failed to resolve the required project files from repository: " + sourceRepository, are);
}
// Get the current build artifact coordinates, so that we replace rather than re-attach.
- String projectArtifactCoordinates = gavCoordinateHelper.getCoordinates(project.getArtifact());
+ String projectArtifactCoordinates = getCoordinates(project.getArtifact());
getLog().debug("Current Project Coordinates: " + projectArtifactCoordinates);
// For each artifactResult, copy it to the build directory,
@@ -375,12 +272,12 @@ void attachExistingArtifacts(final String sourceRepository, final boolean disabl
FileUtils.copyFileToDirectory(artifactResult.getArtifact().getFile(), buildDirectory);
artifactResult.setArtifact(artifactResult.getArtifact().setFile(new File(buildDirectory, artifactResult.getArtifact().getFile().getName())));
- if (gavCoordinateHelper.getCoordinates(artifactResult).equals(projectArtifactCoordinates)) {
+ if (getCoordinates(artifactResult).equals(projectArtifactCoordinates)) {
getLog().debug(" Setting primary artifact: " + artifactResult.getArtifact().getFile());
project.getArtifact().setFile(artifactResult.getArtifact().getFile());
} else {
getLog().debug(
- " Attaching artifact: " + gavCoordinateHelper.getCoordinates(artifactResult) + " "
+ " Attaching artifact: " + getCoordinates(artifactResult) + " "
+ artifactResult.getArtifact().getFile());
projectHelper.attachArtifact(project, artifactResult.getArtifact().getExtension(), artifactResult.getArtifact().getClassifier(), artifactResult.getArtifact().getFile());
}
@@ -401,15 +298,6 @@ void attachExistingArtifacts(final String sourceRepository, final boolean disabl
}
}
- private ArtifactRepositoryLayout getLayout(final String id) throws MojoExecutionException {
- ArtifactRepositoryLayout layout = repositoryLayouts.get(id);
- if (layout == null) {
- throw new MojoExecutionException("Invalid repository layout: " + id);
- }
-
- return layout;
- }
-
/**
* Returns true if the project has any artifacts to be catalogued.
*
@@ -432,4 +320,54 @@ private boolean hasFile(@Nullable Artifact artifact) {
&& project.getArtifact().getFile().exists()
&& project.getArtifact().getFile().isFile();
}
+
+
+ private String getCoordinates(ArtifactResult artifactResult) {
+ return getCoordinates(
+ emptyToNull(artifactResult.getArtifact().getGroupId()),
+ emptyToNull(artifactResult.getArtifact().getArtifactId()),
+ emptyToNull(artifactResult.getArtifact().getBaseVersion()),
+ emptyToNull(artifactResult.getArtifact().getExtension()),
+ emptyToNull(artifactResult.getArtifact().getClassifier())
+ );
+ }
+
+ private static String emptyToNull(final String s) {
+ return StringUtils.isBlank(s) ? null : s;
+ }
+
+ private String getCoordinates(Artifact artifact) {
+ getLog().debug(" Encoding Coordinates For: " + artifact);
+
+ // Get the extension according to the artifact type.
+ String extension = artifact.getArtifactHandler().getExtension();
+
+ return getCoordinates(
+ artifact.getGroupId(),
+ artifact.getArtifactId(),
+ project.getVersion(),
+ extension, artifact.hasClassifier() ? artifact.getClassifier() : null
+ );
+ }
+
+ private String getCoordinates(String groupId,
+ String artifactId,
+ String version,
+ @Nullable String extension,
+ @Nullable String classifier) {
+ Objects.requireNonNull(groupId, "groupId must not be null");
+ Objects.requireNonNull(artifactId, "artifactId must not be null");
+ Objects.requireNonNull(version, "version must not be null");
+
+ StringBuilder result = new StringBuilder();
+ for (String s : new String[]{groupId, artifactId, extension, classifier, version}) {
+ if (s != null) {
+ if (result.length() > 0) {
+ result.append(":");
+ }
+ result.append(s);
+ }
+ }
+ return result.toString();
+ }
}
diff --git a/src/main/java/com/e_gineering/maven/gitflowhelper/AttachDeployedArtifactsMojo.java b/src/main/java/com/e_gineering/maven/gitflowhelper/AttachDeployedArtifactsMojo.java
index 09030f2..29ce797 100644
--- a/src/main/java/com/e_gineering/maven/gitflowhelper/AttachDeployedArtifactsMojo.java
+++ b/src/main/java/com/e_gineering/maven/gitflowhelper/AttachDeployedArtifactsMojo.java
@@ -1,6 +1,7 @@
package com.e_gineering.maven.gitflowhelper;
import org.apache.maven.artifact.Artifact;
+import org.apache.maven.artifact.InvalidRepositoryException;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.plugins.annotations.Execute;
diff --git a/src/main/java/com/e_gineering/maven/gitflowhelper/DefaultGavCoordinateHelper.java b/src/main/java/com/e_gineering/maven/gitflowhelper/DefaultGavCoordinateHelper.java
deleted file mode 100644
index ae9c75c..0000000
--- a/src/main/java/com/e_gineering/maven/gitflowhelper/DefaultGavCoordinateHelper.java
+++ /dev/null
@@ -1,97 +0,0 @@
-package com.e_gineering.maven.gitflowhelper;
-
-import com.google.common.base.Joiner;
-import org.apache.maven.artifact.Artifact;
-import org.apache.maven.project.MavenProject;
-import org.codehaus.plexus.logging.Logger;
-import org.eclipse.aether.RepositorySystemSession;
-import org.eclipse.aether.resolution.ArtifactResult;
-
-import javax.annotation.Nullable;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-import static com.google.common.base.Strings.emptyToNull;
-
-/**
- * A helper factory for creating maven (GroupId, ArtifactId, Extension, Classifier, Version) coordinates.
- */
-class DefaultGavCoordinateHelper implements GavCoordinateHelper {
-
- private static final Joiner GAV_JOINER = Joiner.on(':').skipNulls();
-
- private final Logger log;
-
- private final MavenProject project;
-
- private final RepositorySystemSession session;
-
- /**
- * Creates a new {@link DefaultGavCoordinateHelperFactory}.
- *
- * @param session the repository session
- * @param project the project
- * @param log the logger
- */
- DefaultGavCoordinateHelper(RepositorySystemSession session, MavenProject project, Logger log) {
- this.session = checkNotNull(session, "session must not be null");
- this.project = checkNotNull(project, "project must not be null");
- this.log = checkNotNull(log, "log must not be null");
- }
-
- @Override
- public String getCoordinates(ArtifactResult result) {
- return getCoordinates(result.getArtifact());
- }
-
- @Override
- public String getCoordinates(org.eclipse.aether.artifact.Artifact artifact) {
- return getCoordinates(
- emptyToNull(artifact.getGroupId()),
- emptyToNull(artifact.getArtifactId()),
- emptyToNull(artifact.getBaseVersion()),
- emptyToNull(artifact.getExtension()),
- emptyToNull(artifact.getClassifier())
- );
- }
-
- @Override
- public String getCoordinates(Artifact artifact) {
- log.debug(" Encoding Coordinates For: " + artifact);
-
- // Get the extension according to the artifact type.
- String extension = session.getArtifactTypeRegistry().get(artifact.getType()).getExtension();
-
- // assert that the file extension matches the artifact packaging extension type, if there is an artifact file.
- if (artifact.getFile() != null && !artifact.getFile().getName().toLowerCase().endsWith(extension.toLowerCase())) {
- String filename = artifact.getFile().getName();
- String fileExtension = filename.substring(filename.lastIndexOf('.') + 1);
- log.warn(
- " Artifact file name: " + artifact.getFile().getName() + " of type "
- + artifact.getType() + " does not match the extension for the ArtifactType: "
- + extension + ". "
- + "This is likely an issue with the packaging definition for '" + artifact.getType()
- + "' artifacts, which may be missing an extension definition. "
- + "The gitflow helper catalog will use the actual file extension: " + fileExtension
- );
- extension = fileExtension;
- }
-
- return getCoordinates(
- artifact.getGroupId(),
- artifact.getArtifactId(),
- project.getVersion(),
- extension, artifact.hasClassifier() ? artifact.getClassifier() : null
- );
- }
-
- private String getCoordinates(String groupId,
- String artifactId,
- String version,
- @Nullable String extension,
- @Nullable String classifier) {
- checkNotNull(groupId, "groupId must not be null");
- checkNotNull(artifactId, "artifactId must not be null");
- checkNotNull(version, "version must not be null");
- return GAV_JOINER.join(groupId, artifactId, extension, classifier, version);
- }
-}
diff --git a/src/main/java/com/e_gineering/maven/gitflowhelper/DefaultGavCoordinateHelperFactory.java b/src/main/java/com/e_gineering/maven/gitflowhelper/DefaultGavCoordinateHelperFactory.java
deleted file mode 100644
index 79399e5..0000000
--- a/src/main/java/com/e_gineering/maven/gitflowhelper/DefaultGavCoordinateHelperFactory.java
+++ /dev/null
@@ -1,25 +0,0 @@
-package com.e_gineering.maven.gitflowhelper;
-
-import org.apache.maven.project.MavenProject;
-import org.codehaus.plexus.component.annotations.Component;
-import org.codehaus.plexus.component.annotations.Requirement;
-import org.codehaus.plexus.logging.Logger;
-import org.eclipse.aether.RepositorySystemSession;
-
-/**
- * A helper factory for creating {@link GavCoordinateHelper} instances scoped to a repository session.
- */
-@Component(role = GavCoordinateHelperFactory.class)
-class DefaultGavCoordinateHelperFactory implements GavCoordinateHelperFactory {
-
- @Requirement
- private Logger log;
-
- @Requirement
- private MavenProject project;
-
- @Override
- public GavCoordinateHelper using(RepositorySystemSession session) {
- return new DefaultGavCoordinateHelper(session, project, log);
- }
-}
diff --git a/src/main/java/com/e_gineering/maven/gitflowhelper/GavCoordinateHelper.java b/src/main/java/com/e_gineering/maven/gitflowhelper/GavCoordinateHelper.java
deleted file mode 100644
index ec1a65d..0000000
--- a/src/main/java/com/e_gineering/maven/gitflowhelper/GavCoordinateHelper.java
+++ /dev/null
@@ -1,33 +0,0 @@
-package com.e_gineering.maven.gitflowhelper;
-
-import org.apache.maven.artifact.Artifact;
-import org.eclipse.aether.resolution.ArtifactResult;
-
-/**
- * A helper factory for creating maven (GroupId, ArtifactId, Extension, Classifier, Version) coordinates.
- */
-public interface GavCoordinateHelper {
- /**
- * Get GAV coordinates for the {@link ArtifactResult}.
- *
- * @param result the result
- * @return the GAV coordinate string
- */
- String getCoordinates(ArtifactResult result);
-
- /**
- * Get GAV coordinates for the {@link org.eclipse.aether.artifact.Artifact}.
- *
- * @param artifact the artifact
- * @return the GAV coordinate string
- */
- String getCoordinates(org.eclipse.aether.artifact.Artifact artifact);
-
- /**
- * Get GAV coordinates for the {@link Artifact}.
- *
- * @param artifact the artifact
- * @return the GAV coordinate string
- */
- String getCoordinates(Artifact artifact);
-}
diff --git a/src/main/java/com/e_gineering/maven/gitflowhelper/GavCoordinateHelperFactory.java b/src/main/java/com/e_gineering/maven/gitflowhelper/GavCoordinateHelperFactory.java
deleted file mode 100644
index 6e740ac..0000000
--- a/src/main/java/com/e_gineering/maven/gitflowhelper/GavCoordinateHelperFactory.java
+++ /dev/null
@@ -1,19 +0,0 @@
-package com.e_gineering.maven.gitflowhelper;
-
-import org.eclipse.aether.RepositorySystemSession;
-
-/**
- * A {@link GavCoordinateHelper} factory.
- */
-public interface GavCoordinateHelperFactory {
-
- String ROLE = GavCoordinateHelperFactory.class.getName();
-
- /**
- * Create a coordinate helper scoped to the {@link RepositorySystemSession}.
- *
- * @param session the session
- * @return the coordinate helper
- */
- GavCoordinateHelper using(RepositorySystemSession session);
-}
diff --git a/src/main/java/com/e_gineering/maven/gitflowhelper/PromoteMasterMojo.java b/src/main/java/com/e_gineering/maven/gitflowhelper/PromoteMasterMojo.java
index c8d8789..3df1c1f 100644
--- a/src/main/java/com/e_gineering/maven/gitflowhelper/PromoteMasterMojo.java
+++ b/src/main/java/com/e_gineering/maven/gitflowhelper/PromoteMasterMojo.java
@@ -1,6 +1,7 @@
package com.e_gineering.maven.gitflowhelper;
import org.apache.maven.artifact.Artifact;
+import org.apache.maven.artifact.InvalidRepositoryException;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.plugins.annotations.LifecyclePhase;
diff --git a/src/main/java/com/e_gineering/maven/gitflowhelper/RetargetDeployMojo.java b/src/main/java/com/e_gineering/maven/gitflowhelper/RetargetDeployMojo.java
index e569506..4bb30ee 100644
--- a/src/main/java/com/e_gineering/maven/gitflowhelper/RetargetDeployMojo.java
+++ b/src/main/java/com/e_gineering/maven/gitflowhelper/RetargetDeployMojo.java
@@ -1,7 +1,9 @@
package com.e_gineering.maven.gitflowhelper;
import org.apache.maven.artifact.Artifact;
+import org.apache.maven.artifact.InvalidRepositoryException;
import org.apache.maven.artifact.versioning.VersionRange;
+import org.apache.maven.model.DeploymentRepository;
import org.apache.maven.model.DistributionManagement;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
@@ -15,6 +17,7 @@
public class RetargetDeployMojo extends AbstractGitflowBasedRepositoryMojo {
@Override
protected void execute(final GitBranchInfo gitBranchInfo) throws MojoExecutionException, MojoFailureException {
+ // Ensure we have a 'null' distribution management for other plugins which expect it.
if (project.getDistributionManagement() == null) {
project.setDistributionManagement(new DistributionManagement());
}
diff --git a/src/main/java/com/e_gineering/maven/gitflowhelper/UpdateStageDependenciesMojo.java b/src/main/java/com/e_gineering/maven/gitflowhelper/UpdateStageDependenciesMojo.java
index 8cd0307..74d84b2 100644
--- a/src/main/java/com/e_gineering/maven/gitflowhelper/UpdateStageDependenciesMojo.java
+++ b/src/main/java/com/e_gineering/maven/gitflowhelper/UpdateStageDependenciesMojo.java
@@ -1,6 +1,8 @@
package com.e_gineering.maven.gitflowhelper;
import org.apache.commons.io.FileUtils;
+import org.apache.maven.RepositoryUtils;
+import org.apache.maven.artifact.InvalidRepositoryException;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.plugins.annotations.Component;
@@ -20,6 +22,7 @@
import java.io.File;
import java.io.IOException;
+import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
@@ -36,14 +39,14 @@ public class UpdateStageDependenciesMojo extends AbstractGitflowBasedRepositoryM
protected void execute(final GitBranchInfo branchInfo) throws MojoExecutionException, MojoFailureException {
getLog().debug("update-stage-dependencies setting up Repository session...");
- DefaultRepositorySystemSession reresolveSession = new DefaultRepositorySystemSession(session);
+ DefaultRepositorySystemSession reresolveSession = new DefaultRepositorySystemSession(repositorySystemSession);
reresolveSession.setUpdatePolicy(org.eclipse.aether.repository.RepositoryPolicy.UPDATE_POLICY_ALWAYS);
reresolveSession.setCache(new DefaultRepositoryCache());
LocalRepositoryManager localRepositoryManager = reresolveSession.getLocalRepositoryManager();
getLog().debug("configuring stage as the remote repository for artifact resolution requests...");
- List stageRepo = Arrays.asList(getRepository(stageDeploymentRepository));
+ List stageRepo = Arrays.asList(RepositoryUtils.toRepo(getDeploymentRepository(stageDeploymentRepository)));
boolean itemsPurged = false;
diff --git a/src/test/java/com/e_gineering/maven/gitflowhelper/AbstractIntegrationTest.java b/src/test/java/com/e_gineering/maven/gitflowhelper/AbstractIntegrationTest.java
index 2ddc38e..526a972 100644
--- a/src/test/java/com/e_gineering/maven/gitflowhelper/AbstractIntegrationTest.java
+++ b/src/test/java/com/e_gineering/maven/gitflowhelper/AbstractIntegrationTest.java
@@ -74,8 +74,8 @@ private Verifier createVerifier(String basedir, String settings, String gitBranc
verifier.getSystemProperties().put("maven.multiModuleProjectDirectory", basedir);
- verifier.getSystemProperties().put("maven.compiler.source", "1.7");
- verifier.getSystemProperties().put("maven.compiler.target", "1.7");
+ verifier.getSystemProperties().put("maven.compiler.source", "1.8");
+ verifier.getSystemProperties().put("maven.compiler.target", "1.8");
return verifier;
}
diff --git a/src/test/resources/project-stub/pom.xml b/src/test/resources/project-stub/pom.xml
index 5a47f8a..a4bd877 100644
--- a/src/test/resources/project-stub/pom.xml
+++ b/src/test/resources/project-stub/pom.xml
@@ -6,7 +6,7 @@
gitflow-helper-maven-plugin-test-stub
${stub.project.version}
- jar
+ bundle
@@ -15,12 +15,12 @@
false
true
-
-
-
-
-
-
+
+ test-releases
+ file:${it.repository.basedir}/test-releases
+ false
+ true
+
snapshots
file:${it.repository.basedir}/snapshots
@@ -48,7 +48,7 @@
true
releases
- test-releases::default::file:${it.repository.basedir}/test-releases::false
+ test-releases
snapshots
src/build/resources/master.build.properties
@@ -91,6 +91,33 @@
+
+ org.codehaus.mojo
+ build-helper-maven-plugin
+ 3.0.0
+
+
+ attach-text-file
+
+ attach-artifact
+
+
+
+
+ src/build/resources/my-text-file.txt
+ text-file
+
+
+
+
+
+
+
+ org.apache.felix
+ maven-bundle-plugin
+ 4.2.0
+ true
+
diff --git a/src/test/resources/project-stub/src/build/resources/my-text-file.txt b/src/test/resources/project-stub/src/build/resources/my-text-file.txt
new file mode 100644
index 0000000..0c759a4
--- /dev/null
+++ b/src/test/resources/project-stub/src/build/resources/my-text-file.txt
@@ -0,0 +1 @@
+test123
\ No newline at end of file