Error: 'dependencies.dependency.version' must be a valid version but is

StackOverflow https://stackoverflow.com/questions/23690753

  •  29-07-2023
  •  | 
  •  

Frage

I have this parent POM file (hawaii-banner\pom.xml):

<?xml version="1.0"?>
<project xmlns="http://maven.apache.org/POM/4.0.0">
  <modelVersion>4.0.0</modelVersion>
  <parent>
    <artifactId>base</artifactId>
    <groupId>org.sakaiproject</groupId>    
    <version>2.9.3</version>
    <relativePath>../pom.xml</relativePath>
  </parent>
  <name>University of Hawaii Banner</name>
  <groupId>edu.hawaii.sakai</groupId>
  <artifactId>hawaii-banner</artifactId>
  <version>${hawaii.banner.version}</version>
  <packaging>pom</packaging>
  <properties>
    <downloadSources>true</downloadSources>
    <downloadJavadocs>true</downloadJavadocs>
    <hawaii.banner.version>2.5.0</hawaii.banner.version>
    <uh-gatech.version>2.5.1</uh-gatech.version>
  </properties>
  <dependencies>
    <dependency>
      <groupId>org.sakaiproject.kernel</groupId>
      <artifactId>sakai-kernel-api</artifactId>
      <version>${sakai.kernel.version}</version>
    </dependency>
    <dependency>
      <groupId>org.sakaiproject.kernel</groupId>
      <artifactId>sakai-kernel-util</artifactId>
      <version>${sakai.kernel.version}</version>
    </dependency>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>4.4</version>
      <scope>test</scope>
    </dependency>
  </dependencies>  

  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <configuration>
          <includes>
            <include>**/*Test.java</include>
          </includes>

          <!-- Exclude by default the tests that use remote systems. -->
          <excludes>
            <exclude>**/*Test.java</exclude>
          </excludes>
        </configuration>
      </plugin>
    </plugins>
  </build>

  <modules>
    <module>api</module>
    <module>impl</module>
    <module>integration-test</module>
    <module>pack</module>
    <module>sections-impl</module>
  </modules>

</project>

And this child POM file (hawaii-banner\api\pom.xml):

<?xml version="1.0"?>
<project xmlns="http://maven.apache.org/POM/4.0.0">
  <modelVersion>4.0.0</modelVersion>
  <parent>
    <groupId>edu.hawaii.sakai</groupId>
    <artifactId>hawaii-banner</artifactId>
    <version>2.5.0</version>
    <relativePath>../pom.xml</relativePath>
  </parent>
  <name>University of Hawaii Banner API</name>
  <groupId>edu.hawaii.sakai</groupId>
  <artifactId>hawaii-banner-api</artifactId>
  <version>${hawaii.banner.version}</version>
  <packaging>jar</packaging>
  <properties>
    <deploy.target>shared</deploy.target>
  </properties>
  <dependencies>
    <dependency>
      <groupId>dom4j</groupId>
      <artifactId>dom4j</artifactId>
    </dependency>
    <dependency>
      <groupId>edu.gatech.sakai</groupId>
      <artifactId>uh-gatech-banner-api</artifactId>
      <version>${uh-gatech.version}</version>
      <scope>provided</scope>
    </dependency>
  </dependencies>
</project>

But I'm getting this error:

[ERROR]     'dependencies.dependency.version' for edu.gatech.sakai:uh-gatech-banner-api:jar must be a valid version but is '${uh-gatech.version}'. @ edu.hawaii.sakai:hawaii-banner-api:${hawaii.banner.version}, C:\hawaii-sakai-2.9.3\sakai-src-2.9.3\hawaii-banner\api\pom.xml, line 26, column 16

I don't understand why I'm getting this error because uh-gatech.version is defined in the parent POM file, and <version>${uh-gatech.version}</version> used to be <version>2.5.1</version>, which worked.

I ran mvn clean install from the same directory as the parent POM file, and it didn't work.

Keine korrekte Lösung

Andere Tipps

If maven gives this error, it means that the child module does not recognize the parent properly. I've seen this happen with wrong versions.
You think you are defining the right parent, but you are not. As @jordan suggested, by eliminating the child-parent relationship, you can see it works.

You cannot define the version of a module to be a variable you defined in the same pom, and maven will not want on this.

Although you think it's 2.5.0, it's not...

I suggest you review this relationship definition in your project.

I hope this helps.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top