com.ca.apim.gateway.cagatewayimport.CAGatewayImport Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of gateway-import-plugin Show documentation
Show all versions of gateway-import-plugin Show documentation
The gateway-import-plugin enables importing locally generated bundles to an existing running gateway instance.
/*
* Copyright (c) 2018 CA. All rights reserved.
* This software may be modified and distributed under the terms
* of the MIT license. See the LICENSE file for details.
*/
package com.ca.apim.gateway.cagatewayimport;
import com.ca.apim.gateway.cagatewayimport.config.GatewayImportConfig;
import com.ca.apim.gateway.cagatewayimport.config.GatewayImportConnectionProperties;
import com.ca.apim.gateway.cagatewayimport.tasks.ImportBundleTask;
import org.gradle.api.Plugin;
import org.gradle.api.Project;
import org.gradle.api.provider.Property;
import org.jetbrains.annotations.NotNull;
import java.util.function.Supplier;
public class CAGatewayImport implements Plugin {
@Override
public void apply(@NotNull final Project project) {
// This plugin builds on the CAGatewayExportBase plugin to define conventions
project.getPlugins().apply(CAGatewayImportBase.class);
// Add the base plugin to add standard lifecycle tasks: https://docs.gradle.org/current/userguide/standard_plugins.html#sec:base_plugins
project.getPlugins().apply("base");
final GatewayImportConnectionProperties gatewayConnectionProperties = project.getExtensions().create("GatewayImportConnection", GatewayImportConnectionProperties.class, project);
final GatewayImportConfig gatewayImportConfig = project.getExtensions().create("GatewayImportConfig", GatewayImportConfig.class, project);
// Set Defaults
project.afterEvaluate(p -> setDefaults(gatewayConnectionProperties));
project.getTasks().create("import-bundle", ImportBundleTask.class, t -> {
t.setGatewayConnectionProperties(gatewayConnectionProperties);
t.setGatewayImportConfig(gatewayImportConfig);
});
}
private static void setDefaults(final GatewayImportConnectionProperties gatewayConnectionProperties) {
setDefault(gatewayConnectionProperties.getUrl(), () -> "https://localhost:8443/restman");
setDefault(gatewayConnectionProperties.getUserName(), () -> "admin");
setDefault(gatewayConnectionProperties.getUserPass(), () -> "password");
}
private static void setDefault(Property property, Supplier supplier) {
if (!property.isPresent()) {
property.set(supplier.get());
}
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy