Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

why does m2e plugin for eclipse insert optional attribute to src and what does it do

I started noticing these attributes in my .classpath file after running Maven -> Update Project... tool with Update project configuration from pom.xml option checked:

<?xml version="1.0" encoding="UTF-8"?>
<classpath>
    <classpathentry kind="src" output="target/classes" path="src">
        <attributes>
            <attribute name="optional" value="true"/>
            <attribute name="maven.pomderived" value="true"/>
         </attributes>
    </classpathentry>
    ...
</classpathentry>

The attribute that made me raise my eyebrows the most was this: <attribute name="optional" value="true"/>.

What does it do? It looks mighty suspicious as I find nothing optional about my java source files in a project.

like image 246
Roland Tepp Avatar asked Feb 11 '13 10:02

Roland Tepp


1 Answers

This is added because the src folder is an optional folder for maven. The project should not complain if src is missing. (Actually by default, this should be src/main/java and src/test/java). This means that adding or removing src as a source file should not require updating your maven configuration.

This attribute doesn't need to be there in your case, but it makes it plain that maven doesn't care if the source folder exists as long as everything can be compiled (so Eclipse shouldn't care either).

like image 92
Andrew Eisenberg Avatar answered Oct 05 '22 22:10

Andrew Eisenberg