Maven: Cannot delete filtered resources

223 Views Asked by At

Within my pom.xml, I filter some resources and set the output directory ("asciidoc-filtered") to a folder within my /target folder: /target/asciidoc-filtered.

After some build steps, I want to delete this "asciidoc-filtered" folder with the maven-clean-plugin. I can basically handle the plugin and delete some other stuff, but I somehow cannot delete the folder "asciidoc-filtered".

Here is the extract of the POM:

...
    <build>
        <resources>
            <resource>
                <directory>src/main/asciidoc</directory>
                <targetPath>${project.build.directory}/asciidoc-filtered</targetPath>
                <filtering>true</filtering>
            </resource>
        </resources>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
            <plugin>
                <groupId>org.asciidoctor</groupId>
                <artifactId>asciidoctor-maven-plugin</artifactId>
                <version>1.5.6</version>
                <executions>
                    <execution>
                        <id>generate-html</id>
                        <phase>prepare-package</phase>
                        <goals>
                            <goal>process-asciidoc</goal>
                        </goals>
                        <configuration>
                            <sourceDirectory>${project.build.directory}/asciidoc-filtered</sourceDirectory>
                            <outputDirectory>${project.build.directory}</outputDirectory>
                            <backend>html5</backend>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-assembly-plugin</artifactId>
                <configuration>
                    <descriptor>src/main/resources/assembly.xml</descriptor>
                </configuration>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>single</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-clean-plugin</artifactId>
                <configuration>
                    <excludeDefaultDirectories>true</excludeDefaultDirectories>
                    <filesets>
                        <fileset>
                            <directory>${project.build.directory}</directory>
                            <includes>
                                <include>**/*</include>
                            </includes>
                            <excludes>
                                <exclude>*.jar</exclude>
                                <exclude>*.zip</exclude>
                                <exclude>*.html</exclude>
                            </excludes>
                        </fileset>
                    </filesets>
                </configuration>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>clean</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
...

So without the maven-clean-plugin, my /target looks something like this:

enter image description here

And with the maven-clean-plugin, my /target looks something like this:

enter image description here

What I want to achieve is something that looks like this:

enter image description here

Are there any ideas, why it doesn't work? Or any solutions, how to make it work?

Thanks a lot in advance ;-)

0

There are 0 best solutions below