microsoft / microsoft/azure-maven-plugins
Azure Web Apps Maven Plugin zip deployment type not zipping jar.
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 293
- Forks
- 160
- PR merge metrics
- No merged PRs in 30d
Description
Plugin name and version
<groupId>com.microsoft.azure</groupId>
<artifactId>azure-webapp-maven-plugin</artifactId>
<version>2.5.0</version>
Plugin configuration in your pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.5.8</version>
<relativePath/>
<!-- lookup parent from repository -->
</parent>
<groupId>com.example</groupId>
<artifactId>app</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>user</name>
<description>Demo project for Spring Boot</description>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>com.microsoft.azure</groupId>
<artifactId>azure-webapp-maven-plugin</artifactId>
<version>2.5.0</version>
<configuration>
<schemaVersion>v2</schemaVersion>
<subscriptionId>sub</subscriptionId>
<resourceGroup>rg</resourceGroup>
<appName>appname</appName>
<pricingTier>P3v2</pricingTier>
<region>east</region>
<runtime>
<os>Linux</os>
<javaVersion>Java 8</javaVersion>
<webContainer>Java SE</webContainer>
</runtime>
<!-- Begin of App Settings -->
<appSettings>
<property>
<name>JAVA_OPTS</name>
<value>-Dserver.port=80</value>
</property>
</appSettings>
<!-- End of App Settings -->
<deployment>
<resources>
<resource>
<directory>${project.basedir}/target</directory>
<includes>
<include>*.zip</include>
</includes>
<type>zip</type>
</resource>
</resources>
</deployment>
</configuration>
<executions>
<execution>
<phase>install</phase>
<configuration>
<file>${project.build.finalName}.${project.packaging}</file>
<generatePom>false</generatePom>
<pomFile>pom.xml</pomFile>
<version>${version}</version>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.6</version>
<configuration>
<descriptors>
<descriptor>src/main/resources/assembly.xml</descriptor>
</descriptors>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<excludes>
<exclude>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>
</project>
assembly.xml
<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
<id>zip</id>
<baseDirectory>/</baseDirectory>
<formats>
<format>zip</format>
</formats>
<fileSets>
<fileSet>
<directory>${project.build.directory}</directory>
<includes>
<include>*.jar</include>
</includes>
</fileSet>
</fileSets>
</assembly>
The above pom and assembly are able to zip up jar file in target build folder. We have a need to override the default behavior of the plugin such that it does not rename the final build artifact to app.jar.
Note: the above when deployed to app service causes a "no main manifest attribute" error.
Probably due to some issues with the assembly. Found the solution for that below but would be nice to see if there is a better approach.
https://stackoverflow.com/questions/34852410/using-maven-assembly-plugin-to-create-zip-file-containing-a-fat-jar-jar-with-de
Expected behavior
Expect the azure maven plugin for web app to zip up the jar after changing the deployment type to zip, but it does not. If this is expected is there a better solution you can suggest than the one above ?
Actual behavior
The maven assembly plugin was added as a work around because currently changing the deployment type to zip requires that you add additional code just to zip the jar file after build.
Steps to reproduce the problem
Add to a simple Spring Boot project targeting App Service Linux Java.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the deployment with the supplied pom.xml and assembly.xml in a simple Spring Boot project targeting App Service Linux Java. Start by checking how the Azure Web Apps Maven Plugin handles the deployment resources and zip type, then compare this with the assembly workaround. Done means a zip deployment includes the built jar without requiring extra assembly configuration and the deployed application starts successfully.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- azure, java, spring-boot
- Domain
- cloud, devops
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100