Over a million developers have joined DZone.

Mavenization of NetBeans Platform projects (7.x releases)

· Java Zone

Learn more about the advantages of moving from a monolithic to microservices architecture.  Brought to you in partnership with IBM.

Currently I’m testing some bugs in the NetBeans development build (localisation bugs). But for some issues it’s not enough to have the platform sources and a build. To test maven-driven platform apps, I need all updated artifacts in my local repository.

This tutorial is updated from an old tutorial by Chas Emerick. You can find his version here. I’ve copied anything and changed the steps to the current versions.

  1. Pull the NetBeans Platform sources from the associated hg repo (I used the development repo). It appears that populating your repo with NB RCP artifacts from a binary download is possible, but then you’ll not have the associated javadoc, source artifacts, etc. (see https://netbeans.org/community/sources/hg.html)
    1. First time
      1. hg clone http://hg.netbeans.org/main-silver
    2. Update
      1. hg pull
      2. hg update
  2. Build the entire project – It’s possible to restrict the build to certain clusters, but I don’t see any reason to optimize this process since doing so only saves a little bit of disk (and time).
    1. You must set your JAVA_HOME environment variable and should point to a Oracle JDK, especially in linux environments that often come with non-Oracle JDKs. Not doing this can result in very strange compilation errors.
    2. You must set your ANT_HOME environment variable (please use a version equal or higher than 1.9)
    3. You must set your ANT_OPTS environment variable to specify a higher-than-default maximum heap (export ANT_OPTS=-Xmx1024m worked for me).
      1. Best results with:
        1. -Xmx1024m
    4. Within the top-level of your NetBeans Platform source checkout, run
      1. ant
      2. ant build-nbms
      3. ant build-source-zips
      4. ant build-javadoc
        This will build everything you care about in order to populate your maven repo.
  3. You want to have the NBMs in your repository to have appropriate dependency relationships established with third-party artifacts, right?
    1. Downloading via nb-repository-plugin
      1. mvn org.codehaus.mojo:nb-repository-plugin:1.1:download
    2. or achieving this is easy if you have nexus
      1. unzip sonatype-work/nexus/storage/central/.index/nexus-maven-repository-index.zip somewhere (I used /tmp/nexus-index).
    3. Or use the NetBeans cache folder (the content is unzipped!)
      1. Under Windows: e.g.
    4. set the nexusIndexDirectory property in the last step to that the path where you unzipped central’s index; the nbm-maven-plugin will search that Lucene index to find dependencies referred to within the Platform’s NBMs
  4. set MAVEN_OPTS to specify a higher-than-default maximum heap
    1. MAVEN_OPTS=-Xmx512m
      I’m not sure why this would be required, but I got OutOfMemoryErrors with max heap set to anything less than 512MB. Perhaps searching the maven central repo index is what pushed allocation so high.
  5. Make sure you don’t have a pom.xml in your current directory. Bad things will happen.
  6. Decide on a version number for the deployed artifacts, and use it as the value of theforcedVersion property. I used RELEASE731-patched to go along with the pattern established at http://bits.netbeans.org/maven2
  7. Assuming you’re deploying to a (nexus) release repository, make absolutely sure that you’ve (temporarily) enabled redeployment for that repository! nbm-maven-plugin deploys some NBMs multiple times (presumably while traversing various dependency graphs), and not enabling redeployment will result in errors (400 errors from Nexus, specifically – I can’t say what might happen with different repository managers).
  8. Now for the big finish (please set the correct index-folder from step 3):
    1. Deploying to a repository (e.g. nexus)
      1. mvn org.codehaus.mojo:nb-repository-plugin:1.1:populate
    2. or deploying local for tests
      1. mvn org.codehaus.mojo:nb-repository-plugin:1.1:populate

All this steps together needs two or more hours, depending on your machine and finished old builds.

From Idea to Application gives you the architecture to quickly build, manage and run a range of applications (web, mobile, big data, new smart devices, etc.) on an open-standard, cloud-based platform. See why developers are using IBM Bluemix. Brought to you in partnership with IBM.


The best of DZone straight to your inbox.

Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}