user3310334
user3310334

Reputation:

Only build jar, then delete all folders

When I run

$ mvn install

It build the project into a jar, but it leaves behind a load of junk folders as well:

$ ls
./          archive-tmp/        generated-sources/  maven-status/
../         classes/            maven-archiver/     project-0.0.1.jar
dir1/

How do I build a maven project so that all the junk directories aren't there, only the jar file?

EDIT: note that I don't want all folders to be removed (dir1 in the above example), just the maven-related ones.

Upvotes: 0

Views: 396

Answers (1)

alexbt
alexbt

Reputation: 17085

It doesn't make much sense, but to answer your question, you may override how cleaning is handled:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-clean-plugin</artifactId>
    <version>2.6.1</version>
    <configuration>

        <excludeDefaultDirectories>true</excludeDefaultDirectories>

        <filesets>

            <fileset>
                <directory>${project.build.directory}/classes</directory>
            </fileset>
            <fileset>
                <directory>${project.build.directory}/generated-test-sources</directory>
            </fileset>

            <fileset>
                <directory>${project.build.directory}/...</directory>
            </fileset>

        </filesets>
    </configuration>
</plugin>

Upvotes: 1

Related Questions