0

I have a maven pom file with a dependency as below:

    <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.scholastic.report</groupId>
  <artifactId>testaurora</artifactId>
  <version>2.0.0</version>
  <packaging>jar</packaging>

  <name>testaurora</name>
  <url>http://maven.apache.org</url>

  <build>
    <sourceDirectory>src</sourceDirectory>
    <plugins>
      <plugin>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.7.0</version>
        <configuration>
          <source>1.8</source>
          <target>1.8</target>
        </configuration>
      </plugin>
          <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-dependency-plugin</artifactId>
    <executions>
        <execution>
            <id>copy-dependencies</id>
            <phase>prepare-package</phase>
            <goals>
                <goal>copy-dependencies</goal>
            </goals>
            <configuration>
                <outputDirectory>${project.build.directory}/lib</outputDirectory>
                <overWriteReleases>false</overWriteReleases>
                <overWriteSnapshots>false</overWriteSnapshots>
                <overWriteIfNewer>true</overWriteIfNewer>
            </configuration>
        </execution>
    </executions>
</plugin>
<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <version>3.2.0</version>
    <artifactId>maven-jar-plugin</artifactId>
    <configuration>
        <archive>
            <manifest>
                <addClasspath>true</addClasspath>
                <classpathPrefix>lib/</classpathPrefix>
                <mainClass>com.scholastic.report.TestAuoraReport</mainClass>
            </manifest>
        </archive>
    </configuration>
</plugin>
    </plugins>
  </build>
  <dependencies>
    <dependency>
            <groupId>com.datadoghq</groupId>
            <artifactId>datadog-api-client</artifactId>
            <version>2.8.0</version>
        </dependency>
    </dependencies>
       
</project>

When I run mvn clean install, I get the jar file "datadog-api-client.jar" pulled from maven central but I don't get the dependencies mentioned under datadog-api-client.jar/META_INF/maven/com.datadoghq/datadog-api-client/pom.xml. Is there anything that I should do to bring down all the jars that datadog api depends on.

[WARNING] The POM for org.glassfish.jersey.core:jersey-client:jar:3.0.8 is invalid, transitive dependencies (if any) will not be available, enable debug logging for more details
[WARNING] The POM for org.glassfish.jersey.connectors:jersey-apache-connector:jar:3.0.8 is invalid, transitive dependencies (if any) will not be available, enable debug logging for more details
[WARNING] The POM for org.glassfish.jersey.inject:jersey-hk2:jar:3.0.8 is invalid, transitive dependencies (if any) will not be available, enable debug logging for more details
[WARNING] The POM for org.glassfish.jersey.media:jersey-media-multipart:jar:3.0.8 is invalid, transitive dependencies (if any) will not be available, enable debug logging for more details
[WARNING] The POM for org.glassfish.jersey.media:jersey-media-json-jackson:jar:3.0.8 is invalid, transitive dependencies (if any) will not be available, enable debug logging for more details
[INFO] 
[INFO] --- maven-dependency-plugin:2.8:tree (default-cli) @ ddaurora ---
[INFO] com.scholastic.report:ddaurora:jar:2.0.0
[INFO] \- com.datadoghq:datadog-api-client:jar:2.8.0:compile
[INFO]    +- jakarta.annotation:jakarta.annotation-api:jar:2.1.0:compile
[INFO]    +- org.glassfish.jersey.core:jersey-client:jar:3.0.8:compile
[INFO]    +- org.glassfish.jersey.connectors:jersey-apache-connector:jar:3.0.8:compile
[INFO]    +- org.glassfish.jersey.inject:jersey-hk2:jar:3.0.8:compile
[INFO]    +- org.glassfish.jersey.media:jersey-media-multipart:jar:3.0.8:compile
[INFO]    +- org.glassfish.jersey.media:jersey-media-json-jackson:jar:3.0.8:compile
[INFO]    +- com.fasterxml.jackson.core:jackson-core:jar:2.13.2:compile
[INFO]    +- com.fasterxml.jackson.core:jackson-annotations:jar:2.13.2:compile
[INFO]    +- com.fasterxml.jackson.datatype:jackson-datatype-jsr310:jar:2.13.2:compile
[INFO]    +- com.fasterxml.jackson.core:jackson-databind:jar:2.13.4.2:compile
[INFO]    +- org.openapitools:jackson-databind-nullable:jar:0.2.3:compile
[INFO]    \- com.github.scribejava:scribejava-core:jar:8.3.1:compile
[INFO]       \- com.github.scribejava:scribejava-java8:jar:8.3.1:compile
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
Ashok Ambrose
  • 191
  • 3
  • 17
  • You should get all dependencies automatically, unless they are of the wrong scope (like `provided` or `test`) or lie within ``. – J Fabian Meier Feb 24 '23 at 09:14
  • Yes I should have got automatically but looks like its not bringing it. Am I missing something in the maven settings? – Ashok Ambrose Feb 24 '23 at 11:01
  • No. Can you show us the POM and say what you expect but is missing? – J Fabian Meier Feb 24 '23 at 11:03
  • I have added the pom here. If you see the dependency it is only datadog-api-client.jar. When I do a mvn clean install it should also bring the dependencies mentioned in the datadog-api-client.jar file's META-INF folder but its not bringing those jars which is dependent on datadog-api-client. – Ashok Ambrose Feb 24 '23 at 11:12
  • So what does `mvn dependency:tree` give you? Does it show the dependencies? – J Fabian Meier Feb 24 '23 at 11:14
  • yes it doesn't show all the jars. Some of the jars are missing so the program gives a class not found. – Ashok Ambrose Feb 24 '23 at 11:38
  • So where exactly are they missing? Are they not copied to `${project.build.directory}/lib`? – J Fabian Meier Feb 24 '23 at 11:51
  • I have added the output of mvn dependency:tree. It shows some warnings for the pom dependency and hence its not loading those jars. – Ashok Ambrose Feb 24 '23 at 12:56

2 Answers2

0

You probably have some inconsistencies in your local repository.

Remove or rename .m2/repository (in your user dir) and try again.

J Fabian Meier
  • 33,516
  • 10
  • 64
  • 142
0

While running the dependency:tree I received the below warnings, upon fixing this in POM I was able to solve this problem.

The pom file had a tag problem in it which restricted all these jar files from getting downloaded.

[WARNING] The POM for org.glassfish.jersey.core:jersey-client:jar:3.0.8 is invalid, transitive dependencies (if any) will not be available, enable debug logging for more details
[WARNING] The POM for org.glassfish.jersey.connectors:jersey-apache-connector:jar:3.0.8 is invalid, transitive dependencies (if any) will not be available, enable debug logging for more details
[WARNING] The POM for org.glassfish.jersey.inject:jersey-hk2:jar:3.0.8 is invalid, transitive dependencies (if any) will not be available, enable debug logging for more details
[WARNING] The POM for org.glassfish.jersey.media:jersey-media-multipart:jar:3.0.8 is invalid, transitive dependencies (if any) will not be available, enable debug logging for more details
[WARNING] The POM for org.glassfish.jersey.media:jersey-media-json-jackson:jar:3.0.8 is invalid, transitive dependencies (if any) will not be available, enable debug logging for more details
avariant
  • 2,234
  • 5
  • 25
  • 33
Ashok Ambrose
  • 191
  • 3
  • 17