how do I configure the dependency among my local jars with maven? - maven

I have configured a local repository and have some jars on it. Through the pom file, I used them but when I execute the mvn package phase, I'm seeing...
[WARNING] The POM for p-unit:p-unit:jar:0.15.319 is missing, no dependency information available
[WARNING] The POM for p-unit:p-unit-extension:jar:0.15.319 is missing, no dependency information available
I guess that maven didn't found the jars in the maven repo, so then it uses my local repo because the package phase ends fine.. but I would like to configure the dependency among my local jars (the p-unit-extension.jar depends on the p-unit.jar). How can I configure this in maven?
this is my pom
<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.test</groupId>
<artifactId>perf-test</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>punit-test</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<repositories>
<repository>
<id>snapshots</id>
<url>file:///D:/Users/jmann/.m2/local</url>
<releases>
<enabled>false</enabled>
</releases>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>p-unit</groupId>
<artifactId>p-unit</artifactId>
<version>0.15.319</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>p-unit</groupId>
<artifactId>p-unit-extension</artifactId>
<version>0.15.319</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
I would like to put only the p-unit-extension dependency so that maven downloads the p-unit jar automatically. Any error in my pom, please tell me.
this is my settings.xml:
<settings xmlns="maven.apache.org/SETTINGS/1.1.0"; xmlns:xsi="w3.org/2001/XMLSchema-instance"; xsi:schemaLocation="maven.apache.org/SETTINGS/1.1.0 maven.apache.org/xsd/settings-1.1.0.xsd">;
<localRepository>D:/Users/jmann/.m2/local</localRepository>
<interactiveMode/>
<usePluginRegistry/>
<offline/>
<activeProfiles/>
<pluginGroups/>
</settings>

Related

Stop Maven downloading plugins from private repository?

We have a company Nexus repository which has just a couple of private libraries but it mostly mirrors the public Maven Nexus repository.
The repository is on a private network which can only be accessed by VPN.
This is accessed using a settings.xml config like so (redacted)
User Settings.xml
<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
<servers>
<server>
<id>FOOSNAPSHOTS</id>
<username>foo-publisher</username>
<password>12345</password>
</server>
<server>
<id>BARRELEASES</id>
<username>bar-publisher</username>
<password>12345</password>
</server>
</servers>
<mirrors>
<mirror>
<id>foo-nexus</id>
<mirrorOf>*</mirrorOf>
<url>https://foo/repository/foo-maven-group/</url>
</mirror>
<mirror>
<id>bar-nexus</id>
<mirrorOf>*</mirrorOf>
<url>https://foo/repository/bar-maven-group/</url>
</mirror>
</mirrors>
<profiles>
<profile>
<id>allow-snapshots</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<repositories>
<repository>
<id>snapshots-repo</id>
<url>https://foo/repository/hosted-foo-snapshots</url>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
<repository>
<id>foo-snapshots-repo</id>
<url>https://foo/repository/hosted-bar-snapshots</url>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
</profile>
</profiles>
</settings>
In a sample spring boot project, when trying to build a project when not connected to the VPN it fails because it cannot get plugins like the following.
[ERROR] No plugin found for prefix 'spring-boot' in the current project and in the plugin groups [org.apache.maven.plugins, org.codehaus.mojo] available from the repositories [local (/Users/bobbytables/.m2/repository), foo-nexus (https://foo/repository/foo-maven-group/)] -> [Help 1]
This is annoying as it then requires to be on the VPN, is there a way to get Maven to download plugins from public repos?
Parent POM
<?xml version="1.0" encoding="UTF-8"?>
<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>
<parent>
<groupId>foo.shared-maven-parent</groupId>
<artifactId>shared-maven-parent-java</artifactId>
<version>1.202211110800.52-x6937aa5.master</version>
</parent>
<groupId>foo.bar-service</groupId>
<artifactId>bar-service</artifactId>
<packaging>pom</packaging>
<version>3.0-SNAPSHOT</version>
<name>bar-service</name>
<description>Foo Bar - Bar is Foo</description>
<modules>
<module>contract</module>
<module>server</module>
</modules>
<properties>
<mcu.version>${project.version}</mcu.version>
<!-- Project's contract version -->
<mcu.project.contract.version>1.202204111324.39-x6bb54a3.master</mcu.project.contract.version>
</properties>
</project>
Service POM
<?xml version="1.0" encoding="UTF-8"?>
<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>
<parent>
<groupId>foo.bar-service</groupId>
<artifactId>bar-service</artifactId>
<version>3.0-SNAPSHOT</version>
</parent>
<groupId>foo.bar/groupId>
<artifactId>server</artifactId>
<packaging>jar</packaging>
<name>Listing-command Server</name>
<description>Listing-command Server</description>
<properties>
<java.version>17</java.version>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>foo.shared-maven-bom</groupId>
<artifactId>shared-maven-bom-chassis</artifactId>
<version>1.202211160925.72-xa9bdde9.master</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>foo.shared-commons.spring-boot</groupId>
<artifactId>jetty-server</artifactId>
<version>1.202211110857.90-xcb97a1c.master</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
<!-- Starter for Stackdriver Trace -->
</project>
How can I specify either at project or user level that I want plugins to download from the public repository?
Thanks

Not able to add parent tag in pom.xml maven

Not able to add parent tag in pom.xml just like below. It keeps giving me an error saying "Project 'org.springframework.boot:spring-boot:2.3.2.RELEASE' not found
Inspection info: Inspects a Maven model for resolution problems." Could someone help please?
<?xml version="1.0" encoding="UTF-8"?>
<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>org.learning.springboot</groupId>
<artifactId>SpringBootApplication</artifactId>
<version>1.0-SNAPSHOT</version>
<parent>
<artifactId>spring-boot</artifactId>
<groupId>org.springframework.boot</groupId>
<version>2.3.2.RELEASE</version>
</parent>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.2</version>
</dependency>
</dependencies>
</project>
Check first if repository is part of your project:
On maven central, I see:
<!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot</artifactId>
<version>2.3.2.RELEASE</version>
</dependency>
So, as in here, add:
<project>
<!------ others lines -->
<pluginRepositories>
<pluginRepository>
<id>repository.spring.release</id>
<name>Spring GA Repository</name>
<url>https://repo.spring.io/plugins-release/</url>
</pluginRepository>
</pluginRepositories>
</project>
Or, in your case, a repository, as in the same thread:
<repository>
<id>repository.springframework.maven.release</id>
<name>Spring Framework Maven Release Repository</name>
<url>http://maven.springframework.org/milestone/</url>
</repository>

Maven dependencyManagement WARNING on clean project generated from start.spring.io

I'm creating a Spring Boot 1.5.1 project from start.spring.io including the following dependencies: Web, HATEOAS, Stream Kafka, Zookeeper Configuration, Zookeeper Discovery, Actuator. The service itself is a spring-cloud-stream test service.
Without changing anything from the generated code, at mvn package I got the following message. It's just a warning, but since compiling other maven project I'm getting build problems in other projects I'd like to solve it. (I tried to isolate the problem by creating this clean project from start.spring.io).
This is the exact Warning log, and below the generated pom.xml. Notice that the dependencyManagement warning mentions com.netflix.eureka, but in this project no Eureka dependencies have been included.
I also tried to remove all contents from the local maven repository and rebuild, to make sure this is in a consistent state but kept getting the warning.
[INFO] Scanning for projects...
[WARNING]
[WARNING] Some problems were encountered while building the effective model for eu.myapp.services.testsource:test:jar:0.0.1-SNAPSHOT
[WARNING] 'dependencyManagement.dependencies.dependency.exclusions.exclusion.artifactId' for com.netflix.eureka:eureka-core:jar with value '*' does not match a valid id pattern. # org.springframework.cloud:spring-cloud-netflix-dependencies:1.3.0.BUILD-SNAPSHOT, /home/vagrant/.m2/repository/org/springframework/cloud/spring-cloud-netflix-dependencies/1.3.0.BUILD-SNAPSHOT/spring-cloud-netflix-dependencies-1.3.0.BUILD-SNAPSHOT.pom, line 273, column 19
[WARNING]
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[WARNING]
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
[WARNING]
here the pom.xml:
<?xml version="1.0" encoding="UTF-8"?>
<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>eu.myapp.services.testsource</groupId>
<artifactId>test</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>test</name>
<description>Demo project for Spring Boot</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.1.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-zookeeper-config</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-zookeeper-discovery</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-stream-binder-kafka</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-hateoas</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>Dalston.BUILD-SNAPSHOT</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>spring-snapshots</id>
<name>Spring Snapshots</name>
<url>https://repo.spring.io/snapshot</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
<repository>
<id>spring-milestones</id>
<name>Spring Milestones</name>
<url>https://repo.spring.io/milestone</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
</project>
The issue comes from https://github.com/spring-cloud/spring-cloud-netflix/blob/master/spring-cloud-netflix-dependencies/pom.xml#L273-L276
I've opened an issue here. https://github.com/spring-cloud/spring-cloud-netflix/issues/1715
it's very likely that the dependency is being used by another dependency I recommend you first find the issue by doing a search on your dependency tree.
mvn dependency:tree
looks like spring-cloud-starter-zookeeper-discovery might be the culprit
https://cloud.spring.io/spring-cloud-zookeeper/
now it's just a matter of finding what is excluding it. What you do next might get tricky because if you exclude it, zookeeper might now work anymore

Missing artifact when trying to add spring-data

I am trying to add the spring data dependency to my Spring boot starter project but I am getting the error: Missing artifact org.springframework.data:spring-data-jdbc-ext:jar:1.0.0.RELEASE
Here is my pom.xml file. What am I missing here?
<?xml version="1.0" encoding="UTF-8"?>
<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.test</groupId>
<artifactId>myApp</artifactId>
<version>0.0.1-SNAPSHOT</version>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.0.0.RC1</version>
</parent>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.thymeleaf</groupId>
<artifactId>thymeleaf-spring4</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-jdbc-ext</artifactId>
<version>1.0.0.RELEASE</version>
</dependency>
</dependencies>
<properties>
<start-class>com.test.Application</start-class>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>spring-milestone</id>
<url>http://repo.spring.io/libs-milestone</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>spring-milestone</id>
<url>http://repo.spring.io/libs-milestone</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
</project>
For some reason the documentation on the Spring Data JDBC Extensions website is wrong (or the distribution is wrong!).
According to that page you, indeed, need to include the dependency you mention.
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-jdbc-ext</artifactId>
<version>1.0.0.RELEASE</version>
</dependency>
However if you take a look in the spring repository for that artifact it contains a zip file with the release instead of a jar or pom file.
The spring-data-jdbc-ext project consists of 2 artifacts, which both are available. Change your dependency to the following
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-jdbc-core</artifactId>
<version>1.0.0.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-oracle</artifactId>
<version>1.0.0.RELEASE</version>
</dependency>
If you don't need the specific Oracle extensions than you could leave that one out.
A small note there is a 1.1.0.M1 version also (a milestone/pre-release versio) which works with a newer version of Spring Data. You might want to try that instead of the 1.0.0.RELEASE version which was build against an older version of Spring Data.

Cannot read jenkins maven dependencies

I am trying to get this demo application up and running on my machine:
https://github.com/jenkinsci/cli-channel-demo
I have this in my pom:
<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>org.jenkins-ci.demo</groupId>
<artifactId>cli-channel-demo</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>cli-channel-demo</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<repositories>
<repository>
<id>repo.jenkins-ci.org</id>
<url>http://repo.jenkins-ci.org/public/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.jenkins-ci.main</groupId>
<artifactId>cli</artifactId>
<version>1.415</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>1.4</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
But I get this error:
The POM for org.jenkins-ci.main:cli:jar:1.415 is missing, no dependency information available
even though the dependency is located right here:
http://repo.jenkins-ci.org/public/org/jenkins-ci/main/cli/1.415/
and I have this in my pom:
<repositories>
<repository>
<id>repo.jenkins-ci.org</id>
<url>http://repo.jenkins-ci.org/public/</url>
</repository>
</repositories>
Why can't maven resolve this dependency on my local machine?
Worked fine on my machine. I think you need to supply some more details of your error.
Common issues are:
Network proxy denying direct access to internet
Mirror configuration pointing builds at a local Maven repository
See the Maven settings reference for more details on how these issues could be fixed.

Resources