A pattern for WebStart in Maven

Java WebStart and JNLP can be finicky beasts, especially when paired with Maven-generated websites and artifact repositories. Over the last few months I’ve developed POM and JNLP template patterns that I think are useful when used with the webstart-maven-plugin:jnlp goal; the main advantage is that applications can be WebStarted directly from the repository, which means that the version available is always the latest -SNAPSHOT or release.

In the POM I define two variables, site.baseUrl and artifactUrl. site.baseUrl defines the server and root path where all Maven-generated websites are published; it has a prefix because usually I’d only set it once in the corporate POM. artifactUrl is the full URL of the project-specific website.

By default both site.baseUrl and artifactUrl point to the location where -SNAPSHOT sites are published, usually by a CI system. They’re overridden in two profiles: release switches site.baseUrl to the release website (which is applied to artifactUrl, so there’s no need to set it again), and devel sets artifactUrl to the local target directory (and omits site.baseUrl, which ends up unused).

<project>
...
  <properties>
    <site.baseUrl>http://repository/snapshot-site/</site.baseUrl>
    <artifactUrl>${site.baseUrl}/${project.artifactId}</artifactUrl>
  </properties>
...
  <profiles>
    <profile>
      <id>release</id>
      <properties>
        <site.baseUrl>http://repository/release-site/</site.baseUrl>
      </properties>
      <distributionManagement>
        <site>
          <id>release-site</id>
          <url>dav:${artifactUrl}</url>
        </site>
      </distributionManagement>
    </profile>
    <profile>
      <id>devel</id>
      <properties>
        <artifactUrl>file://${project.build.directory}</artifactUrl>
      </properties>
    </profile>
  </profiles>
...
</project>

In the JNLP template, the codebase is set to artifactUrl, which means that the resulting JNLP will retrieve any artifact dependencies from the snapshot, release or local output directories.

<jnlp
  spec="$jnlpspec"
  codebase="${artifactUrl}/jnlp/"
  version="$project.Version"
>
...
</jnlp>

Note that the artifact dependencies still need to be copied into the jnlp directory, which webstart-maven-plugin:jnlp does by default. It would be nice to be able to get them from their canonical locations on the repository, but that’s not easily accomplished.

Kool-Aid, drinking the

At work, I’ve finally had a chance to apply some of the practices I’ve been reading about (and advocating) for months. Foremost among them are the related concepts of test-driven development, (proper) unit testing, dependency injection and the principle of least knowledge (aka the Law of Demeter).

And what do you know: they actually work!

I’ve also wound up doing quite a bit of refactoring—mostly, as someone (maybe Michael Feathers?) put it, of “new legacy” code, stuff that’s been written in the last few months (not by me) which is full of global state and complex un-mockable setup. Most of that has been scattershot/mercenary work to make life easier for myself, rather than a concerted effort to rebuild the foundations without tearing down the walls, but I think I’ve made some incremental improvements that will help in the long run.

Now I just have to get the rest of the source control/build monkeys off my back. A few months ago I’d almost divested myself of one, through no small or short-lived effort, but just when I thought I was out….

Coin

Obverse:

It has been Hollywood gospel for decades that advertising and marketing can help a film to open strongly, but moviegoers talking with each other are crucial to its continuing success. [… Younger moviegoers] resist a choice that is not in step with their peer group. Having joined the crowd at Transformers, they’re making their plans to see G. I. Joe. Some may have heard about The Hurt Locker, but simply lack the nerve to suggest a movie choice that involves a departure from groupthink.

If I mention the cliché “the dumbing-down of America,” it’s only because there’s no way around it. And this dumbing-down seems more pronounced among younger Americans. It has nothing to do with higher educational or income levels. It proceeds from a lack of curiosity[…] This trend coincides with the growing effectiveness of advertising and marketing campaigns to impose box office success on heavily-promoted [CGI] blockbusters, which are themselves often promotions for video games. No checks and balances prevail. The mass media is the bitch of marketing.

Reverse:

Craig Ferguson, July 21, 2009

We got it all on…

The movie “UHF” was released to an unsuspecting public exactly 20 years ago today. #UHF

It sure was. Twenty years ago my friend Bob picked me up on the road in front of my parents’ house—we were in such a hurry, he pulled away before I was fully in the car, which caused me to rip the sole of my shoe as it dragged along the rough asphalt—and tore into London to the Huron Market Place theatre to see a double bill of The Karate Kid, Part III and Al’s magnum opus. (KK3 left so little of an impression in my mind that I had to look up releases from the summer of ’89 to figure out what else was on.) From the shot of the mountain at the beginning to Spatula City to “Supplies!” to “I knew she was gonna say that” I could hardly stop laughing.

Think I’m going to go put in the DVD. Don’t wait up!

It’s not elitism if you’re actually one of the elite

While reading I’m a proud Brainiac, Roger Ebert’s non-apology to those who call him “elitist” for not liking Transformers 2, I was reminded of one of my favourite moments from this year’s Fringe festival. It was during The NO Show, a nightly “talk show” put on by local sketch comedy group Fully Insured and hosted by scriptoris fecundus palmaris Jayson McDonald. The show is traditionally heavily comedy-oriented, including the interviews, just like the televised versions it springs from, and it’s really funny, due in large part to Jayson’s own ability to quickly riff on what his guest has just said.

What impressed me, though, was his interview with the cast and director of Never Swim Alone (Eva Blahut, Meaghan Chenosky, Tyler Parr and Justin Peter Quesnelle). Rather than play the interview for laughs, Jayson and his guests took the time to have an honest, insightful discussion about the show and their craft. It was a few minutes that demonstrated the intelligence of, and mutual respect between, the five people on stage.

Gene Siskel, Ebert’s partner on At the Movies until his death, said “I always ask myself: ‘Is the movie that I am watching as interesting as a documentary of the same actors having lunch together?'” Having now witnessed Eva, Jayson, Justin, Meaghan and Tyler “having lunch”, they’ve set a high bar for themselves and their companies (Passionfool and Stars and Hearts); but knowing the consistently high quality and passion each brings to her/his work, it’s one they’re all easily capable of leaping with room to spare.