GergA
GergA

Reputation: 314

Maven build not download all needed files

I have a maven build what should download some jar files form the same directory in nexus. There are

myproduct_model-1.32-SNAPSHOT.jar
and
myproduct_model-1.32-SNAPSHOT-liquibase.jar

The build successfully download the first one but not the second. How can I force that?

Upvotes: 0

Views: 160

Answers (2)

Pierre B.
Pierre B.

Reputation: 12933

You can use the <classifier> element on your dependencies, such as:

  <dependency>
      <groupId>com.deltabasics</groupId>
      <artifactId>myproduct_model</artifactId>
      <version>${version-myproduct_model}</version>
  </dependency>
  <dependency>
      <groupId>com.deltabasics</groupId>
      <artifactId>myproduct_model</artifactId>
      <version>${version-myproduct_model}</version>
      <classifier>liquibase</classifier>
  </dependency>

This will make Maven download both dependencies even if they use the same version as the classifier is different. If you want these dependencies to be download in your project target directory, use the maven-dependency-plugin with the same method:

<build>
  <plugins>
    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-dependency-plugin</artifactId>
        <version>3.0.2</version>
        <executions>
            <execution>
                <id>copy</id>
                <phase>package</phase>
                <goals>
                    <goal>copy</goal>
                </goals>
                <configuration>
                    <artifactItems>
                        <artifactItem>
                            <groupId>com.deltabasics</groupId>
                            <artifactId>myproduct_model</artifactId>
                            <version>${version-myproduct_model}</version>
                            <type>jar</type>
                        </artifactItem>
                        <artifactItem>
                            <groupId>com.deltabasics</groupId>
                            <artifactId>myproduct_model</artifactId>
                            <version>${version-myproduct_model}</version>
                            <type>jar</type>
                            <classifier>liquibase</classifier>
                        </artifactItem>
                    </artifactItems>
                </configuration>
            </execution>
        </executions>
     </plugin>
  </plugins>
</build>

Upvotes: 1

GergA
GergA

Reputation: 314

I tried to add the following rows

     <dependency>
          <groupId>com.deltabasics</groupId>
          <artifactId>myproduct_model</artifactId>
          <version>${version-myproduct_model}-liquibase</version>
      </dependency>

Unfortunately the maven made the other folder instead of downloading.

Upvotes: 0

Related Questions