From Fedora Project Wiki

< SIGs‎ | bigdata‎ | packaging

(saving work; initial revision)
 
(added macros)
Line 4: Line 4:


This is a quick guide to getting Fedora packages built with <code>sbt</code>.  Since <code>sbt</code> uses Ivy for dependency resolution, you'll either need to construct a local Ivy repository as part of the build (for F20) or rely on xmvn's improved support for Ivy metadata (in F21 and above after xmvn 2.0 lands).  For now, this guide covers building packages on F20 with the [https://github.com/willb/climbing-nemesis/ climbing-nemesis] script.
This is a quick guide to getting Fedora packages built with <code>sbt</code>.  Since <code>sbt</code> uses Ivy for dependency resolution, you'll either need to construct a local Ivy repository as part of the build (for F20) or rely on xmvn's improved support for Ivy metadata (in F21 and above after xmvn 2.0 lands).  For now, this guide covers building packages on F20 with the [https://github.com/willb/climbing-nemesis/ climbing-nemesis] script.
Eventually, I hope that the best practices around building Scala projects will coalesce into official Scala packaging guidelines, but for now it's sort of the wild west.


== General tips and tricks ==
== General tips and tricks ==
Line 10: Line 12:


=== Helpful macros ===
=== Helpful macros ===
The first of these macros, <code>remap_version</code>, takes a group ID, an artifact ID, a version string, and a <code>sbt</code> build file and updates the file so that any dependency on the given artifact is for the version specified in the macro invocation and not on whatever version was in the build file.
<code>%global remap_version() sed -i -e 's/"%{1}" %% "%{2}" %% "[^"]*"/"%{1}" %% "%{2}" %% "'%{3}'"/g' %{4} </code>
<code>remap_version_to_installed</code> takes a group ID, an artifact ID, and a <code>sbt</code> build file and updates the file so that any dependency on the given artifact is for the version of that artifact installed on the build machine.
<code>%global remap_version_to_installed() sed -i -e 's/"%{1}" %% "%{2}" %% "[^"]*"/"%{1}" %% "%{2}" %% "'$(rpm -q --qf "%%%%{version}" $(rpm -q --whatprovides "mvn(%{1}:%{2})" ))'"/g' %{3}</code>


== Using <code>climbing-nemesis</code> ==
== Using <code>climbing-nemesis</code> ==

Revision as of 16:31, 10 February 2014

Building packages that use sbt

Overview

This is a quick guide to getting Fedora packages built with sbt. Since sbt uses Ivy for dependency resolution, you'll either need to construct a local Ivy repository as part of the build (for F20) or rely on xmvn's improved support for Ivy metadata (in F21 and above after xmvn 2.0 lands). For now, this guide covers building packages on F20 with the climbing-nemesis script.

Eventually, I hope that the best practices around building Scala projects will coalesce into official Scala packaging guidelines, but for now it's sort of the wild west.

General tips and tricks

sbt build files are either written in a domain-specific language (*.sbt files) or are general Scala code that incorporates sbt as a library. This means that patches against sbt builds are typically less brittle than patches against Ant build files, and it's more straightforward to carry Fedora-specific build patches as sed commands.

Helpful macros

The first of these macros, remap_version, takes a group ID, an artifact ID, a version string, and a sbt build file and updates the file so that any dependency on the given artifact is for the version specified in the macro invocation and not on whatever version was in the build file.

%global remap_version() sed -i -e 's/"%{1}" %% "%{2}" %% "[^"]*"/"%{1}" %% "%{2}" %% "'%{3}'"/g' %{4}

remap_version_to_installed takes a group ID, an artifact ID, and a sbt build file and updates the file so that any dependency on the given artifact is for the version of that artifact installed on the build machine.

%global remap_version_to_installed() sed -i -e 's/"%{1}" %% "%{2}" %% "[^"]*"/"%{1}" %% "%{2}" %% "'$(rpm -q --qf "%%%%{version}" $(rpm -q --whatprovides "mvn(%{1}:%{2})" ))'"/g' %{3}

Using climbing-nemesis