Class PackageMojo
- java.lang.Object
-
- org.apache.maven.plugin.AbstractMojo
-
- com.microsoft.azure.maven.AbstractAzureMojo
-
- com.microsoft.azure.maven.appservice.AbstractAppServiceMojo
-
- com.microsoft.azure.maven.function.AbstractFunctionMojo
-
- com.microsoft.azure.maven.function.PackageMojo
-
- All Implemented Interfaces:
org.apache.maven.plugin.ContextEnabled,org.apache.maven.plugin.Mojo
@Mojo(name="package", defaultPhase=PACKAGE, requiresDependencyResolution=RUNTIME) public class PackageMojo extends AbstractFunctionMojoGenerate configuration files (host.json, function.json etc.) and copy JARs to staging directory.
-
-
Field Summary
-
Fields inherited from class com.microsoft.azure.maven.function.AbstractFunctionMojo
alwaysReadyInstances, appInsightsInstance, appInsightsKey, artifactPath, AZURE_FUNCTIONS_JAVA_LIBRARY, CAN_NOT_FIND_ARTIFACT, disableAppInsights, finalName, FUNCTION_EXTENSION_LIBRARY_MAP, HOST_JSON, hostJson, instanceSize, LOCAL_SETTINGS_JSON, localSettingsJson, maximumInstances, outputDirectory, parser, pricingTier, region, runtime, skip, storageAccountName, storageAccountResourceGroup, TRIGGER_TYPE
-
Fields inherited from class com.microsoft.azure.maven.appservice.AbstractAppServiceMojo
appName, appServiceClient, appServicePlanName, appServicePlanResourceGroup, appSettings, deploymentSlotSetting, MAVEN_PLUGIN_POSTFIX, resourceGroup
-
Fields inherited from class com.microsoft.azure.maven.AbstractAzureMojo
allowTelemetry, auth, authType, buildDirectory, COMPILE_LEVEL_NOT_SUPPORTED, FAILED_TO_GET_VALID_RUNTIMES, failsOnError, failsOnRuntimeValidationError, INSTALLATION_ID_KEY, mavenResourcesFiltering, plugin, PLUGIN_NAME_KEY, PLUGIN_VERSION_KEY, project, session, SESSION_ID_KEY, settings, settingsDecrypter, SUBSCRIPTION_ID_KEY, SUBSCRIPTION_NOT_FOUND, SUBSCRIPTION_TEMPLATE, subscriptionId, telemetries, telemetryProxy, USING_AZURE_ENVIRONMENT
-
-
Constructor Summary
Constructors Constructor Description PackageMojo()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static voidbuildArtifactWithDependencies(File artifactFile, Set<File> dependencies, File target)private voidcopyArtifactToStagingDirectory(File stagingDirectory, Set<File> dependencies)private voidcopyDependenciesToStagingDirectory(File stagingDirectory, Set<File> dependencies)private static voidcopyFilesWithDefaultContent(File source, File dest, String defaultContent)private static voidcopyFileToDirectory(File srcFile, File destFile)protected voidcopyHostJson()protected voidcopyJarsToStageDirectory()protected voidcopyLocalSettingsJson()protected voiddoExecute()protected Set<Method>findAnnotatedMethods(com.microsoft.azure.toolkit.lib.legacy.function.handlers.AnnotationHandler handler)protected com.microsoft.azure.toolkit.lib.legacy.function.handlers.AnnotationHandlergetAnnotationHandler()protected URLgetArtifactUrl()private static List<org.apache.maven.plugins.shade.resource.ResourceTransformer>getDefaultResourceTransformers()protected List<URL>getDependencyArtifactUrls()private static org.apache.maven.plugins.shade.filter.FiltergetExcludeSignFilesFilter(Set<File> jars)protected Set<com.microsoft.azure.toolkit.lib.legacy.function.bindings.BindingEnum>getFunctionBindingEnums(Map<String,com.microsoft.azure.toolkit.lib.legacy.function.configurations.FunctionConfiguration> configMap)protected Map<String,com.microsoft.azure.toolkit.lib.legacy.function.configurations.FunctionConfiguration>getFunctionConfigurations(com.microsoft.azure.toolkit.lib.legacy.function.handlers.AnnotationHandler handler, Set<Method> methods)protected com.microsoft.azure.toolkit.lib.legacy.function.handlers.FunctionCoreToolsHandlergetFunctionCoreToolsHandler(com.microsoft.azure.toolkit.lib.legacy.function.handlers.CommandHandler commandHandler)protected com.fasterxml.jackson.databind.ObjectWritergetObjectWriter()List<com.microsoft.azure.maven.model.DeploymentResource>getResources()protected StringgetScriptFilePath()protected URLgetTargetClassUrl()protected voidinstallExtension(com.microsoft.azure.toolkit.lib.legacy.function.handlers.FunctionCoreToolsHandler handler, Set<com.microsoft.azure.toolkit.lib.legacy.function.bindings.BindingEnum> bindingEnums)protected booleanisInstallingExtensionNeeded(Set<com.microsoft.azure.toolkit.lib.legacy.function.bindings.BindingEnum> bindingTypes)protected voidpromptCompileInfo()protected voidtrackFunctionProperties(Map<String,com.microsoft.azure.toolkit.lib.legacy.function.configurations.FunctionConfiguration> configMap)protected voidvalidateFunctionConfigurations(Map<String,com.microsoft.azure.toolkit.lib.legacy.function.configurations.FunctionConfiguration> configMap)protected voidwriteFunctionJsonFile(com.fasterxml.jackson.databind.ObjectWriter objectWriter, String functionName, com.microsoft.azure.toolkit.lib.legacy.function.configurations.FunctionConfiguration config)protected voidwriteFunctionJsonFiles(com.fasterxml.jackson.databind.ObjectWriter objectWriter, Map<String,com.microsoft.azure.toolkit.lib.legacy.function.configurations.FunctionConfiguration> configMap)protected voidwriteObjectToFile(com.fasterxml.jackson.databind.ObjectWriter objectWriter, Object object, File targetFile)-
Methods inherited from class com.microsoft.azure.maven.function.AbstractFunctionMojo
getAppInsightsInstance, getAppInsightsKey, getArtifact, getBundleVersion, getFinalName, getFunctionLibraryVersion, getHostJsonFile, getLocalSettingsJsonFile, getRegion, getRuntimeConfiguration, getTelemetryProperties, isDisableAppInsights, isSkipMojo, readHostJson, validateAppName, validateFunctionCompatibility
-
Methods inherited from class com.microsoft.azure.maven.appservice.AbstractAppServiceMojo
getAppName, getAppServicePlanName, getAppServicePlanResourceGroup, getAppSettings, getDeploymentSlotSetting, getDeploymentStagingDirectoryPath, getResourceGroup, initAzureAppServiceClient, printCurrentSubscription
-
Methods inherited from class com.microsoft.azure.maven.AbstractAzureMojo
afterMojoExecution, beforeMojoExecution, checkSubscription, execute, executeWithTimeRecorder, getActualAuthType, getAllowTelemetry, getBuildDirectoryAbsolutePath, getCompileLevel, getFailsOnError, getFailsOnRuntimeValidationError, getInstallationId, getMavenResourcesFiltering, getPluginName, getPluginVersion, getProject, getSession, getSessionId, getSettings, getSubscriptionId, getTargetSubscriptionId, getTelemetries, getTelemetryProxy, getUserAgent, getValidRuntimes, highlightDefaultValue, infoWithMultipleLines, initTelemetryProxy, loginAzure, loginAzure, onMojoError, onSkipped, printCredentialDescription, selectSubscription, selectSubscription, trackMojoFailure, updateTelemetryProperties, validateArtifactCompileVersion
-
-
-
-
Field Detail
-
SEARCH_FUNCTIONS
public static final String SEARCH_FUNCTIONS
- See Also:
- Constant Field Values
-
FOUND_FUNCTIONS
public static final String FOUND_FUNCTIONS
- See Also:
- Constant Field Values
-
NO_FUNCTIONS
public static final String NO_FUNCTIONS
- See Also:
- Constant Field Values
-
GENERATE_CONFIG
public static final String GENERATE_CONFIG
- See Also:
- Constant Field Values
-
GENERATE_SKIP
public static final String GENERATE_SKIP
- See Also:
- Constant Field Values
-
GENERATE_DONE
public static final String GENERATE_DONE
- See Also:
- Constant Field Values
-
VALIDATE_CONFIG
public static final String VALIDATE_CONFIG
- See Also:
- Constant Field Values
-
VALIDATE_SKIP
public static final String VALIDATE_SKIP
- See Also:
- Constant Field Values
-
VALIDATE_DONE
public static final String VALIDATE_DONE
- See Also:
- Constant Field Values
-
SAVING_HOST_JSON
public static final String SAVING_HOST_JSON
- See Also:
- Constant Field Values
-
SAVING_LOCAL_SETTINGS_JSON
public static final String SAVING_LOCAL_SETTINGS_JSON
- See Also:
- Constant Field Values
-
SAVE_FUNCTION_JSONS
public static final String SAVE_FUNCTION_JSONS
- See Also:
- Constant Field Values
-
SAVE_SKIP
public static final String SAVE_SKIP
- See Also:
- Constant Field Values
-
SAVE_FUNCTION_JSON
public static final String SAVE_FUNCTION_JSON
- See Also:
- Constant Field Values
-
SAVE_SUCCESS
public static final String SAVE_SUCCESS
- See Also:
- Constant Field Values
-
COPY_JARS
public static final String COPY_JARS
- See Also:
- Constant Field Values
-
COPY_SUCCESS
public static final String COPY_SUCCESS
- See Also:
- Constant Field Values
-
INSTALL_EXTENSIONS
public static final String INSTALL_EXTENSIONS
- See Also:
- Constant Field Values
-
SKIP_INSTALL_EXTENSIONS_HTTP
public static final String SKIP_INSTALL_EXTENSIONS_HTTP
- See Also:
- Constant Field Values
-
INSTALL_EXTENSIONS_FINISH
public static final String INSTALL_EXTENSIONS_FINISH
- See Also:
- Constant Field Values
-
BUILD_SUCCESS
public static final String BUILD_SUCCESS
- See Also:
- Constant Field Values
-
FUNCTION_JSON
public static final String FUNCTION_JSON
- See Also:
- Constant Field Values
-
EXTENSION_BUNDLE
public static final String EXTENSION_BUNDLE
- See Also:
- Constant Field Values
-
AZURE_FUNCTIONS_JAVA_CORE_LIBRARY
private static final String AZURE_FUNCTIONS_JAVA_CORE_LIBRARY
- See Also:
- Constant Field Values
-
DEFAULT_LOCAL_SETTINGS_JSON
private static final String DEFAULT_LOCAL_SETTINGS_JSON
- See Also:
- Constant Field Values
-
DEFAULT_HOST_JSON
private static final String DEFAULT_HOST_JSON
- See Also:
- Constant Field Values
-
FUNCTION_WITHOUT_FUNCTION_EXTENSION
private static final com.microsoft.azure.toolkit.lib.legacy.function.bindings.BindingEnum[] FUNCTION_WITHOUT_FUNCTION_EXTENSION
-
EXTENSION_BUNDLE_ID
private static final String EXTENSION_BUNDLE_ID
- See Also:
- Constant Field Values
-
EXTENSION_BUNDLE_PREVIEW_ID
private static final String EXTENSION_BUNDLE_PREVIEW_ID
- See Also:
- Constant Field Values
-
SKIP_INSTALL_EXTENSIONS_FLAG
private static final String SKIP_INSTALL_EXTENSIONS_FLAG
- See Also:
- Constant Field Values
-
SKIP_INSTALL_EXTENSIONS_BUNDLE
private static final String SKIP_INSTALL_EXTENSIONS_BUNDLE
- See Also:
- Constant Field Values
-
BUILD_UBER_ARTIFACT_EXCEPTION
private static final String BUILD_UBER_ARTIFACT_EXCEPTION
- See Also:
- Constant Field Values
-
skipInstallExtensions
@Parameter(property="functions.skipInstallExtensions", defaultValue="false") protected Boolean skipInstallExtensionsBoolean flag to skip extension installation
-
skipCopyDependencies
@Parameter(property="functions.skipCopyDependencies", defaultValue="false") protected Boolean skipCopyDependenciesBoolean flag to control whether to skip copy dependencies to staging directory
-
buildJarWithDependencies
@Parameter(property="functions.buildJarWithDependencies", defaultValue="false") protected Boolean buildJarWithDependenciesBoolean flag to control whether to build fat jar or use the original jar with dependencies in lib folder
-
-
Method Detail
-
doExecute
protected void doExecute() throws com.microsoft.azure.toolkit.lib.common.exception.AzureExecutionException- Specified by:
doExecutein classcom.microsoft.azure.maven.AbstractAzureMojo- Throws:
com.microsoft.azure.toolkit.lib.common.exception.AzureExecutionException
-
buildArtifactWithDependencies
public static void buildArtifactWithDependencies(@Nonnull File artifactFile, @Nullable Set<File> dependencies, File target)
-
getDefaultResourceTransformers
private static List<org.apache.maven.plugins.shade.resource.ResourceTransformer> getDefaultResourceTransformers()
-
getExcludeSignFilesFilter
private static org.apache.maven.plugins.shade.filter.Filter getExcludeSignFilesFilter(Set<File> jars)
-
getAnnotationHandler
protected com.microsoft.azure.toolkit.lib.legacy.function.handlers.AnnotationHandler getAnnotationHandler()
-
findAnnotatedMethods
protected Set<Method> findAnnotatedMethods(com.microsoft.azure.toolkit.lib.legacy.function.handlers.AnnotationHandler handler) throws MalformedURLException
- Throws:
MalformedURLException
-
getArtifactUrl
protected URL getArtifactUrl() throws MalformedURLException
- Throws:
MalformedURLException
-
getTargetClassUrl
protected URL getTargetClassUrl() throws MalformedURLException
- Throws:
MalformedURLException
-
getDependencyArtifactUrls
protected List<URL> getDependencyArtifactUrls()
- Returns:
- URLs for the classpath with compile scope needed jars
-
getFunctionConfigurations
protected Map<String,com.microsoft.azure.toolkit.lib.legacy.function.configurations.FunctionConfiguration> getFunctionConfigurations(com.microsoft.azure.toolkit.lib.legacy.function.handlers.AnnotationHandler handler, Set<Method> methods) throws com.microsoft.azure.toolkit.lib.common.exception.AzureExecutionException
- Throws:
com.microsoft.azure.toolkit.lib.common.exception.AzureExecutionException
-
getScriptFilePath
protected String getScriptFilePath()
-
validateFunctionConfigurations
protected void validateFunctionConfigurations(Map<String,com.microsoft.azure.toolkit.lib.legacy.function.configurations.FunctionConfiguration> configMap)
-
writeFunctionJsonFiles
protected void writeFunctionJsonFiles(com.fasterxml.jackson.databind.ObjectWriter objectWriter, Map<String,com.microsoft.azure.toolkit.lib.legacy.function.configurations.FunctionConfiguration> configMap) throws IOException- Throws:
IOException
-
writeFunctionJsonFile
protected void writeFunctionJsonFile(com.fasterxml.jackson.databind.ObjectWriter objectWriter, String functionName, com.microsoft.azure.toolkit.lib.legacy.function.configurations.FunctionConfiguration config) throws IOException- Throws:
IOException
-
copyHostJson
protected void copyHostJson() throws IOException- Throws:
IOException
-
copyLocalSettingsJson
protected void copyLocalSettingsJson() throws IOException- Throws:
IOException
-
copyFilesWithDefaultContent
private static void copyFilesWithDefaultContent(File source, File dest, String defaultContent) throws IOException
- Throws:
IOException
-
writeObjectToFile
protected void writeObjectToFile(com.fasterxml.jackson.databind.ObjectWriter objectWriter, Object object, File targetFile) throws IOException- Throws:
IOException
-
getObjectWriter
protected com.fasterxml.jackson.databind.ObjectWriter getObjectWriter()
-
copyJarsToStageDirectory
protected void copyJarsToStageDirectory() throws IOException, org.apache.maven.plugin.MojoExecutionException- Throws:
IOExceptionorg.apache.maven.plugin.MojoExecutionException
-
copyDependenciesToStagingDirectory
private void copyDependenciesToStagingDirectory(@Nonnull File stagingDirectory, @Nullable Set<File> dependencies) throws IOException
- Throws:
IOException
-
copyArtifactToStagingDirectory
private void copyArtifactToStagingDirectory(@Nonnull File stagingDirectory, @Nullable Set<File> dependencies) throws IOException
- Throws:
IOException
-
getResources
public List<com.microsoft.azure.maven.model.DeploymentResource> getResources()
- Overrides:
getResourcesin classcom.microsoft.azure.maven.appservice.AbstractAppServiceMojo
-
getFunctionCoreToolsHandler
protected com.microsoft.azure.toolkit.lib.legacy.function.handlers.FunctionCoreToolsHandler getFunctionCoreToolsHandler(com.microsoft.azure.toolkit.lib.legacy.function.handlers.CommandHandler commandHandler)
-
installExtension
protected void installExtension(com.microsoft.azure.toolkit.lib.legacy.function.handlers.FunctionCoreToolsHandler handler, Set<com.microsoft.azure.toolkit.lib.legacy.function.bindings.BindingEnum> bindingEnums) throws com.microsoft.azure.toolkit.lib.common.exception.AzureExecutionException- Throws:
com.microsoft.azure.toolkit.lib.common.exception.AzureExecutionException
-
getFunctionBindingEnums
protected Set<com.microsoft.azure.toolkit.lib.legacy.function.bindings.BindingEnum> getFunctionBindingEnums(Map<String,com.microsoft.azure.toolkit.lib.legacy.function.configurations.FunctionConfiguration> configMap)
-
isInstallingExtensionNeeded
protected boolean isInstallingExtensionNeeded(Set<com.microsoft.azure.toolkit.lib.legacy.function.bindings.BindingEnum> bindingTypes)
-
promptCompileInfo
protected void promptCompileInfo()
-
trackFunctionProperties
protected void trackFunctionProperties(Map<String,com.microsoft.azure.toolkit.lib.legacy.function.configurations.FunctionConfiguration> configMap)
-
-