Skip to content

[MWAR-443] Maven WAR plugin is deleting files generated by Maven Dependency plugin after upgrading to 3.3.1 #522

@jira-importer

Description

@jira-importer

David Benes opened MWAR-443 and commented

In my project, I'm using Derby database. Derby also needs locales, otherwise I get warning in the log file. Derby mentings these locales in manifest file without versions. So I ended up using something like following pom.xml (simplified)

<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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>test</groupId>
    <artifactId>maven-war-issue</artifactId>
    <version>0.0.1</version>
    <packaging>war</packaging>
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <derby.version>10.14.2.0</derby.version>
    </properties>
    <dependencies>
        <dependency>
            <groupId>org.apache.derby</groupId>
            <artifactId>derby</artifactId>
            <version>${derby.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.derby</groupId>
            <artifactId>derbyLocale_cs</artifactId>
            <version>${derby.version}</version>
            <scope>provided</scope>
        </dependency>
    </dependencies>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.8.1</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <version>3.2.0</version>
                <executions>
                    <execution>
                        <id>copy</id>
                        <phase>prepare-package</phase>
                        <goals>
                            <goal>copy-dependencies</goal>
                        </goals>
                        <configuration>
                            <includeArtifactIds>derbyLocale_cs</includeArtifactIds>
                            <outputDirectory>${project.build.directory}/${project.artifactId}-${project.version}/WEB-INF/lib</outputDirectory>
                            <overWriteReleases>false</overWriteReleases>
                            <overWriteSnapshots>false</overWriteSnapshots>
                            <overWriteIfNewer>true</overWriteIfNewer>
                            <stripVersion>true</stripVersion>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <version>3.3.1</version>
                <configuration>
                    <warSourceDirectory>WebContent</warSourceDirectory>
                    <failOnMissingWebXml>false</failOnMissingWebXml>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

After upgrading to Maven WAR plugin, this stopped working because after copying artifacts, by the Maven Dependency plugin to correct location they are deleted by Maven WAR plugin as shown in below:

C:\code\maven-war-issue>mvn package
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------< test:maven-war-issue >------------------------
[INFO] Building maven-war-issue 0.0.1
[INFO] --------------------------------[ war ]---------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ maven-war-issue ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory C:\code\maven-war-issue\src\main\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.8.1:compile (default-compile) @ maven-war-issue ---
[INFO] No sources to compile
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ maven-war-issue ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory C:\code\maven-war-issue\src\test\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.8.1:testCompile (default-testCompile) @ maven-war-issue ---
[INFO] No sources to compile
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ maven-war-issue ---
[INFO] No tests to run.
[INFO]
[INFO] --- maven-dependency-plugin:3.2.0:copy-dependencies (copy) @ maven-war-issue ---
[INFO] Copying derbyLocale_cs-10.14.2.0.jar to C:\code\maven-war-issue\target\maven-war-issue-0.0.1\WEB-INF\lib\derbyLocale_cs.jar
[INFO]
[INFO] --- maven-war-plugin:3.3.1:war (default-war) @ maven-war-issue ---
[INFO] Packaging webapp
[INFO] Assembling webapp [maven-war-issue] in [C:\code\maven-war-issue\target\maven-war-issue-0.0.1]
[INFO] Processing war project
[INFO] deleting outdated resource WEB-INF\lib\derbyLocale_cs.jar
[INFO] Building war: C:\code\maven-war-issue\target\maven-war-issue-0.0.1.war
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  1.944 s
[INFO] Finished at: 2021-07-09T16:35:29+02:00
[INFO] ------------------------------------------------------------------------C:\code\maven-war-issue>

For me it seems to be the same as MWAR-433, but as that was already fixed in version 3.3.1, this seems to be another case.

Is there some way how I can mark those artifacts copied by Maven Dependency plugin as not outdated?


Affects: 3.3.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingpriority:majorMajor loss of function

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions