Using the maven versions plugin I update the version numbers of the pom files :
versions:set -DnewVersion=1.0.2-SNAPSHOT
I then check in the pom files manually prior to performing a build. I don't think the versions plugin can check in files automatically? The maven releases plugin seems to offer functionalty for checking in files using the 'prepare' goal.
No turns out its only poor mans SCM (stores a backup with the changes you make to the pom and allows you to revert to it).
Use the release plugin.
Related
I would like to use the jgitver maven plugin to automatic define the version of eclipse plugins, features, repository that are built with tycho in pomless mode.
The version management of this 3 plugins are:
jgitver computes a version depending on git tree and tags, create a logical copy of pom, set the new version and associate the new pom to the current plugin in the maven reactor.
For tycho, version are defined in pom and in manifest.mf or feature.xml files. A version consistency check is performed.
When the pom is not defined, pomless maven generates a temporary pom file named .polyglot.build.properties using versions defined in manifest or feature file.
The input path are defined here and depends on PolyglotModelUtil.
The easier way would be a Jgitver evolution to locally update the feature.xml and manifest.MF. It would be a bad idea because a local file would be modified that is not compliant with the plugin philosophy.
A better way would be a Jgitver evolution to generate temporary feature.xml and manifest.MF files that would have been updated with the computed version. Then tycho and tycho-pomless should be forced to use them.
It seems to be possible if i succeed in setting a new ModelProcessor.LOCATION option
Do you think it's an effective way to solve this compatibility problem?
Do you see an alternative?
Thanks for your help.
You could also use directly the jgitver library to participate into your build environment ; it is a pure java library.
The library is the base of both the maven and gradle plugins.
I stumbled over compatibility issues related to the dependency plugin and gradle-3.0M1. Quickly, people told me this might be fixed in the trunk version of the plugin, but not in the latest release version 0.5.7.
Now I wanted to verify this but didn't find an easy way to use the snapshot version of the plugin. In the end, I
downloaded the plugin source by cloning the git repo
rebuilt the plugin
copied the jar file into a folder
made this folder available as flatDir within my build script
Is there a better way to do this? Is there a public mvn repo for the snapshots?
Publish the plugin to your local maven repo (.m2) using either the older maven plugin or the newer maven-publish plugin.
In the project where you want to use/test the plugin you just build, add mavenLocal() as a repository in the buildscript section of build.gradle.
Is there an equivalent to a mvn
"deploy:promote"
goal, which will take an artifact from one repository and copy it to another ?
I call this "promote" because the typical use case would be promotion of a snapshot to a release.
I know that proprietary tools exist with UI's for doing this sort of thing.... But I'm assuming that the deploy plugin would handle it as well.
You cannot promote a snapshot to a release.
An snapshot has a version like 1-SNAPSHOT(.complextimestamp)
That version number is in your pom. It's in the metadata in META-INF in your jar or war file. So you can't just copy the artifact and declare that it has a different version.
You must rebuild with the release version and deploy that. The maven-release-plugin and the jgitflow-maven-plugin both automate this process.
Whenever I want to create a new version of my projects, I have to go in and edit the <version> tag in the POM files.
The projects are related, so they have the same version, most of the time.
Is it possible to just put the new version in some file, and have the POM regenerated when needed?
Thanks
The best thing in such situations is to use the release plugin which supports automatically changing the version in the pom and creating a tag/label in the appropriate VCS. There are two steps release:prepare and release:perform which can simply be combined.
A command like this:
mvn release:prepare release:prepare
will do all needed steps like making a tag in VCS, change pom's version and deploy the artifacts to your repository. But the prerequesite is having correct entries in the SCM area of your pom, correctly configured the distributionManagement etc.
If the project comprises of several modules which have the same version this sounds like using a multi-module build instead of separated projects which would solve the problem of changing the version manually.
I have a Maven 2 multi-module project and want to be sure everything is taken from my local checked-out source.
Is it possible to tell Maven to never download anything for the modules it has the source of? Do I have to disable the remote repositories?
Does Maven always have to go the expensive way of installing a module into the local repository, and then extracting it again for each of its dependents?
Does Maven automatically first recompile dependencies for a module if their local source changed, and then compile the dependent?
Is it possible to tell Maven to never download anything for the modules it has the source of?
No. Maven 2 only "sees" the current module while it builds. On the plus side, you can build part of the tree by running Maven in a module.
Do I have to disable the remote repositories?
Yes, use the "offline" option -o or -offline. Or use settings.xml with a proxy that doesn't have any files. This isn't what you want, though.
Does Maven always have to go the expensive way of installing a module into the local repository, and then extracting it again for each of its dependents?
Yes but it's not expensive. During the build, the file is copied (that was expensive ten years ago). When a dependency is used, Maven just adds the path to the file to the Java process. So the file isn't copied or modified again. Maven assumes that files in the local repository don't change (or only change once when a download/install happens).
Does Maven automatically first recompile dependencies for a module if their local source changed?
No. There were plans for Maven 3 but I can't find an option to enable something like that.
To solve your issues, you should install a local proxy (like Nexus).
Maven download stuffs (dependencies) only if it's not available in your local reposiotory ($USER_HOME/.m2/repository). If you do not want anything to be downloaded use offline mode. This can be done by using -o switch. E.g.
mvn -o clean install
There is nothing expensive in it. If you are building the complete parent project, it will build all the modules and then copy the artifacts to your local repository. Then, when you build a project that has dependencies on those project, Maven will just copy them from local repository on your hard disk to the package that is going to be created for current project.
No. I have been burnt. Maven does not compile dependencies automatically. There is a plugin called Maven Reactor Plug-in. This plugin enables you to build a project's dependencies before the project is built.