Skip to content

Commit

Permalink
Add DeploymentName as a separate parameter to allow unique deployment…
Browse files Browse the repository at this point in the history
…s of the same application or just differing names.
  • Loading branch information
Andrew committed Mar 9, 2015
1 parent b7a84b6 commit 0db5420
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 2 deletions.
7 changes: 7 additions & 0 deletions README.md
Expand Up @@ -61,6 +61,13 @@ In order to post to the Mule Repository, you need only these permissions:
What to name the application when it is uploaded to the repository
<td>
MuleApplication
<tr>
<td>
deploymentName
<td>
What to name the deployment when it is uploaded to the repository
<td>
same as <code>name</code>
<tr>
<td>
version
Expand Down
14 changes: 13 additions & 1 deletion src/main/java/org/mule/tools/maven/rest/Deploy.java
Expand Up @@ -48,6 +48,14 @@ public class Deploy extends AbstractMojo {
*/
protected String name;

/**
* The name that the application will be deployed as. Default is
* same as ${name}
*
* @parameter expression="${deploymentName}"
*/
protected String deploymentName;

/**
* The version that the application will be deployed as. Default is the
* current time in milliseconds.
Expand Down Expand Up @@ -102,6 +110,10 @@ public void execute() throws MojoExecutionException, MojoFailureException {
logger.info("Name is not set, using default \"{}\"", DEFAULT_NAME);
name = DEFAULT_NAME;
}
if (deploymentName == null) {
logger.info("DeploymentName is not set, using application name \"{}\"", name);
deploymentName = name;
}
if (version == null) {
version = new SimpleDateFormat("MM-dd-yyyy-HH:mm:ss").format(Calendar.getInstance()
.getTime());
Expand All @@ -123,7 +135,7 @@ public void execute() throws MojoExecutionException, MojoFailureException {
validateProject(appDirectory);
muleRest = buildMuleRest();
String versionId = muleRest.restfullyUploadRepository(name, version, getMuleZipFile(outputDirectory, finalName));
String deploymentId = muleRest.restfullyCreateDeployment(serverGroup, name, versionId);
String deploymentId = muleRest.restfullyCreateDeployment(serverGroup, deploymentName, versionId);
muleRest.restfullyDeployDeploymentById(deploymentId);
} catch (Exception e) {
throw new MojoFailureException("Error in attempting to deploy archive: " + e.toString(), e);
Expand Down
9 changes: 8 additions & 1 deletion src/test/java/org/mule/tools/maven/rest/DeployTest.java
Expand Up @@ -83,11 +83,18 @@ public void testFinalNameNull() throws MojoExecutionException, MojoFailureExcept
}

@Test(expected = MojoFailureException.class)
public void testServerGRoupNull() throws MojoExecutionException, MojoFailureException {
public void testServerGroupNull() throws MojoExecutionException, MojoFailureException {
deploy.serverGroup = null;
deploy.execute();
Assert.fail("Exception should have been thrown before this is called");
}

@Test
public void testDeploymentNameNull() throws MojoExecutionException, MojoFailureException {
deploy.deploymentName = null;
deploy.execute();
Assert.assertEquals("When null, deploymentName should be same as name", deploy.name, deploy.deploymentName);
}

@Test
public void testHappyPath() throws Exception{
Expand Down

0 comments on commit 0db5420

Please sign in to comment.