Skip to content
This repository has been archived by the owner on Oct 14, 2020. It is now read-only.

Commit

Permalink
Use finalName in generated application location in server.xml
Browse files Browse the repository at this point in the history
Signed-off-by: Scott Kurz <[email protected]>
  • Loading branch information
scottkurz committed Sep 16, 2019
1 parent eabd692 commit a7f9416
Showing 1 changed file with 28 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -167,24 +167,35 @@ private void generateServerConfig(List<AbstractBoosterConfig> boosterConfigs) th
}
}

private List<String> getWarNames() {
List<String> warNames = new ArrayList<String>();

for (Artifact artifact : project.getArtifacts()) {
if (artifact.getType().equals("war")) {
warNames.add(artifact.getArtifactId() + "-" + artifact.getVersion());
}
}
/**
* Assumes a non-WAR packaging type (like JAR) has a WAR dependency.
* We assume there's only 1 but don't check, just return the first one.
* @return
* @throws BoostException
*/
private String getWarName() throws BoostException {

String retVal = null;
if (project.getPackaging().equals(ConfigConstants.WAR_PKG_TYPE)) {
if (project.getVersion() == null) {
warNames.add(project.getArtifactId());
} else {
warNames.add(project.getArtifactId() + "-" + project.getVersion());
retVal = project.getBuild().getFinalName();
} else {
// JAR package "release", get WAR from dependency
for (Artifact artifact : project.getArtifacts()) {
// first WAR
if (artifact.getType().equals("war")) {
retVal = artifact.getArtifactId() + "-" + artifact.getVersion();
break;
}
}
if (retVal == null) {
BoostLogger log = BoostLogger.getSystemStreamLogger();
String msg = "With non-WAR packaging type, we require a WAR dependency";
log.error(msg);
throw new BoostException(msg);
}
}

return warNames;
return retVal;
}

/**
Expand All @@ -195,8 +206,6 @@ private List<String> getWarNames() {
*/
private void generateLibertyServerConfig(List<AbstractBoosterConfig> boosterConfigurators) throws Exception {

List<String> warNames = getWarNames();

String encryptionKey = (String) boostProperties.get(BoostProperties.AES_ENCRYPTION_KEY);
LibertyServerConfigGenerator libertyConfig = new LibertyServerConfigGenerator(libertyServerPath, encryptionKey,
BoostLogger.getSystemStreamLogger());
Expand All @@ -210,16 +219,9 @@ private void generateLibertyServerConfig(List<AbstractBoosterConfig> boosterConf

String httpsPort = (String) boostProperties.getOrDefault(BoostProperties.ENDPOINT_HTTPS_PORT, "9443");
libertyConfig.addHttpsPort(httpsPort);

// Add war configuration if necessary
if (!warNames.isEmpty()) {
for (String warName : warNames) {
libertyConfig.addApplication(warName);
}
} else {
throw new Exception(
"No war files were found. The project must have a war packaging type or specify war dependencies.");
}

String warName = getWarName();
libertyConfig.addApplication(warName);

// Loop through configuration objects and add config and
// the corresponding Liberty feature
Expand Down

0 comments on commit a7f9416

Please sign in to comment.