From 7dd2b9d3bb2e9e8ca0ab38e6e9bbb37d937208cf Mon Sep 17 00:00:00 2001 From: Sonal Shingavi Date: Wed, 3 Jul 2019 15:51:50 +0530 Subject: [PATCH 1/2] Ability for users to provide application archives folder to upload the EAR in domain --- .../application/BWEARInstallerMojo.java | 33 ++++++++++++++++--- 1 file changed, 29 insertions(+), 4 deletions(-) diff --git a/Source/bw6-maven-plugin/src/main/java/com/tibco/bw/maven/plugin/application/BWEARInstallerMojo.java b/Source/bw6-maven-plugin/src/main/java/com/tibco/bw/maven/plugin/application/BWEARInstallerMojo.java index 06207b9b..d1e6317f 100644 --- a/Source/bw6-maven-plugin/src/main/java/com/tibco/bw/maven/plugin/application/BWEARInstallerMojo.java +++ b/Source/bw6-maven-plugin/src/main/java/com/tibco/bw/maven/plugin/application/BWEARInstallerMojo.java @@ -6,7 +6,11 @@ import java.util.List; import java.util.Properties; import java.util.jar.Manifest; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import org.apache.commons.io.FileUtils; import org.apache.maven.execution.MavenSession; import org.apache.maven.plugin.AbstractMojo; import org.apache.maven.plugin.MojoExecutionException; @@ -118,6 +122,9 @@ public class BWEARInstallerMojo extends AbstractMojo { @Parameter(property="deploymentConfigfile") private String deploymentConfigfile; + + @Parameter(property = "externalEarLoc") + private String externalEarLoc; private String earLoc; private String earName; @@ -144,13 +151,22 @@ public void execute() throws MojoExecutionException { getLog().info("Deploy To Admin is set to False. Skipping EAR Deployment."); return; } - + File [] files = BWFileUtils.getFilesForType(outputDirectory, ".ear"); if(files.length == 0) { throw new Exception("EAR file not found for the Application"); } - - deriveEARInformation(files[0]); + + if(externalEarLocExists()){ + File f = new File(externalEarLoc); + Path p = Paths.get(externalEarLoc + "/" +files[0].getName()); + + Files.deleteIfExists(p); + FileUtils.copyFileToDirectory(files[0], f); + deriveEARInformation(p.toFile()); + } else + deriveEARInformation(files[0]); + applicationName = manifest.getMainAttributes().getValue(Constants.BUNDLE_SYMBOLIC_NAME); RemoteDeployer deployer = new RemoteDeployer(agentHost, Integer.parseInt(agentPort), agentAuth, agentUsername, agentPassword, agentSSL, trustPath, trustPassword, keyPath, keyPassword); @@ -184,7 +200,7 @@ public void execute() throws MojoExecutionException { throw new MojoExecutionException("Failed to deploy BW Application ", e); } } - + private void deriveEARInformation(File file) { earLoc = file.getAbsolutePath(); earLoc = earLoc.replace("\\", "/"); @@ -205,6 +221,14 @@ private boolean deploymentConfigExists() { getLog().info("Deployment Config File found. Loading configuration from the same."); return true; } + + private boolean externalEarLocExists() { + if(externalEarLoc == null || externalEarLoc.isEmpty()){ + return false; + } + getLog().info("ExternalEarLoc is set. Deploying the ear from ExternalEarLoc folder."); + return true; + } private void loadFromDeploymentProperties() { File file = new File(deploymentConfigfile); @@ -250,6 +274,7 @@ private void loadFromDeploymentProperties() { backupLocation = deployment.getProperty("backupLocation"); externalProfile=Boolean.parseBoolean(deployment.getProperty("externalProfile")); externalProfileLoc=deployment.getProperty("externalProfileLoc"); + externalEarLoc=deployment.getProperty("externalEarLoc"); } catch(Exception e) { deployToAdmin = false; getLog().error(e); From bca75c3c105a1e75bbea5757b82f213a9ac7ea6b Mon Sep 17 00:00:00 2001 From: Sonal Shingavi Date: Tue, 9 Jul 2019 15:15:14 +0530 Subject: [PATCH 2/2] Modifing log in BWEARInstallerMojo.java --- .../tibco/bw/maven/plugin/application/BWEARInstallerMojo.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/bw6-maven-plugin/src/main/java/com/tibco/bw/maven/plugin/application/BWEARInstallerMojo.java b/Source/bw6-maven-plugin/src/main/java/com/tibco/bw/maven/plugin/application/BWEARInstallerMojo.java index d1e6317f..7d59a7b9 100644 --- a/Source/bw6-maven-plugin/src/main/java/com/tibco/bw/maven/plugin/application/BWEARInstallerMojo.java +++ b/Source/bw6-maven-plugin/src/main/java/com/tibco/bw/maven/plugin/application/BWEARInstallerMojo.java @@ -226,7 +226,7 @@ private boolean externalEarLocExists() { if(externalEarLoc == null || externalEarLoc.isEmpty()){ return false; } - getLog().info("ExternalEarLoc is set. Deploying the ear from ExternalEarLoc folder."); + getLog().info("Deploying the Ear from external Ear location: " + externalEarLoc); return true; }