Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2.9.4 #684

Merged
merged 5 commits into from
Nov 22, 2022
Merged

2.9.4 #684

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Source/bw6-maven-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.tibco.plugins</groupId>
<artifactId>bw6-maven-plugin</artifactId>
<version>2.9.2</version>
<version>2.9.4</version>
<packaging>maven-plugin</packaging>
<name>Plugin Code for Apache Maven and TIBCO BusinessWorks™</name>
<description>Plugin Code for Apache Maven and TIBCO BusinessWorks™.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,10 @@ public AppNode getOrCreateAppNode(final String domainName, final String appSpace
return createAppNode(domainName, appSpaceName, appNodeName, agentName, httpPort, osgiPort, description);
}

public void addAndDeployApplication(final String domainName, final String appSpaceName, final String appName, final String earName, final String file, final boolean replace, final String profile, final boolean backupEar, final String backupLocation,final String version,final boolean externalProfile, final String externalProfileLoc, final String appNodeName, final String path) throws Exception {
public void addAndDeployApplication(final String domainName, final String appSpaceName, final String appName, final String earName,
final String file, final boolean replace, final String profile, final boolean backupEar,
final String backupLocation,final String version,final boolean externalProfile,
final String externalProfileLoc, final String appNodeName, final String path, boolean skipUploadArchive) throws Exception {
List<Application> applications = getApplications(domainName, appSpaceName, null, true);
String appDescription=null;

Expand Down Expand Up @@ -326,11 +329,20 @@ public void addAndDeployApplication(final String domainName, final String appSpa
}
}
}
log.info("Uploading the Archive file -> " + earName + ", EAR Upload Path -> "+ path);
uploadArchive(domainName, path, file, true);

if (!skipUploadArchive) {
log.info("Uploading the Archive file -> " + earName + ", EAR Upload Path -> "+ path);
uploadArchive(domainName, path, file, true);
}
else {
log.info("Skipping - Uploading the Archive file -> " + earName + ", EAR Upload Path -> "+ path);
}
log.info("Deploying the Application with name -> " + appName + " with Profile -> " + profile);
deployApplication(domainName, appSpaceName, earName, path, startOndeploy, replace, profile,externalProfile,appDescription);
if(externalProfile){
// fix from runtime side only
// UI doesn't seem to fix the externalProfile flag when profile is set to an application Profile
// We should use the external profile here if this is really the case
if(externalProfile && !externalProfileLoc.isEmpty() && (profile != null && profile.equals("other")) ) {
setProfile(domainName,appSpaceName,version,appName,externalProfileLoc);
log.info("Starting Application -> "+ appName);
if(startOndeploy){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,9 @@ public class BWDeployMojo extends AbstractMojo {
@Parameter(property = "earUploadPath")
private String earUploadPath;

@Parameter(property = "skipUploadArchive")
private boolean skipUploadArchive;

@Parameter(property="retryCount", defaultValue = "10")
private int retryCount;

Expand Down Expand Up @@ -243,7 +246,7 @@ public void execute() throws MojoExecutionException, MojoFailureException {
deployer.addAndDeployApplication(domain, appSpace, applicationName,
earName, earFile.getAbsolutePath(), redeploy, profile,
backup, backupLocation, version, externalProfile,
externalProfileLoc, appNode, earUploadPath);
externalProfileLoc, appNode, earUploadPath, skipUploadArchive);
deployer.close();
deployer.close();
BWEarUtils.deleteEARFileEntries(earLocation);
Expand Down Expand Up @@ -346,6 +349,7 @@ private void loadFromDeploymentProperties() throws MalformedURLException, IOExce
.getProperty("externalProfile"));
externalProfileLoc = deployment.getProperty("externalProfileLoc");
earUploadPath = deployment.getProperty("earUploadPath");
skipUploadArchive = Boolean.parseBoolean(deployment.getProperty("skipUploadArchive"));
getAppNodeConfigProps(deployment);
} catch (Exception e) {
getLog().error(e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,9 @@ public class BWEARInstallerMojo extends AbstractMojo {
@Parameter(property = "externalEarLoc")
private String externalEarLoc;

@Parameter(property="skipUploadArchive")
private boolean skipUploadArchive;

@Parameter(property = "createAdminCompo" , defaultValue = "true" )
private boolean createAdminCompo;

Expand Down Expand Up @@ -271,7 +274,8 @@ public void execute() throws MojoExecutionException {
getLog().info("AppSpace is Running.");
}
getLog().info("domain -> " + domain + " earName -> " + earName + " Ear file to be uploaded -> " + files[0].getAbsolutePath());
deployer.addAndDeployApplication(domain, appSpace, applicationName, earName, files[0].getAbsolutePath(), redeploy, profile, backup, backupLocation,version,externalProfile,externalProfileLoc, appNode, earUploadPath);
deployer.addAndDeployApplication(domain, appSpace, applicationName, earName, files[0].getAbsolutePath(), redeploy, profile,
backup, backupLocation,version,externalProfile,externalProfileLoc, appNode, earUploadPath, skipUploadArchive);
deployer.close();
}
} catch(Exception e) {
Expand Down Expand Up @@ -380,6 +384,7 @@ private void loadFromDeploymentProperties() throws MalformedURLException, IOExce
externalProfileLoc=deployment.getProperty("externalProfileLoc");
externalEarLoc=deployment.getProperty("externalEarLoc");
earUploadPath = deployment.getProperty("earUploadPath");
skipUploadArchive = Boolean.parseBoolean(deployment.getProperty("skipUploadArchive"));
getAppNodeConfigProps(deployment);
} catch(Exception e) {
deployToAdmin = false;
Expand Down Expand Up @@ -474,7 +479,10 @@ private boolean validateFields() {
}

boolean isValidexternalProfileLoc = true;
if(externalProfile && externalProfileLoc.isEmpty()) {
// fix from runtime side only
// UI doesn't seem to fix the externalProfile flag when profile is set to an application Profile
// We should give error only if profile is set to "other" and not an interal application profile
if(externalProfile && externalProfileLoc.isEmpty() && (profile != null && profile.equals("other")) ) {
isValidexternalProfileLoc = false;
errorMessage.append("[external Profile Location value is required]");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,9 @@ else if( "Operation".equals(cEl.getNodeName()))
BWTestConfig.INSTANCE.getLogger().debug("Process : "+ processName + ", Activity : "+ activityName+ ", Id : "+ location +", Error : Invalid Mock Output File Path - "+mockOutputFilePath);
throw new Exception("Process : "+ processName + ", Activity : "+ activityName+ ", Id : "+ location +", Error : Invalid Mock Output File Path - "+mockOutputFilePath);
}
// on Mac and Unix - will replace backslash with forward slash
// on Windows - noop
mockOutputFilePath = mockOutputFilePath.replace("\\", File.separator);
File file = new File(mockOutputFilePath);
if(!file.isAbsolute()){
BWTestConfig.INSTANCE.getLogger().debug("Provided Mock File path is relative "+file.getPath());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,21 @@
import java.util.stream.Collectors;
import java.util.stream.Stream;

import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;

import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.DependencyResolutionRequiredException;
import org.apache.maven.project.MavenProject;
import org.w3c.dom.Document;
import org.w3c.dom.NodeList;
import org.xml.sax.SAXException;
import org.w3c.dom.Element;

import com.tibco.bw.maven.plugin.osgi.helpers.ManifestParser;
import com.tibco.bw.maven.plugin.test.helpers.BWTestConfig;
import com.tibco.bw.maven.plugin.utils.Constants;

public class ConfigFileGenerator
{
Expand All @@ -44,13 +53,16 @@ public void generateConfig()
addPluginsFromDir(target, builder);
}

List<MavenProject> cxfProjects = new ArrayList<MavenProject>();
List<MavenProject> requiredDevPropertiesProjects = new ArrayList<MavenProject>();

List<MavenProject> projects = BWTestConfig.INSTANCE.getSession().getProjects();

for( MavenProject project : projects ) {
if (project.getPackaging().equals("bwmodule") || project.getPackaging().equals("bwear")) {

if (isJavaProject(project)) {
requiredDevPropertiesProjects.add(project);
}
Set<Artifact> artifacts = project.getDependencyArtifacts();
if(artifacts != null)
{
Expand All @@ -65,7 +77,7 @@ public void generateConfig()
}
}
if(isCXF){
cxfProjects.add(project);
requiredDevPropertiesProjects.add(project);
}
}
}
Expand All @@ -86,15 +98,15 @@ public void generateConfig()
properties.put( "osgi.bundles", builder.toString() );
properties.put( "osgi.bundles.defaultStartLevel", "5" );
properties.put( "osgi.install.area", "file:" + BWTestConfig.INSTANCE.getTibcoHome() + BWTestConfig.INSTANCE.getBwHome() + "/system/hotfix/lib/common");
properties.put("osgi.framework", "file:" + BWTestConfig.INSTANCE.getTibcoHome() + BWTestConfig.INSTANCE.getBwHome() + "/system/lib/common/org.eclipse.osgi_3.15.300.v20200520-1959.jar");
properties.put("osgi.framework", "file:" + BWTestConfig.INSTANCE.getTibcoHome() + BWTestConfig.INSTANCE.getBwHome() + "/system/lib/common/org.eclipse.osgi_3.16.200.v20210226-1447.jar");
properties.put("osgi.configuration.cascaded", "false");

FileOutputStream stream = new FileOutputStream(configIni);
properties.store(stream, "Configuration File");
stream.flush();
stream.close();

generateDevPropertiesFile(cxfProjects);
generateDevPropertiesFile(requiredDevPropertiesProjects);
}

catch(Exception e )
Expand All @@ -104,18 +116,52 @@ public void generateConfig()

}

private void generateDevPropertiesFile(List<MavenProject> cxfProjects) throws IOException, DependencyResolutionRequiredException{
private boolean isJavaProject(MavenProject project) {
File projectFile = new File(project.getBasedir(), Constants.DOT_PROJECT_FILE);
NodeList nList = getNatureList(projectFile);
if (nList != null) {
for(int i = 0; i < nList.getLength(); i++) {
if (nList.item(i) != null) {
Element node = (Element)nList.item(i);
String nature = node.getTextContent();
if (nature != null && nature.equals(Constants.NATURE_JAVE_PROJECT_PROPERTY))
return true;
}
}
}
return false;
}

private NodeList getNatureList(File dotProject) {
NodeList nList = null;
try {
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
dbFactory.setNamespaceAware(true);
DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
Document doc = dBuilder.parse(dotProject);
nList = doc.getElementsByTagName(Constants.NATURE_PROPERTY);
} catch (ParserConfigurationException e) {
e.printStackTrace();
} catch (SAXException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return nList;
}

private void generateDevPropertiesFile(List<MavenProject> requiredDevPropertiesProjects) throws IOException, DependencyResolutionRequiredException{
File devProps = new File( BWTestConfig.INSTANCE.getConfigDir() , "dev.properties");
devProps.createNewFile();

Properties properties = new Properties();
properties.put("@ignoredot@","true");
for(MavenProject cxfProject : cxfProjects)
for(MavenProject reqProject : requiredDevPropertiesProjects)
{
//find classpath
Manifest projectManifest = ManifestParser.parseManifest( cxfProject.getBasedir() );
Manifest projectManifest = ManifestParser.parseManifest( reqProject.getBasedir() );
String bundleClassPath = projectManifest.getMainAttributes().getValue("Bundle-ClassPath");
BWTestConfig.INSTANCE.getLogger().debug("Bundle-Classpath for project "+ cxfProject.getName() +" -> "+bundleClassPath);
BWTestConfig.INSTANCE.getLogger().debug("Bundle-Classpath for project "+ reqProject.getName() +" -> "+bundleClassPath);
String pathString = "";
if(bundleClassPath != null)
{
Expand All @@ -126,8 +172,8 @@ private void generateDevPropertiesFile(List<MavenProject> cxfProjects) throws IO
}
}
pathString = "bin,target/classes" + pathString;
properties.put(cxfProject.getName(), pathString);
BWTestConfig.INSTANCE.getLogger().debug("Adding CXF project entry to dev.properties -> "+ cxfProject.getName()+ "="+ pathString);
properties.put(reqProject.getName(), pathString);
BWTestConfig.INSTANCE.getLogger().debug("Adding project entry to dev.properties -> "+ reqProject.getName()+ "="+ pathString);
}

FileOutputStream stream = new FileOutputStream(devProps);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ public interface Constants {
public static final String TEMP_SUBSTVAR = "external.substvar";
public static final String TIMESTAMP = "timestamp";
public static final String COMPONENT_PROCESS = "ComponentProcess";
public static final String DOT_PROJECT_FILE = ".project";
public static final String NATURE_PROPERTY = "nature";
public static final String NATURE_JAVE_PROJECT_PROPERTY = "org.eclipse.jdt.core.javanature";

// TCI
public static final String TCI_SERVER_ENDPOINT_ENV = "TCI_PLATFORM_API_ENDPOINT";
Expand Down