I have a Maven project that builds fine on the command line. I want to edit the project files in Eclipse Luna 4.4.1, but when I load the project, it reports the following errors in my pom.xml file:
cvc-datatype-valid.1.2.1: '${MYVAR}' is not a valid value for 'boolean'
cvc-type.3.1.3: The value of '${MYVAR}' of element 'enabled' is not valid.
This problem looks similar to Validating Maven pom.xml when boolean is a property, which doesn't have any answers yet. While I can compile via Maven on the command line, it is annoying that Eclipse constantly reports these as errors. Is there any way to get rid of these errors without disabling the validation of the rest of the pom.xml file?
According to http://maven.apache.org/pom.html#Properties I'm referencing the MYVAR
property correctly.
Here are the relevant contents of my pom.xml file:
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>myproject</artifactId>
<groupId>org.mydomain</groupId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<properties>
<spring-version>3.0.2.RELEASE</spring-version>
<MYVAR>false</MYVAR>
</properties>
<repositories>
<repository>
<id>internal_repo</id>
<name>my internal repository for offline use</name>
<url>file://${INT_REPO_HOME}/java/maven_repo</url>
<layout>default</layout>
</repository>
<repository>
<id>central</id>
<url>http://repo1.maven.org/maven2</url>
<releases>
<enabled>${MYVAR}</enabled>
</releases>
<snapshots>
<enabled>${MYVAR}</enabled>
</snapshots>
</repository>
</repositories>
</project>
i think that this is a timeing/order problem. maven first trys to build the whole project model before it executes is. so to collect all pom.xml to construct the whole model of the project it uses the repositories. and AFTER this it uses the properties and replaces all the variables for the effective project model (pom.xml)
if you use the ${MYVAR} outside the definition it should be no problem.. right?
Eclipse is validating the XSD of the POM which says that this XML element is of type boolean.
Valid values for boolean are true/false so when it sees ${MYVAR} it raises a validation error... because the plugin of Eclipse doesn't do the variable translation from "${MYVAR}" to "false".
However if you do a mvn install it works with no problem, which means that the pom is correct.
Conclusion, this is an Elipse plugin issue so you can only ignore it.
It appears that this is an Eclipse issue, because Eclipse developers refuse to acknowledge the difference between a templated XML and a runtime XML. Only in the latter case does validation matter.
They have a good concept of allowing you to turn validations on/off, or converting some to warnings. But, in this case, there this option does not exist.
People have suggested that you can turn this validation off, but I've tried to know avail. Personally, I have no interest in any XSD validation being done by Eclipse.
The only option I'm aware of is to lobby https://bugs.eclipse.org/bugs/