kumade
kumade

Reputation: 541

Exclude *.java source files from WAR package

I have a problem with filtering my *.java files from resulting WAR package. I'm using maven 3.0.3. My pom.xml is like this:

<?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 http://maven.apache.org/maven-v4_0_0.xsd">

<parent>
    <groupId>com.my</groupId>
    <artifactId>app</artifactId>
    <version>1.00</version>
</parent>

<modelVersion>4.0.0</modelVersion>
<groupId>com.my.app</groupId>
<artifactId>app</artifactId>
<packaging>war</packaging>
<name>My Webapp</name>

<build>
    <finalName>My</finalName>

    <resources>
        <resource>
            <directory>src/main/java</directory>
            <filtering>true</filtering>
            <excludes>
                <exclude>*.java</exclude>
            </excludes>
        </resource>

        <resource>
            <directory>src/main/resources</directory>
        </resource>
    </resources>
....

and then I'm asembling my WAR with mvn clean package. After that I can see all my *.java files inside my WAR. Am I having wrong config or\and am I executing wrong maven plugins?

P.S. I've also tried to use the following plugin:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-war-plugin</artifactId>
    <configuration>
      <warSourceExcludes>**/*.java</warSourceExcludes>
    </configuration>
  </plugin>

with mvn war:war but with no success.

Upvotes: 1

Views: 2533

Answers (2)

Ianrakisa
Ianrakisa

Reputation: 51

Don't Use <warSourceExcludes>, try as like below

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>3.2.0</version>
<configuration>
<packagingExcludes>
    WEB-INF/**/*.java
</packagingExcludes>
</configuration>
</plugin>

Upvotes: 0

kumade
kumade

Reputation: 541

With @khmarbaise 's help i have found the cause of a problem. In my case i just removed the "<resource>" section for "src/main/java" folder.

Upvotes: 1

Related Questions