use of com.microsoft.azure.maven.model.DeploymentResource in project azure-maven-plugins by microsoft.
the class PackageMojo method getResources.
@Override
public List<DeploymentResource> getResources() {
final DeploymentResource resource = new DeploymentResource();
resource.setDirectory(getBuildDirectoryAbsolutePath());
resource.setTargetPath("/");
resource.setFiltering(false);
resource.setIncludes(Collections.singletonList("*.jar"));
return Collections.singletonList(resource);
}
use of com.microsoft.azure.maven.model.DeploymentResource 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.maven.model.DeploymentResource in project azure-maven-plugins by microsoft.
the class ConfigurationSerializer method createResourcesNode.
protected DOMElement createResourcesNode(List<DeploymentResource> resources) {
final DOMElement resourceRootNode = new DOMElement("resources");
for (final DeploymentResource resource : resources) {
final DOMElement resourceNode = new DOMElement("resource");
XMLUtils.addNotEmptyElement(resourceNode, "type", resource.getType());
XMLUtils.addNotEmptyElement(resourceNode, "filtering", resource.getFiltering());
XMLUtils.addNotEmptyElement(resourceNode, "mergeId", resource.getMergeId());
XMLUtils.addNotEmptyElement(resourceNode, "targetPath", resource.getTargetPath());
XMLUtils.addNotEmptyElement(resourceNode, "directory", resource.getDirectory());
XMLUtils.addNotEmptyListElement(resourceNode, "includes", "include", resource.getIncludes());
XMLUtils.addNotEmptyListElement(resourceNode, "excludes", "exclude", resource.getExcludes());
resourceRootNode.add(resourceNode);
}
return resourceRootNode;
}
use of com.microsoft.azure.maven.model.DeploymentResource in project azure-maven-plugins by microsoft.
the class DeployExternalResourcesTask method deployExternalResources.
private void deployExternalResources(final IAppService<?> target, final List<DeploymentResource> resources) {
if (resources.isEmpty()) {
return;
}
AzureMessager.getMessager().info(AzureString.format("Uploading resources to %s", target.name()));
final PublishingProfile publishingProfile = target.getPublishingProfile();
final String serverUrl = publishingProfile.getFtpUrl().split("/", 2)[0];
try {
final FTPClient ftpClient = FTPUtils.getFTPClient(serverUrl, publishingProfile.getFtpUsername(), publishingProfile.getFtpPassword());
for (final DeploymentResource externalResource : resources) {
uploadResource(externalResource, ftpClient);
}
} catch (IOException e) {
throw new AzureToolkitRuntimeException(e.getMessage(), e);
}
}
use of com.microsoft.azure.maven.model.DeploymentResource in project azure-maven-plugins by microsoft.
the class Deployment method getDefaultDeploymentConfiguration.
public static Deployment getDefaultDeploymentConfiguration(String deployType) {
final Deployment result = new Deployment();
final DeploymentResource resource = new DeploymentResource();
resource.setDirectory(DEFAULT_DIRECTORY);
resource.addInclude(String.format(DEFAULT_INCLUDE, StringUtils.firstNonBlank(deployType, DEFAULT_DEPLOYTYPE)));
result.setResources(Collections.singletonList(resource));
return result;
}
Aggregations