maven can't download dependency Illegal character in path - java

The problem I'm facing here is that i can't download a pom from the local artifactory. (the pom is there)
To give a short overview about the projects i'm dealing with:
first of all there are 2 projects
one is the base project and there i declared in the parent pom the version like this:
<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>x.x.x.x</groupId>
<artifactId>x</artifactId>
<version>${global.version}</version>
<packaging>pom</packaging>
...
<properties>
<global.version>x.x.x-SNAPSHOT</global.version>
</properties>
</project>
the other one is declared the same way
now in the second project there is a dependency to the first project and if i want to build it there is an error popping up
Illegal character in path at index 29: URL/artifactory/x/x/x/x/x/x/${global.version}/x-${global.version}.pom
i know it is telling me to eliminate the ${global.version} but is there an other way to fix this up?

I fix it up some how...
The main problem here was the artifactory i think.
Whenever i deployed the maven project 1 to the artifactory there where these relative version instructions ${global.version} still written in the pom.
That's why every time project 2 wants to load the dependency it cant find the path.
So it's back to standard version declaration.

Related

Using custom packaging type as dependency in maven

I have created a custom packaging type in my maven plugin so that I can deploy files in this custom format.
E.g. I have a project that uses this format for packaging. The pom.xml has:
<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.example</groupId>
<artifactId>mylib</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>mybin</packaging>
....
I am able to deploy successfully to a repository. But now I want to use this as a dependency in another project.
E.g. by adding something like this:
<dependency>
<groupId>com.example</groupId>
<artifactId>mylib</artifactId>
<version>1.0-SNAPSHOT</version>
<type>mybin</type>
</dependency>
This is working fine, also except that mybin format includes some nested resources such as jar files) that I would like to include in the classpath.
I so far I've attempted to programmatically extract the jars from inside a mojo and programmatically add it to the project using project.getModel().addDependency(systemJarDep), but this doesn't seem to be picked up by the compiler.
How can this be done in Maven?
It seems that this sort of thing cannot be done in Maven.
I am solving my problem by adjusting the format of my custom package type to be a jar file itself, with all of the classes that I want on the classpath directly inside it. The other sub-resources that I don't require on the classpath (at least by default) are bundled inside the META-INF directory.
This is not ideal, but it is an acceptable solution for now.

How to resolve dependencies on JNLP with Maven

I'm working on a Slick 2D project, with JDK 15, using Eclipse 09-2020, and I am resolving my dependencies via Maven. When I add Slick2D to pom.xml, it shows an error in the IDE at xsi:schemaLocation, saying "Missing artifact javax.jnlp:jnlp-api:jar:5.0"
I've tried re-downloading Java, resetting my JAVA_HOME variable, but to no avail. The other problems that I've come across reference "javaw.jar" in the lib directory, but that is not present in my JDK. How do I solve this?
Here's my pom.xml, if it helps:
<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.newproject</groupId>
<artifactId>newapi</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>Slick Based API</name>
<dependencies>
<dependency>
<groupId>org.slick2d</groupId>
<artifactId>slick2d-core</artifactId>
<version>1.0.2</version>
</dependency>
</dependencies>
Just a general note: The slick project seems dead. The official source repo has been taken offline. I would probably not use it for a completely new project.
But now to your question:
Java Webstart has been removed starting from Java11 since oracle did not opensource it. So what can you do?
You downgrade to Java 9/10
You use https://openwebstart.com (some adaptions might be necessary)
You remove JNLP from the project (since there are other means to start it)
Some other guy seems to have taken up the project. You can find it on github. In one of the forks JNLP has been removed, too.

mvn command for updating version in dependency and one project that uses the dependency

I'm trying to figure out the best practice for updating the version in a POM file that is used by several other Java projects. I'm new to Java and Maven, but not OOP and semver.
I took over a few git repos with Java code using a maven build system. I need to add new features to a "core" repo that is used by several other repos, even though I only need one of the repos to benefit from the new features. My hope is to leave the other repos untouched. If the other repos get redeployed by some devops process, I want them to use the version of "core" without any changes I added to "core".
I think I should update the version in the POM file of the "core" repo before storing its artifact in Nexus so the other repos won't download the version of "core" containing my changes. What mvn command should I use?
Right now, the "core" library declares its version like:
<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.company.team</groupId>
<artifactId>foo-core</artifactId>
<version>1.0.4-SNAPSHOT</version>
<packaging>jar</packaging>
<name>foo-core</name>
<url>http://maven.apache.org</url>
<blah/>
<blah/>
</project>
The projects that use "core" have a POM that looks like:
<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.company.team</groupId>
<artifactId>bar</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<description>Bar</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.2.4.RELEASE</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>
<dependencies>
<dependency>
<groupId>com.company.team</groupId>
<artifactId>foo-core</artifactId>
<version>1.0.4-SNAPSHOT</version>
</dependency>
</dependencies>
</project>
I'm not sure when <parent> is a useful tag, but I notice it is not being used to connect the application repos to the "core" repo.
I imagine I want to update the POM
for the core
and for the one project that uses the core, but not the other projects that also use the core.
I interpret the fact that the version -SNAPSHOT is used in references to "core" by all the other projects to tell me that no "release" was created for the "core", at least at the current version. Can I skip ever making a release for 1.0.4 if I want to the version of "core" container my features to be 1.0.5-SNAPSHOT?
What are the commands I need to execute in both the "core" repo and the repo for the one project I want to use the new build? I think some commands simply modify the POM, but other commands will publish the build to Nexus.
Or can I just type a new number in the POM and run a mvn command to push the build to Nexus with the new version? If I simply change the value with a text editor, I plan to leave the word -SNAPSHOT in the incremented version of "core" as well as the reference to "core" in the one app I want to use the new features. Then I will just need to publish core to Nexus.
--- UPDATE ---
I learned that this command will bump the version number in "core". It seems unnecessarily complex since you still need to type in the full version value when prompted by the CLI (I typed "1.0.5-SNAPSHOT").
mvn versions:set nestSnapshot
And I guess this is how you update the app to use the latest version of the dependency, but I think it only works if you succeeded to publish the dependency with mvn deploy.
mvn versions:use-latest-releases -Dincludes=com.company.team:foo-core -DallowSnapshots=true
You can just go to the two POM files you mentioned and change the version number in the file.
I would first change the version of the core, then run a build mvn clean install (if this done on your local machine) or mvn clean deploy (if you want to sent it to your company repository) and then change the version number of core in the other project.
Note that SNAPSHOT versions are for development. When you want to release something, create a release version, e.g. through the Maven release plugin.

"doubled POM" error when running m2e in eclipse

We recently experience the problem that POMs in the local repository are broken in a special way: The content of the POM appears twice, or, in some cases, just some end part of the POM appears twice. So these POMs look like
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<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">
...
</project>
...
</project>
Obviously, these POMs cannot be read correctly.
One case in which the problem appears often is the following workflow:
Remove the local repository
Start Eclipse with an existing workspace
(Immediately) start a build inside Eclipse.
My guess is that m2e does not properly handle concurrency. The automatic download of dependencies in the background and the build try to download the same POMs at roughly the same time.
Is my analysis correct?
If so, can I do anything about it?
If not, what is the explanation?
EDIT
It seems that the error also occurs if one only starts Eclipse with a lot of projects in the workspace (without starting a in-Eclipse build).

Project Dependency in Maven

I have two different maven projects - let's say ProjectA and ProjectB where ProjectA uses ProjectB.
These projects have seperate pom.xml files. I would like to create a dependancy inside the pom.xml of ProjectA and include ProjectB.
However, everytime I try to run as clean install it always fails and shows the following error.
[WARNING] The POM for database-manager:database-manager:jar:0.0.1-SNAPSHOT is missing, no dependency information available
[ERROR] Failed to execute goal on project cumulus-certificate-generator-attestation: Could not resolve dependencies for project database-manager:database-manager:jar:0.0.1-SNAPSHOT: Could not find artifact cdatabase-manager:cdatabase-manager:jar:0.0.1-SNAPSHOT -> [Help 1]
where database-manager = ProjectB.
My dependency (inside ProjectA pom.xml) looks like this:
<dependency>
<groupId>database-manager</groupId>
<artifactId>database-manager</artifactId>
<version>0.0.1-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
I want to mention that I found a solution by including a "master" pom.xml that will include these two projects but this is not the solution as I have multiple pom.xml files and multiple projects.
If this question has already been answered, can you please point me the solution as I cannot find anything similar to this.
<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>database-manager</groupId>
<artifactId>database-manager</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>database-manager</name>
Thanks!
First: - just read error message more carefully:
cumulus-database-manager:cumulus-database-manager:jar:0.0.1-SNAPSHOT
This is dependency which missed not your database-manager:database-manager
Your projectB database-manager has it.
When dependency missed - it means as #Sridhar said it is not in <your home directory>/.m2/repository folder and as well as it cannot be downloaded from any defined remote repositories.
if cumulus-database-manager is valid dependency
I assume you have to see at the beginning of Maven output, some messages like downlading artifact ... from ...<url> and then cannot be downloaded message.
In this case you will get cumulus-database-manager/cumulus-database-manager direcotry in your locam .m2/repository, but with no jar file in it.
Try to delete cumulus-database-manager directory from .m2/repository and run again to force Maven try to download it again and look at messages why it was not downloaded...
BTW if you need to build at the same time two projects when one depends on another - you have to have "master" pom, with both projects defined in modules element. Otherwise you have to build one after another manually, at least for the first time.

Categories