-
Notifications
You must be signed in to change notification settings - Fork 87
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix for WFMP-269, Support multiple deployments in the package goal
- Loading branch information
Showing
9 changed files
with
353 additions
and
21 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
74 changes: 74 additions & 0 deletions
74
plugin/src/main/java/org/wildfly/plugin/provision/DeploymentConfiguration.java
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 |
---|---|---|
@@ -0,0 +1,74 @@ | ||
/* | ||
* Copyright The WildFly Authors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
package org.wildfly.plugin.provision; | ||
|
||
/** | ||
* | ||
* @author jdenise | ||
*/ | ||
public class DeploymentConfiguration { | ||
|
||
private String groupId; | ||
private String artifactId; | ||
private String classifier; | ||
private String type = "jar"; | ||
private String name; | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public String getGroupId() { | ||
return groupId; | ||
} | ||
|
||
public String getArtifactId() { | ||
return artifactId; | ||
} | ||
|
||
public String getType() { | ||
return type; | ||
} | ||
|
||
public String getClassifier() { | ||
return classifier; | ||
} | ||
|
||
/** | ||
* @param groupId the groupId to set | ||
*/ | ||
public void setGroupId(String groupId) { | ||
this.groupId = groupId; | ||
} | ||
|
||
/** | ||
* @param artifactId the artifactId to set | ||
*/ | ||
public void setArtifactId(String artifactId) { | ||
this.artifactId = artifactId; | ||
} | ||
|
||
/** | ||
* @param classifier the classifier to set | ||
*/ | ||
public void setClassifier(String classifier) { | ||
this.classifier = classifier; | ||
} | ||
|
||
/** | ||
* @param type the type to set | ||
*/ | ||
public void setType(String type) { | ||
this.type = type; | ||
} | ||
|
||
/** | ||
* @param name the name to set | ||
*/ | ||
public void setName(String name) { | ||
this.name = name; | ||
} | ||
|
||
} |
67 changes: 67 additions & 0 deletions
67
plugin/src/main/java/org/wildfly/plugin/provision/DeploymentResolution.java
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 |
---|---|---|
@@ -0,0 +1,67 @@ | ||
/* | ||
* Copyright The WildFly Authors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
package org.wildfly.plugin.provision; | ||
|
||
import java.io.File; | ||
import java.util.Map; | ||
import java.util.Set; | ||
import java.util.TreeMap; | ||
|
||
import org.apache.maven.artifact.Artifact; | ||
import org.apache.maven.plugin.MojoExecutionException; | ||
import org.apache.maven.project.MavenProject; | ||
|
||
/** | ||
* Resolve possible deployments from the Maven project dependencies. | ||
*/ | ||
class DeploymentResolution { | ||
|
||
private static final String WAR = "war"; | ||
private static final String EAR = "ear"; | ||
private static final String RAR = "rar"; | ||
private static final String JAR = "jar"; | ||
private static final Set<String> SUPPORTED_DEPLOYMENT_TYPES = Set.of(EAR, JAR, RAR, WAR); | ||
private static final String TEST_JAR = "test-jar"; | ||
|
||
static DeploymentResolution getInstance(MavenProject project) throws MojoExecutionException { | ||
return new DeploymentResolution(project); | ||
} | ||
|
||
private final Map<String, File> files = new TreeMap<>(); | ||
|
||
private DeploymentResolution(MavenProject project) throws MojoExecutionException { | ||
for (Artifact artifact : project.getArtifacts()) { | ||
if (TEST_JAR.equals(artifact.getType())) { | ||
continue; | ||
} | ||
if (SUPPORTED_DEPLOYMENT_TYPES.contains(artifact.getType())) { | ||
files.put(buildKey(artifact.getGroupId(), artifact.getArtifactId(), | ||
artifact.getClassifier(), artifact.getType()), artifact.getFile()); | ||
} | ||
} | ||
} | ||
|
||
public File getFile(final String groupId, final String artifactId, final String classifier, | ||
final String type) throws MojoExecutionException { | ||
return files.get(buildKey(groupId, artifactId, classifier, type)); | ||
} | ||
|
||
private String buildKey(String groupId, String artifactId, String classifier, String type) throws MojoExecutionException { | ||
if (groupId == null) { | ||
throw new MojoExecutionException("Deployment groupId can't be null"); | ||
} | ||
if (artifactId == null) { | ||
throw new MojoExecutionException("Deployment artifactId can't be null"); | ||
} | ||
if (type == null) { | ||
throw new MojoExecutionException("Deployment type can't be null"); | ||
} | ||
if (!SUPPORTED_DEPLOYMENT_TYPES.contains(type)) { | ||
throw new MojoExecutionException( | ||
"Deployment type " + type + " is not supported. Supported types are " + SUPPORTED_DEPLOYMENT_TYPES); | ||
} | ||
return groupId + ":" + artifactId + ":" + (classifier == null ? "" : classifier) + ":" + type; | ||
} | ||
} |
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.