I have a new app, the pom for which has parent tags and all. I have to include in this app another dependency whose parent is different than the current apps parent. The problem is the version tag for the new dependency.
The current pom :
<?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">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>abc-pom</artifactId>
<groupId>com.abc</groupId>
<version>4.480.0-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<groupId>com.abc.libs</groupId>
<artifactId>dynamixSession</artifactId>
<packaging>jar</packaging>
<name>dynamixSession</name>
.....
.....
<dependency>
<groupId>com.pqr.someOtherProject</groupId>
<artifactId>SomeCoreProcessing</artifactId>
<version>4.2.14.2-SNAPSHOT</version>
<!-- <version>${project.version}</version>-->
<scope>provided</scope>
</dependency>
This pom works. Since I am hardcoding version number here, do I need to update this pom everytime the version changes ? Or will it be updated automatically. But I doubt that it updates automatically.
I would like to use '${project.version}' so that I don't have to update it. But if I use '${project.version}' it tries to look for 'com.pqr.someOtherProject.SomeCoreProcessing:4.480.0-SNAPSHOT', which is not existing.
Is there a way arround this or am I stuck with harcoding the version in my pom ?
Thanks
You can use versions plugin to achieve that. It would be the easiest way. The plugins is especially used for these kind of requirements.
But it would not be automatically updated. You would need to execute versions:use-latest-snapshots goal.
If you are using a continuous integration tool (e.g. Jenkins) you can automate this with nightly builds or some other way.
Just have a look at below link to see all the details of versions plugin. It is nicely documented.
http://mojo.codehaus.org/versions-maven-plugin/
Why don't you try {env.SomeCoreProcessing_version} instead? Just make sure you set/export the SomeCoreProcessing_version variable before kick starting your build.
Related
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.
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.
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.
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).
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.