Open Source & Free  

Building Codename One From Source – Maven Edition

Building Codename One From Source – Maven Edition

Learn how to build Codename One from source and use this "local" version in your Codename One projects.

Jump To Topic

Tip

This post is targeted at experienced Codename One users. If you haven’t built an app with Codename One before, I recommend you start with this Getting Started tutorial (for Java) or this tutorial (for Kotlin).

One of the benefits of moving to Maven is improved project hygiene. It is now trivial to build Codename One from source.

In this video, I show you how to build Codename One from source and use this “local” version in your Codename One projects.

TLDW (Too Long Didn’t Watch)

Here’s the gist of what happens in the video.

1. Clone the Codename One repository, then run mvn install in the maven subdirectory:
				
					git clone https://github.com/codenameone/CodenameOne
cd CodenameOne/maven
mvn install
				
			

This will take a few minutes, but at the end of the tunnel you should see “SUCCESS” as shown below:

mvn-install-success
2. Clone the cn1-maven-archetypes repository, then run mvn install in its root directory:
				
					git clone https://github.com/shannah/cn1-maven-archetypes
cd cn1-maven-archetypes
mvn install
				
			

This will take another minute or so, but at the end of the tunnel you should see “SUCCESS”:

mvn-install-archetypes-success
After completing these steps, Codename One will be installed in the local maven repository. A key point I make in this video is the version number of the sources that I checked out of Github. If you are cloning the project from the master branch, then the version will usually be a SNAPSHOT version. E.g. 7.0.21-SNAPSHOT. This is a Maven convention. Release versions will not have the -SNAPSHOT suffix.

In the video, you can see that the version number is “7.0.21-SNAPSHOT”.

Using the Local Version in Your Application Project

Now that Codename One is installed in your local Maven repo, you can use that version in your application instead of the release version.

I demonstrate this in the video by creating a new project with the Codename One initializr.

cn1-intializr

Tip

Check out my Video tutorial on Codename One initializr if you haven’t seen it yet.

After downloading and extracting the project, I open its pom.xml file and and look for the <cn1.version> and <cn1.plugin.version> properties:
cn1-version-properties

I then change these to point to the version that I installed into my local maven repository: 7.0.21-SNAPSHOT.

cn1-version-updated

Why Build From Source?

Because you can, and because it is the first step toward taking control of your own destiny. It gives you early access to features that may not be available on Maven Central, and it also enables you to make your own changes, and potentially contribute them to the Codename One core.

Getting Started

If you haven’t built an app yet, it’s easy to get started. Just go to Codename One initializr and press “Download”. You could be up and running in only a few minutes.

 

If you want to dig deeper into Codename One’s Maven support, check out the Codename One Maven Developers Guide.

2 Comments

  • Dave Dyer says:

    something is out of date. in codenameone\maven, mvn install

    [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.0:compile (default-compile) on project
    java-runtime: Compilation failure: Compilation failure:
    [ERROR] Source option 5 is no longer supported. Use 7 or later.
    [ERROR] Target option 5 is no longer supported. Use 7 or later.

Leave a Reply