Search code examples
mavencmusphinxmaven-dependency-plugin

How to depend on this maven project


My projects consists of three sub-projects, and my parent pom looks like:

<groupId>com.bwort.core</groupId>
<artifactId>bwort</artifactId>
<packaging>pom</packaging>
<version>0.0.1-SNAPSHOT</version>

<name>bwort</name>

<modules>
  <module>proj1</module>
  <module>proj2</module>
  <module>proj3</module>             
</modules>

Now my project needs to dependent this project below, which comprises three subprojects, with a parent pom. In particular, it already has a parent as below: https://github.com/cmusphinx/sphinx4/blob/master/pom.xml

  <parent>
    <groupId>org.sonatype.oss</groupId>
    <artifactId>oss-parent</artifactId>
    <version>7</version>
  </parent>

  <groupId>edu.cmu.sphinx</groupId>
  <artifactId>sphinx4-parent</artifactId>
  <version>1.0-SNAPSHOT</version>
  <packaging>pom</packaging>

My question is, how can I declare the dependency in my parent pom file? I can add another module to my parent pom:

<module>sphinx4</module>

But since this library already defined its own parent "oss-parent", then how can I make my parent pom as its parent?

What's the right way for my project to depend on this project? Thank you.

EDITTED: My pom.xml

 <project >
  <modelVersion>4.0.0</modelVersion>

   <parent>
     <groupId>com.bwort.core</groupId>
     <artifactId>bwort</artifactId>
     <version>0.0.1-SNAPSHOT</version>
   </parent>

    <artifactId>wikipedia</artifactId>
    <packaging>jar</packaging>


  <repositories>
       <repository>
           <id>snapshots-repo</id>
           <url>https://oss.sonatype.org/content/repositories/snapshots</url>
           <releases><enabled>false</enabled></releases>
          <snapshots><enabled>true</enabled></snapshots>
       </repository>
    </repositories>

  <dependencies>

    <dependency>
        <groupId>edu.cmu.sphinx</groupId>
        <artifactId>sphinx4-core</artifactId>
        <version>1.0-SNAPSHOT</version>
    </dependency>
    <dependency>
        <groupId>edu.cmu.sphinx</groupId>
        <artifactId>sphinx4-data</artifactId>
        <version>1.0-SNAPSHOT</version>
    </dependency>

 </dependencies>   

</project>

Solution

  • If your pom.xml has something like the following, it should work:

    <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>
        <groupId>com.mycompany.app</groupId>
        <artifactId>my-app</artifactId>
        <packaging>jar</packaging>
        <version>1.0-SNAPSHOT</version>
        <name>my-app</name>
        <url>http://maven.apache.org</url>
        <repositories>
            <repository>
                <id>snapshots-repo</id>
                <url>https://oss.sonatype.org/content/repositories/snapshots</url>
                <releases>
                    <enabled>false</enabled>
                </releases>
                <snapshots>
                    <enabled>true</enabled>
                </snapshots>
            </repository>
        </repositories>
        <dependencies>
            <dependency>
                <groupId>junit</groupId>
                <artifactId>junit</artifactId>
                <version>3.8.1</version>
                <scope>test</scope>
            </dependency>
            <dependency>
                <groupId>edu.cmu.sphinx</groupId>
                <artifactId>sphinx4-core</artifactId>
                <version>1.0-SNAPSHOT</version>
            </dependency>
            <dependency>
                <groupId>edu.cmu.sphinx</groupId>
                <artifactId>sphinx4-data</artifactId>
                <version>1.0-SNAPSHOT</version>
            </dependency>
        </dependencies>
    </project>