Fork me on GitHub

n. Slang a rough lawless young Kuali developer.
[perhaps variant of Houlihan, Irish surname]
kualiganism n

Blog of an rSmart Java Developer. Full of code examples, solutions, best practices, et al.

Monday, February 27, 2012

Building Applications with the Kuali POMs

Overview

The Kuali Rice team has been investing a lot recently into Maven standardization. That is, bringing projects together more cohesively via Maven. It is not just to have all projects using Maven, but also using the same plugins, licensing, dependencies and so on with Maven. The best solution as of late is one Mother POM. In Maven, it's conveniently named a parent POM. Rice has two right now (Kuali and Kuali Common). Documentation to these can conveniently be found on the Kuali Foundation Wiki.

This post is for projects that are looking to get started really quickly with setting up a project at the Kuali Foundation. While documentation is available on the wiki, I am going through this on my blog as an outsider. Some of this is also pertinent to institutions that wish to implement Kuali Software. While these POM files do simplify things for foundation projects, institutions that use these parent POM files may encounter some caveats.

Scenarios

I Want to Start a New Project. Now What?

Just create your project normally. Make sure your POM has this in it.
<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/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <parent>
    <groupId>org.kuali.pom</groupId>
    <artifactId>kuali-common</artifactId>
    <version>1.0.31</version>
  </parent>
...
...
</project>

You will automatically get all of the Kuali Maven Configuration. This means that all of the nexus configuration comes as well. This includes deployment urls and usernames. No passwords are included in the configuration. Passwords are expected to be setup in a wagon configuration via the settings.xml. Therefore, if your project is not a Kuali Foundation project with that settings.xml setup properly, you will probably encounter a number of errors. For example, see below:

[INFO] ------------------------------------------------------------------------
[INFO] Building kfs 4.1.1-maven-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-jar-plugin:2.3.2:test-jar (test-jar) @ kfs-parent ---
[WARNING] JAR will be empty - no content was marked for inclusion!
[INFO]
[INFO] --- maven-install-plugin:2.3.1:install (default-install) @ kfs-parent ---
[INFO] Installing /Users/leo/projects/git/kfs-maven/kfs-parent/pom.xml to /Users/leo/.m2/repository/org/kuali/kfs/kfs-parent/4.1.1-maven-SNAPSHOT/kfs-parent-4.1.1-maven-SNAPSHOT.pom
[INFO] Installing /Users/leo/projects/git/kfs-maven/kfs-parent/target/kfs-parent-4.1.1-maven-SNAPSHOT-tests.jar to /Users/leo/.m2/repository/org/kuali/kfs/kfs-parent/4.1.1-maven-SNAPSHOT/kfs-parent-4.1.1-maven-SNAPSHOT-tests.jar
[INFO]
[INFO] --- maven-deploy-plugin:2.7:deploy (default-deploy) @ kfs-parent ---
Downloading: s3://maven.kuali.org/snapshot/org/kuali/kfs/kfs-parent/4.1.1-maven-SNAPSHOT/maven-metadata.xml
[WARN] s3://maven.kuali.org/snapshot - Connection refused
[WARNING] Could not transfer metadata org.kuali.kfs:kfs-parent:4.1.1-maven-SNAPSHOT/maven-metadata.xml from/to kuali.snapshot (s3://maven.kuali.org/snapshot): The S3 wagon needs AWS Access Key set as the username and AWS Secret Key set as the password. eg:

my.server
[AWS Access Key ID]
[AWS Secret Access Key]


[INFO] Logged off - maven.kuali.org

Above is the result of a missing or even misconfigured settings.xml. What is missing are the keys for s3-based maven repository. This isn't something you want to fix, this is something you want to configure. Let's consider this is not a Kuali Foundation project, then what needs to occur is the <distributionManagement ... /> section needs to be configured within the POM.xml
<distributionManagement>
    <downloadUrl>${kuali.site.download.url}</downloadUrl>
    <site>
      <id>${kuali.site.server.id}</id>
      <name>Kuali Maven Site</name>
      <url>${kuali.site.publish.url}</url>
    </site>
    <repository>
      <id>${kuali.repo.release.id}</id>
      <name>${kuali.repo.release.name}</name>
      <url>${kuali.repo.release.url}</url>
    </repository>
    <snapshotRepository>
      <id>${kuali.repo.snapshot.id}</id>
      <name>${kuali.repo.snapshot.name}</name>
      <url>${kuali.repo.snapshot.url}</url>
    </snapshotRepository>
  </distributionManagement>
The above properties can be overridden at build time. If you with for your kfs-maven project to deploy somewhere else within your organization so that you may build an overlay from it, then you will want to override these properties. A few other properties I use are:

-Dkuali.cloudfront.phase=none -Dkuali.nexus.sonatype.phase=none -Dkuali.gpg.phase=none -Dkuali.cloudfront.phase=none -Dksite.phase=none


For a list of other properties that can be overridden, please refer to Kuali Community Maven POM Properties

Typically, properties follow the patterns:
  • <artifactId^gt;.version The version property pattern
  • <artifactId>.goal.phase phase property pattern
For more about what these are and what they're used for, see Kuali Community Maven POM Patterns and Conventions

The kfs-public POM

This isn't an official POM yet. I am hoping to get it added to the Kuali Repository soon, but even if it is not added to the Kuali Repository, you can add it to your own local repository. You can find the kfs-public POM here at GitHub. It is pretty much the same as the kuali-common POM, except that it overrides all of the things I was mentioning earlier to make it usable for public consumption. That is, non-Kuali Foundation projects.

No comments:

Post a Comment