Learning Maven: "Unable to parse configuration" for jar plugin

Viewed 13518

I am attempting to learn maven on a small project of my own, using eclipse. I converted the existing project to the maven standard directory configuration, and it was building; now I'm trying to get maven to produce the jar for the application. The following is pom.xml:

<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/xsd/maven-4.0.0.xsd">
    <modelVersion>  4.0.0           </modelVersion>
    <groupId>       com.rc          </groupId>
    <artifactId>    SpaceCheck      </artifactId>
    <version>       0.9.1-SNAPSHOT  </version>
    <name>          SpaceCheck      </name>
    <packaging>     jar             </packaging>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>

    <build>
        <plugins>
              <plugin>
                  <groupId>   org.apache.maven.plugins </groupId>
                  <artifactId>maven-jar-plugin         </artifactId>
                  <version>   2.3.2                    </version>
                  <configuration>
                <includes>**/src/*</includes>
                      <archive>
                          <manifest>
                              <addClasspath>true</addClasspath>
                              <classpathPrefix>lib/</classpathPrefix>
                              <mainClass>spacecheck.SpaceCheck</mainClass>
                          </manifest>
                      </archive>
                  </configuration>
              </plugin>
        </plugins>
    </build>

</project>

I didn't use to have the 'includes' clause; as near as I can tell, that's what the example I got pointed to told me to do to fix the problem. It does not.

When I attempt to build, I get:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-jar-plugin:2.3.2:jar (default-jar) on project SpaceCheck: Unable to parse configuration of mojo org.apache.maven.plugins:maven-jar-plugin:2.3.2:jar for parameter includes: Cannot assign configuration entry 'includes' with value '*/src/' of type java.lang.String to property of type java.lang.String[] -> [Help 1]

The "Help 1" link points me to the tutorial that I followed to get this far.

The problem I have with the tutorial is that it doesn't explain how things work -- it gives you an example and expects you to extract general workings from the example. There's nothing wrong with examples, but they rarely match exactly what one wants to do.

I'm sure many people can tell me what's wrong, and I would appreciate it. But it would be even better if they could ALSO tell me where this is explained, not just where there is an example that does something similar. The explanation, to be complete, would explain what element needs to be added, just where in the XML that goes, and what the various options are for the thing that goes there.

3 Answers

The problem is maven version

Following format for list/set is support in maven 3.3.9 and onward versions but in lower versions it not supported.

<includes>**/src/*</includes>

But in maven version less than 3.3.9, above is not supported

To fix make it backward compatible

<includes>
    <include>**/src/*</include>   
</includes>

PS: for more details check this link

Related