简体   繁体   中英

Eclipse maven plugin (m2e) is including unexpected files

I'm working with a maven project in eclipse. When I run with "Run As->Maven install" the jar is generated into the target folder properly. But I detected the size of targeted jar is different than if I build the project by command line:

mvn clean install

I have compared both jar files and I see that the jar created by eclipse contains files that are not in the jar generated with commad line. All the files are into src folder in many packages. As example: /src/main/java/Dummy/resources/file.pdf

file extensions included in jar file generated with Eclipse : bd cer cfg class css cvsignore dld gitignore htm jar jardesc jasper jrxml MF odt pdf properties sql txt wsdd xml xsl

file extensions included in jar file generated with Command line : class MF properties xml

I need only: class, MF, properties, xml, cfg and xsl extensions

I have created an example in https://github.com/RubenPozoMolina/49939684

The project contains src/main/resources/test.pdf and src/main/java/dummy/iddummy/resources/test.odt

with eclipse iddummy-0.0.1-SNAPSHOT.jar contains test.odt file executing with command line test.odt file is not into the jar file

How can I configure the files to be included in eclipse?

You are having non-Java files in you src/main/java folder. They need to be elsewhere.

To be sure of the files contained in the jar I have modified my pom with:

    <build>
    <resources>
        <resource>
            <directory>src/main/java</directory>
            <filtering>true</filtering>
            <includes>
                <include>**/*.MF</include>
                <include>**/*.cfg</include>
                <include>**/*.properties</include>
                <exclude>**/*.xml</exclude>
                <exclude>**/*.xsl</exclude>
            </includes>
            <excludes>
                <exclude>**/*.bd</exclude>
                <exclude>**/*.cer</exclude>
                <exclude>**/*.cvsignore</exclude>
                <exclude>**/*.css</exclude>
                <exclude>**/*.htm</exclude>
                <exclude>**/*.gitignore</exclude>
                <exclude>**/*.jardesc</exclude>
                <exclude>**/*.jasper</exclude>
                <exclude>**/*.jrxml</exclude>
                <exclude>**/*.sql</exclude>
                <exclude>**/*.wsdd</exclude>
                <exclude>**/*.odt</exclude>
                <exclude>**/*.pdf</exclude>
            </excludes>
        </resource>
    </resources>
</build>

Now the files generated by eclipse and maven via command line are identical

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM