use of com.microsoft.azure.toolkit.lib.appservice.model.WebAppArtifact in project azure-maven-plugins by microsoft.
the class ConfigParser method convertOneDeployResourceToArtifacts.
private static List<WebAppArtifact> convertOneDeployResourceToArtifacts(Resource resource) {
final List<File> artifacts = MavenArtifactUtils.getArtifacts(resource);
final String typeString = ((DeploymentResource) resource).getType();
final DeployType type = DeployType.fromString(typeString);
Objects.requireNonNull(type, () -> String.format("Unsupported resource type '%s', please change to one from this list: %s", typeString, DeployType.values().stream().map(Object::toString).map(StringUtils::lowerCase).collect(Collectors.joining(", "))));
if (type.requireSingleFile() && artifacts.size() > 1) {
throw new AzureToolkitRuntimeException(String.format("Multiple files are found for resource type('%s'), only one file is allowed.", type));
}
if (artifacts.isEmpty()) {
Log.warn(String.format("Cannot find any files defined by resource(%s)", StringUtils.firstNonBlank(resource.toString())));
}
if (type.ignorePath() && StringUtils.isNotBlank(resource.getTargetPath())) {
throw new AzureToolkitRuntimeException(String.format("'<targetPath>' is not allowed for deployable type('%s').", type));
}
if (StringUtils.isNotBlank(type.getFileExt())) {
final String expectFileExtension = type.getFileExt();
for (final File file : artifacts) {
if (!StringUtils.equalsIgnoreCase(FilenameUtils.getExtension(file.getName()), expectFileExtension)) {
throw new AzureToolkitRuntimeException(String.format("Wrong file '%s' Deployable type('%s'), expected file type '%s'", file, type, expectFileExtension));
}
}
}
return artifacts.stream().map(file -> WebAppArtifact.builder().file(file).deployType(type).path(getRemotePath(type, resource, file)).build()).collect(Collectors.toList());
}
use of com.microsoft.azure.toolkit.lib.appservice.model.WebAppArtifact in project azure-gradle-plugins by microsoft.
the class DeployTask method parseConfiguration.
private GradleWebAppConfig parseConfiguration() {
final AzureWebappPluginExtension ctx = this.azureWebappExtension;
GradleWebAppConfig config = new GradleWebAppConfig();
config.subscriptionId(ctx.getSubscription());
config.resourceGroup(ctx.getResourceGroup());
config.appName(ctx.getAppName());
config.pricingTier(ctx.getPricingTier());
config.region(ctx.getRegion());
config.runtime(ctx.getRuntime());
config.appSettings(ctx.getAppSettings());
config.servicePlanName(ctx.getAppServicePlanName());
config.servicePlanResourceGroup(ctx.getAppServicePlanResourceGroup());
config.deploymentSlotName(Optional.ofNullable(ctx.getDeploymentSlot()).map(GradleDeploymentSlotConfig::name).orElse(null));
config.deploymentSlotConfigurationSource(Optional.ofNullable(ctx.getDeploymentSlot()).map(GradleDeploymentSlotConfig::configurationSource).orElse(null));
if (StringUtils.isNotBlank(this.artifactFile)) {
File file = new File(this.artifactFile);
if (!file.exists()) {
throw new AzureToolkitRuntimeException(String.format("artifact file(%s) cannot be found.", file.getAbsolutePath()));
}
final WebAppArtifact webAppArtifact = WebAppArtifact.builder().deployType(Utils.getDeployTypeByFileExtension(file)).file(file).build();
config.webAppArtifacts(Collections.singletonList(webAppArtifact));
}
return config;
}
Aggregations