Using Maven with Sourceforge.net - java

For a new project which uses Maven I would like to add distributionManagement configuration in the pom.xml which will connect the project with the Sourceforge.net file upload system.
I have found this information (of 2007), is it still valid or do you know updated resources?
http://docs.codehaus.org/display/MAVENUSER/MavenAndSourceforge
Related question: How can I deploy artifacts from a Maven build to the SourceForge File Release System?

This looks correct. However, note that it only describes deploying the site artifacts, not the project artifacts (JAR and POM). And while it's possible that you could use maven to deploy your artifacts, I'm not sure that you'd want to -- the Maven directory structure is different from the SourceForge structure (of one directory per release).
If you're looking to deploy your project releases to Maven Central, read this: http://maven.apache.org/guides/mini/guide-central-repository-upload.html
The process has changed in the last year or so. At one time you could request that your project be added to a nightly rsync job, but apparently now you have to deploy directly to a recognized repository. Given the number of times that rsync job would fail, it's no wonder they decided to change the process ...

Related

Quickest POM settings to turn an existing Eclipse web project in a Maven-managed project?

I'm converting an existing Eclipse-based web project to a Maven-managed one.
Since the project has lots of dependencies, many of which are custom (they're either internally made or they've been taken from sources that have no public repository), is there some 'magic' Maven POM setting that will let me load every jar from WebContent/WEB-INF/lib and make the project work as before right now, so that I can configure each dependency and do the necessary refactoring to turn it to a proper Maven project with a little more time and care?
I have already seen this question, but the project must continue to compile inside Eclipse, so - or at least I guess - it is not just a matter of using the Maven war plugin
What you want to do is called "installing" your non-mavenized JARs into your maven repository. This can be a local or remote repo that you host.
The command to install to your local repo is something like this: mvn install:install-file -Dfile=My-lib.jar -DgroupId=com.mycompany -DartifactId=My-lib -Dversion=1.2.3 -Dpackaging=jar
You'll want to review the various options for install to suit your project.
Once the non-mavenized dependencies are installed to your repo you can add them to your pom like any other maven dependency. They will be fetched from your local repo.
You will have to set up your own remote repo (like Artifactory) or install each plugin for every developer and CI server in your environment for others on your team to build the project. I strongly reccomend Artifactory, it makes it easy on your and your team to use maven and get dependencies.

Travis CI not using extra Maven repository provided in pom.xml

I have a Java-based GitHub project, fitnessjiffy-spring (I'm currently focused on the "bootstrap" branch). It depends on a library built from another GitHib project, fitnessjiff-etl. I am trying to configure both of these to be built by Travis CI.
Unfortunately, Travis is not as sophisticated as Jenkins or Hudson in dealing with Maven-based Java projects. Jenkins can easily handle dependencies between projects, but the same concept doesn't seem to exist with Travis. If one project depends on another, then that other project must already be built previously... and its artifact uploaded to some Maven repo where the first project can download it later.
My "fitnessjiffy-etl" library is building and deploying just fine. I'm using Bintray for Maven repository hosting, and you can clearly see my artifacts over plain HTTP at:
http://dl.bintray.com/steve-perkins/maven/
In my "fitnessjiffy-spring" project, I am adding this Maven repo location directly in the pom.xml, so that Travis will be able to find that artifact dependency. Here is the state of my POM at the time of this writing. Note the <repositories> element at the bottom of the file.
When I build this project locally, it works just fine. I can see it downloading the Maven artifact from "http://dl.bintray.com/...". However, when I try to build on Travis CI it fails every time. I can see in the console log that Travis is still trying to download the artifact from Maven Central rather than my specified repo.
Does this make sense to anyone else? Why does Maven utilize a custom repository location in a POM file when building locally, but ignores this configuration when running on a Travis CI build?
From digging into this further, I discovered that Travis uses its own proxy for Maven Central, and has configured Maven to force ALL dependency requests through their proxy. In other words, it does not seem possible at this time to use additional Maven repos specified in the POM file of a project built on Travis.
In my case, I ended up refactoring such that project would not need the outside JAR dependency. I also switched to Drone.io, so I could manage my settings on the build server rather than having to carry a YAML file in my repository (which always struck me as a bit daft).
However, even on Drone it's still a major hassle to manage dependencies between multiple projects (extremely common with Java development). For Java, I just don't think there's currently an adequate substitute for Jenkins or Hudson, maybe running on a cheap Digital Ocean droplet or some other VPS provider instance.
In your install phase add a $HOME/.m2/settings.xml define your custom repository.
cache:
directories:
- "$HOME/.m2"
install:
- curl -o $HOME/.m2/settings.xml
https://raw.githubusercontent.com/trajano/trajano/master/src/site/resources/settings.xml
- mvn dependency:go-offline
script:
- mvn clean install site

Jenkins CI Job Workspace custom changes

I have setup a CI environment for deploying to dev using Jenkins/Maven/SVN. For the deployment to Jboss Eap server, I am using JBoss as maven plugin. Since the project teams does not have the plugin for this the jboss-as:deploy in the respective poms, once I create the job in Jenkins and a local workspace gets created for the project, I manually update the pom.xml with the plugin and the server configuration. Is there any way to automate this process? I dont have the option to ask all project teams to commit the plugin in the pom file. Issues i am facing.
Project teams commit a change at the same line number where I added the jboss as dependency in the pom, caused a svn merge conflict in my Jenkins local workspace and the build fails since pom is corrupted.
For every job, I have to manually update the POM in the Jenkins workspace.
If I have to deploy a project to multiple app servers, I have to create multiple jobs.
Can anyone suggest a solution.
I would create another distribution-component and keep it separately, e.g. as a component or module. I would update inside its pom.xml the change you mentioned and just support two projects - the developers' one and the one used for other purposes.

use of Maven for Java web development

I am new to java web development and the book I am using to learn uses Maven and Tomcat for development. After searching some basics about Maven on internet all I know is that it is a tool for managing dependencies in project. I am using Netbeans 8 and every time I create a new project or clean-build an existing project Maven downloads lots of files. Is there any way I can keep a common place/repository for all my Maven projects which can be used locally? I have gone through some existing answers on stackoverflow but for me as a beginner they are difficult to understand.
Maven indeed has such a local repository (in .m2/repository in your home folder) where the files found to be needed are downloaded are automatically stored for future use.
The source repository - Maven Central - is very large, so you do not want to download everything as you will most likely not need most of it.
If you need to go offline, or want to be sure that everything you may need in your current build, you can run the dependency:go-offline target. You can then safely use the -o switch to maven to avoid network usage.
When you create a Maven project and build it for the first time, Maven will automatically create a local repository for you, downloading the necessary jars for your project to this location. From then on, all your maven projects will share this repository.
On Windows, the default location for your local Maven repository is
%HOMEPATH%\ .m2\repository
You will find this page useful: http://maven.apache.org/guides/mini/guide-configuring-maven.html
You can also download 'Maven the complete reference' for free as a PDF from here: http://www.sonatype.com/resources/books/maven-the-complete-reference/download

Resolve/Download dependencies after deployment to remote server

I have a big war file over-sized due to lots of external dependencies & also I have internet connection speed issues because of which I don't want to keep the dependency jars in my war, so that I could reduce war size & do faster uploads of my updated wars from dev machine to remote server.
I would like the maven project to instead download the dependencies on the remote tomcat server itself when it has been uploaded there & starts running. How do I configure maven to do that ?
There is a pretty simple solution: Build the project on the server.
An easy way to do this is to put all the sources into a version control system like Mercurial or Git.
In addition to giving you a history and an automated backup, DVCS have insanely efficient algorithms to update remote copies (they just transfer the changes, so if you change a single line, only one line is sent over the wire).
Building on your server also means that you get the very fast download of dependencies on the server (which has probably very good download rates). And local deployment will be very, very fast.
Last but not least: When you use version control, you will be able to go back to the last stable version quickly when something goes wrong.
As Aarom says you should build the project on the server directly.
There are two requirements:
You need to have a command line access on the remote server.
Maven must be installed on the remote server.
Then you can upload the sources of your project on the remote server (without dependencies).
Go in the root directory of your project and run your build command (mvn package or whatever custom build command that you use).
So that's it, you have the .war on the remote server loaded with all the dependencies; you can then remove the source files.
#user01
Install all desired 3rd-party jars to Tomcat's lib folder.
Set the scope of those dependencies to "provided" in you Maven pom.xml.
Install Maven on your remote server.
Install a CI server such as Jenkins, Continuum, Bamboo, Hudson, CruiseControl, etc. I'd suggest Jenkins.
Hopefully, you are using revision control software such as SVN, Git, Mercurial, Bazaar, or CVS. If not, then I'd suggest setting up
Git or SVN for your source code repository.
Configure the scm tag in your pom.xml to point to your project's location within your source code repository.
Configure your CI server to get your pom.xml from your source code repository. Your CI server will read the scm tag, and the
URL's you've configured within the scm tag, and will check your
project out. Your CI server will then build your project.
You can either have Jenkins deploy your built war artifact to Tomcat via the Jenkins Deploy Plugin, or you can use a Maven plugin such as the
tomcat7-maven-plugin or Cargo.

Categories

Resources