I am trying to implement a maven release build on a specific cvs tag. Here is my workflow I'm trying to implement:
Jenkins builds a project every night.
Jenkins deploys the WAR on a internal testserver.
After some time I tag an specific tested nightly build in CVS.
Now I will run a maven release build on that specific tag to make sure that only tested changes are in this release and newer changes are irgnored.
The maven release plugin tags this version and deploys the WAR to an artifactory.
Is it somehow possible to make a maven release on a specific CVS tag/branch? Currently I am able to build specific tags/branches with jenkins and also execute a maven release build on this tag/branch. But when I check the tag of the release version it also contains newer changes which makes it unpossible to create hotfixes for this version or just checkout the correct source for a certain version. Another big problem is that the resulting artifact also contains all changes from the HEAD and not only from the selected tag/branch.
I hope you can help me!
You can specify the name of the tag in the CVS settings
Related
I am trying to use maven to build a JNI project and I am running into some difficulty creating a GA release. The project's native code needs to be compiled on at least 3 systems (Linux, OSX, Windows) due to the native code requirements. I would also like GitHub Actions to produce a release build when I create a tag on GitHub. Because of this, I am facing a number of issues with the maven release plugin. It seems like maven's release process involves compiling and testing the code as well as screwing around with SCM before I can create a GA version and release. This simply isn't possible for this JNI project. I have already gone down the cross compiler route with Ant and I would really like to move away from that for any number of reasons, mostly Apple related. I also thought about releasing each JNI target individually, but I would really like to bundle the native code inside of the JAR and things start getting complicated when I need to share a .m2 folder across different build environments. Is it possible to release a maven project without all the compiling, testing and SCM nonsense? Maybe a different 3rd party plugin? Is there a better way I should be doing this? For reference, the pom can be found here.
Dont use the release plugin, I had a lot more success with the maven version plugin.
All the maven release plugin is doing is taking the version off the snapshot, creating a new commit and then upping the version to a new incremented SNAPSHOT. You can mimic this process without maven needing to know anything about your SCM using versions.
One way to do it is to not SNAPSHOTS and instead build with the git short hash as part of the version:
So while developing, the version looks pretty normal
<groupId>org.example</groupId>
<artifactId>my-app</artifactId>
<version>1.1.0</version>
The do a "release" build based on a tag. My flow was
commit and push
build - mvn clean install, results in my-app-1.1.0.jar
deploy to a test env and run regression tests, if they succeed, we tag the commit with a "passed_tests" tag
CI fires on tags that match "passed_tests" - this needed to be the same commit that resulted in the jar under test
runs mvn -f ./pom.xml versions:set -DnewVersion=${gitProps['git.build.version']}_${gitProps['git.commit.id.abbrev']}
On the disk, our maven version is now:
<groupId>org.example</groupId>
<artifactId>my-app</artifactId>
<version>1.1.0-abcdef</version>
then runs mvn deploy. This is the artifact that gets deployed to the repo and now we have a jar file (or whatever) that has a version matching the git commit.
You could use the same process for all your target architectures.
What is the exact dependency I need to develop a Gradle Plugin in Java? Ideally I would like to get it from a well-known repository such as Maven Central or similar.
I have a Maven project with a core functionality and I just added two extra plugins, one for Ant, one for Maven. They are already tested and working; easy! Now, I wanted to add a third module for a Gradle plugin to make this functionality also available from any Gradle project.
However, I can't find the exact dependencies I need to develop a Gradle plugin.
The Gradle docs (such as https://docs.gradle.org/current/userguide/java_gradle_plugin.html) are not very well written to say the least. They mention:
the gradleAPI() dependency
or the java-gradle-plugin dependency
But they are quite unclear... no group, no version (really?).
If anyone can enlighten me to where I can get these dependencies from, I would be very thankful.
Gradle's public and internal APIs, aka gradleApi(), are bundled with the Gradle distribution and not independently published and therefore not easily consumable by Maven builds. There's the pending epic #1156 (Ensure plugin cross-version compatibility by allowing a user to depend on gradlePublicApi()) that might help here.
Since Gradle plugins are best to be built with Gradle, a pragmatic solution is to invoke the Gradle build from Maven and attach the produced artifact to the Maven build. Andres Almiray (aalmiray) once described this in the blog post Running Gradle Inside Maven (Web Archive Link). He describes the following high level steps:
Create a new Maven module (e.g. gradle-plugin) and add attach it to the parent POM
In the POM of gradle-plugin add a dependency to your core module. Use the maven-dependency-plugin to store dependencies to the Maven build folder, e.g. target/dependencies.
Create the build.gradle, add a Maven repository that points to target/dependencies (step 2) and let it depend on the core module as well as gradleApi(). Implement the Gradle plugin.
Use the exec-maven-plugin to invoke the Gradle build.
Use the maven-resources-plugin to copy the Gradle built plugin jars to the standard Maven build folder.
Use the build-helper-maven-plugin to attach the copied jars to the Maven build.
Sample project to be found here (gradle-in-maven).
https://docs.gradle.org/current/userguide/custom_plugins.html#sec:custom_plugins_standalone_project
In here it is mentioned that it is gradleApi() and I know that this works (from experience). The localGroovy() on that page is only needed if your plugin code uses groovy (does not apply if you only use groovy in the build.gradle of your plugin).
java-gradle-plugin is a library that makes it a bit simpler to make plugins, it is not required though. I personally prefer using gradleApi only.
EDIT:
It appears I've misunderstood the question. Here are the steps to get gradleApi jar:
Create a Gradle project with your desired Gradle version.
Add implementation gradleApi() dependency.
Import/run the project once.
Go to your .gradle folder (located in home folder in Linux-based operating systems).
Open caches folder
Open the version folder you want, e.g. 6.0.1
Open generated-gradle-jars folder.
Copy the jar to wherever you want and use it.
For me the 6.0.1 jar is at ~/.gradle/caches/6.0.1/generated-gradle-jars/gradle-api-6.0.1.jar
Please note that I have not tested this, I know the jar is there but I haven't tried using it.
I have several libraries which I've manually deployed to my Nexus repository using:
mvn deploy:deploy-file -Durl=[url] -DrepositoryId=[repoId] -Dfile=[filePath] -DgroupId=[gId] -DartifactId=[aid] -Dversion=[v] -Dpackaging=jar
I did this because they are legacy jars and quite a large amount of them for which I've automated the process.
The problem I'm having is in packaging a WAR. The dependencies come down just fine, but when the war is generated they have the version+timestamp appended to the end. I have several other projects where this doesn't appear to be the scenario - i.e., after multiple packagings and deployments to a given server the lib directory [for the project] contains:
[jar].[<version>-timestamp1].jar
[jar].[<version>-timestamp2].jar
[jar].[<version>-timestamp3].jar
[jar].[<version>-SNAPSHOT].jar <== this entry alone would be ideal
Also, I'm not using any specific plugins just invoking:
clean package
Is it possible to eliminate the timestamp when packaging the war?
You may need to ask yourself why you need to eliminate the timestamp.
If you just want to download the latest SNAPSHOT version, Nexus provides REST API to download latest SNAPSHOT artifact just directly using your snapshot version as version parameter, such as 1.0-SNAPSHOT. e.g.
http://<your-nexus>/service/local/artifact/maven/redirect?r=<your-repo>&g=<the-group>&a=<the-id>&v=1.0-SNAPSHOT
From the API doc, the version parameter can support LATEST, RELEASE and SNAPSHOT versions.
Version of the artifact (Required) Supports resolving of "LATEST", "RELEASE" and snapshot versions ("1.0-SNAPSHOT") too.
Furthermore, with timestamp each SNAPSHOT build has it's unique version, which gives you the chance to download a specified SNAPSHOT build such as v=1.0-20140822.145007-2.
If you want to limit the number of snapshots, you can take a look this one: How to limit number of deployed snapshots artifacts in Nexus?
It is known that whenever a search is done through the Maven repository, one can find dependencies for different versions of a package (e.g. BoneCP Maven Search) depending on the Development Stage.
I would like to know, for any external dependency found in the Maven repository, which version should be included in a final deployment of a project. For instance:
Always the latest RELEASE/RC (Release Candidate)?
Always the latest version even if its an alpha/beta/SNAPSHOT version?
Thanks in advance.
For a release you generally create a tag from stable snapshot version [trunk] and then deploy it to repository.
Generally the highest tag version for the each release is taken for code release and deployment.
Also want to add snapshot version is meant for development and not for release.
I am having a java project with a ant build file, using this ant file i create an ejb of the project and deploy it on the jboss server.
Now I am planning to use maven and convert this existing project which consist of nearly 28-30 jar's in its class path(jars related to ejb3, hibernate, jboss, etc).
I can easily do it using eclipse i.e right click project goto maven and click Conver to Maven.
A pom.xml is generated and the MavenClassPath Container is also added to the project.
Now I want to know how to get rid of those 28-30 jar's present in the lib folder of the project and in the classpath. i.e. I want my pom.xml handle all the dependencies.
Does Maven provide any mechanism to achieve this goal while converting the project or I have to add all of these jar dependencies one by one manually in the pom.xml file.
The intention of doing this is I want to have common maven remote repository where the jars will be stored and each developer machine will point to it through their maven project.
Thanks
I think you're after a repository manager like Nexus (I use Nexus, it seems to be the most popular http://nexus.sonatype.org/ ).
Nexus can be used as:
A proxy repository (for Maven Central, etc)
A repository for your own releases.
Nexus provides user management for your developers to release builds into the repo.
Developers will then point their Maven settings.xml file to your Nexus repository, and all their dependencies will come from here (Nexus will cache them).
I'm afraid you will have to configure the dependencies individually, but that is a good thing, because you should pay attention to what version ranges you are interested in for each dependency.
Any jars which can't be found in Maven Central, etc, you can add to your own Nexus repository .
Ofcourse there are alternatives to Nexus, but I haven't used any.
HTH
The most important thing i can recommend is to use a Maven Repository Manager (Nexus, Artifactory or Achiva or other..).
Second your pom conversion via Eclipse shows me that you are not using an up-to-date Eclipse nor an up-to-date Maven Plugin for Eclipse. The best thing would be use Eclipse-Indigo (m2e is the newest and greatest).
Furthermore you have to go through all your jar's and add them step by step to you pom (dependencies) and see if your project can be compiled. This should be checked on command line not inside Eclipse.
After you got a working pom.xml file put it into your version control and check if you can remove some of your added dependencies based on transitive dependencies. After that you can finally delete your lib folder.