/srv/irclogs.ubuntu.com/2009/06/11/#ubuntu-classroom.txt

=== santiago-pgsql is now known as santiago-ve
=== Guest54546 is now known as santiago-ve
=== ziroday is now known as zeroday
=== zeroday is now known as ziroday`
=== ziroday` is now known as ziroday
=== mzz is now known as mzz_
=== mzz_ is now known as mzz
ttxWho is here for the Packaging Training session on Java libraries ?12:59
ttxanyone? :)13:00
jkeyes0I am, sort of. I know little to nothing about packaging in Ubuntu, so I just planned to sit on the sidelines and observe.13:01
* drubin 13:01
ttxjkeyes0: that's perfectly alright. I was worried I would talk with noone listening13:01
ttxOK, let's start !13:02
ttxWelcome everyone to this packaging training session, today the subject is Java library packaging...13:02
ttxThis session assumes you know some basics of Debian packaging and have a vague notion of what a Java library and "ant" are.13:02
* Quintasan waves13:02
ttxTalk / discussion should happen in #ubuntu-classroom-chat. Prefix questions with QUESTION: so that I can spot them more easily. Let me know on channel if I go too fast...13:02
ttxSo...13:03
ttxJava software uses lots of Java libraries, which are commonly provided as JAR files13:03
ttxIt usually ships with a directory full of those JAR files and some launcher that builds a classpath from them. But that's not how we do it in Linux distributions13:03
ttxWe want to build from source, and we want to avoid code duplication. So we want to package Java libraries separately, place them in a common directory (/usr/share/java), and then have the software started with a classpath that points to them13:03
ttxTrying to have a common library set causes several global issues (in particular with software requiring slightly different versions of the same library) but that's not the purpose of this session13:04
ttxWe lack a lot of very common Java libraries, which makes packaging Java software more complex than it should. This session will focus on the specific rules and tips to properly package Java libraries, with a few examples.13:04
ttxAny question so far ?13:05
ttxOK, there should be a lot more in a few minutes :)13:05
ttxSo let's say you are packaging some Java software and it imports org.safehaus.uuid, conveniently from a binary JAR bundled with its own source in lib/jug-asl-2.2.0.jar13:05
ttxI meant, "So let's say you are packaging some Java software and it imports org.safehaus.uuid, conveniently from a binary JAR bundled with its own source in lib/jug-asl-2.2.0.jar"13:06
ttxWe can't just use that binary JAR. We have to build that JAR from source and have the software build-depend on it.13:06
ttxSo we need to package version 2.2.0 of that "jug-asl" library.13:07
ttxBasically what you want to do is to build jug-asl.jar from source and end up with /usr/share/java/jug-asl-2.2.0.jar, together with a symbolic link /usr/share/java/jug-asl.jar -> jug-asl-2.2.0.jar13:07
ttxFirst you need to double-check that this library hasn't already been packaged somewhere. It's not as easy as it sounds, sometimes its classes will be hidden somewhere in a strange jar name in an obscure package...13:08
ttxTo be sure, you would need to unjar all the JARs that the distribution contains to check.13:08
ttxFortunately I did that for you and published java-Contents.gz files that contain all classes in all jars in all packages...13:08
ttxSee https://wiki.ubuntu.com/JavaTeam/JavaContents13:08
ttxSo making sure that nobody already provides org.safehaus.uuid in Jaunty is just a matter of downloading the java-Contents.gz file and do a "zgrep org.safehaus.uuid jaunty-java-Contents.gz"13:09
ttxIf you try it, you can see that it's packaged as part of the "eucalyptus-javadeps" package...13:10
ttxBut now you want to properly package it separately, depending on eucalyptus-javadeps is just not an option for you.13:10
ttxQuestions, so far ?13:10
ttxBefore we attack the packaging part :)13:11
ttxI'll assume everything is crystal clear, then.13:12
ttxQUESTION: how could I know that an app uses org.safehaus.uuid?13:12
ttxYou can usually tell from the build documentation of the software you want to package.13:13
ttxBut you often find out when you try to compile it... and get import errors during java compilation13:13
ttxjmehdi: does that answer your question ?13:14
jmehdittx: yep ;)13:14
ttxOk, let's continue.13:15
ttxJava library packaging follows the usual rules, with a few specificities.13:15
ttxFirst debian/control:13:15
ttxYou should build-depend on "default-jdk" (+any other Java library needed at build-time)13:15
ttxThat will use openjdk-6-jdk in Ubuntu13:15
ttx(for amd64/i386)13:16
ttxThe binary package that will install those MUST be named libjug-asl-java, this is a requirement of the Debian Java policy. I'll name the source package after the project name, "jug", even if some packagers use libfoo-java as the source package name as well.13:16
ttxThe binary should usually depend on "default-jre-headless | java2-runtime-headless". That makes sure the right runtime environment is pulled if nothing is already present.13:17
ttxIf the library requires Java 5 or Java 6, use java5- or java6- instead of java2-13:17
ttxIf the library *really* cannot do anything without the full JRE, then you should depend on "default-jre | java2-runtime". But usually you don't need to.13:17
ttxAny question about the debian/control file ?13:18
ttxQUESTION: what's the difference between jre-headless and default-jre?13:19
ttxThe "headless" JRE is one without graphical extensions13:20
ttxso it doesn't pull 50 Mb of X libraries with it13:20
ttxOn a desktop you don't really care13:20
ttxbut on servers... you clearly don't want to install all those X libraries that your Java library doesn't really use13:21
ttxOK, moving on to debian/rules13:21
ttxthe complex part :)13:21
ttxDownloading jug-src.tar.gz from http://jug.safehaus.org/Download I can see that there is a build.xml there, which means it uses the ant build system, which is good news.13:21
ttx"ant" is like a Java-oriented "make". The Makefile is called build.xml and contains targets (in XML) that you can call with ant <target>.13:22
ttxThe easy way to write the rules file is to use the CDBS ant class. See http://pastebin.ubuntu.com/192289/ for example13:22
ttxsimple, uh ?13:22
ttxYou just need to identify the ant task that will build what you need. here it is "jar.asl", you don't want the native part of the jug-lgpl version.13:23
ttxNow, the tricky part.13:23
ttxTo successfully compile you will need to have the required Java libraries in the compiler classpath.13:23
ttxTo make the Ubuntu build-daemons happy we need to build-depend on the needed library package and insert its JAR into the compiler classpath, we can't use directly another binary coming from nowhere.13:24
ttxAs a sidenote, that means you first need to properly package all the Java library dependencies needed to build your own... which can be a very large number ;)13:24
ttxThe CDBS ant class has a nifty mechanism for inserting JARs in the system classpath, just add the required JAR names on a DEB_JARS line. You can put JAR names (without path or extension, it will look in /usr/share/java) or complete paths.13:24
ttxIn our example, jug needs the log4j library to compile. We would just add a liblog4j-java build-depend in debian/control, and in debian/rules :13:25
ttxDEB_JARS := log4j13:25
ttx(will add /usr/share/java/log4j.jar to the Java compiler classpath)13:26
ttxIf the build.xml doesn't try to be too smart with required dependencies, it's all that is needed. But sometimes the "source" bundles the needed binary JAR dependencies, so you need to patch out the part that adds them to the classpath.13:26
ttxAnother option is to play with the "build.sysclasspath" ant property to control precedence between system classpath and build.xml classpath, like this:13:26
ttxDEB_ANT_ARGS := -Dbuild.sysclasspath=last13:27
ttxThere is no definitive solution since it all depends on how the build.xml file is written. I'd suggest starting packaging easy libraries with no build-dependencies, then try one with a couple dependencies, etc.13:27
ttxQuestions ?13:27
ttxThat may seem complex. But Libraries without any dependencies are really simple13:28
bdrungi missed the start, is there already a log for this session?13:29
ttxQUESTION: is this dependencies management specific to java?13:29
ttxbdrung: maybe on irclogs.ubuntu.com13:29
ttxThis dependency management is not really specific to Java13:30
ttxWhat is specific to Java is that stuff usually depends on tons of other stuff13:30
ttxand their build systems aren't distribution-oriented13:31
ttxso they just pack their binary dependencies with their source code13:31
ttxand tell you to run "ant" and be done with it.13:31
ttxthe difficulty here is to make that build-daemon compatible13:31
ttxand end up with everything built from pure source13:32
ttxand without code duplication13:32
ttxThat's where it gets complex :)13:32
ttxOK, we have some time left, so I'll speak of what we do when the library doesn't use "ant".13:33
ttxIf there is no build system, the easiest way is to write a minimal build.xml file and use the ant CDBS class.13:33
ttxSomething like http://pastebin.ubuntu.com/192303/13:33
ttx(this one will compile all classes in src/main/java and make a JAR out of them)13:34
ttxThis should be sufficient for most libraries. But sometimes... if you're unlucky... the stuff you want to package will use maven.13:34
* ttx pauses for some dramatic effect13:34
ttxMaven is a complex build/integration system that handles both build rules and dependency management. The trouble for us is that it makes heavy use of pre-built JARS that it downloads directly from Maven repositories.13:35
ttxSince we want reproduceability our build-daemons cannot download from outside repositories. We need to use our own packages. So we need to bypass Maven dependency management completely.13:35
ttxIf the software is simple enough I'd recommend rewrite an ant build.xml file, as if there were no build system, and use the maven files as hints on required dependencies.13:35
ttxBut if you're really really unlucky, the thing you're trying to package will make heavy use of "maven plugins" so rewriting it as a build.xml file is just impossible.13:36
* ttx pauses again for more dramatic effect13:36
ttxWe are still investigating techniques to work around that problem. The idea is to set up an environment around maven to make it believe it already has everything it needs to run, so that it doesn't download anything.13:36
ttxFor those interested, Debian proposes: http://wiki.debian.org/Java/MavenBuilder. It's not really complete, but they packaged a lot of Maven plugins already so that's very good.13:37
ttxWe originally proposed a slightly different approach, less integrated but that can be used on a per-package basis: https://wiki.ubuntu.com/JavaTeam/Specs/MavenSupportSpec. We benefit from Debian work on packaging plugins.13:37
ttxThat's all about alternative build systems.13:38
ttxTo sum it up, looking at the build system and dependencies you'll have a good idea of the complexity of the task ahead13:38
ttxant-based, no build dependencies --> easy13:39
ttxant-based, a few already-packaged build dependencies --> medium13:39
ttxno build system --> medium13:39
ttxant-based or no build system, lots of build deps --> hard13:40
ttxmaven-based with lots of plugins --> huh13:40
ttxQuestions ?13:40
ttxQUESTION: does eclipse uses maven?13:41
ttxI don't think so. I think they use ant, and they don't have so much external dependencies13:42
ttxapt-get source eclipse and looking at debian/rules you should be able to see13:42
ttxJetty 6 uses maven, for example13:43
ttxBut upstream was kind enough to produce an ant build.xml13:43
ttxMost of the stuff I talked about is documented in wiki at https://wiki.ubuntu.com/JavaTeam/LibraryPackaging13:44
ttxPlease join #ubuntu-java and the Java team meetings (on Thursdays, 1400 UTC) if you're interested in doing Java packaging.13:44
ttxWe should publish a list of wanted libraries, with an evaluation of the expected difficulty13:45
darkwiseQ: is-it the same why to package a java program ? (there is some where to ask questions?)13:45
darkwiseah ok thanks :)13:45
ttxdarkwise: Java programs have the same problems. A few things I talked about don't apply to them though13:46
ttxlike package naming13:46
ttxor runtime dependencies13:46
ttxBut in the end programs are made of libraries, so... :)13:46
ttxIf you look into the tomcat6 package for example...13:47
ttxit produces a library part called libtomcat6-java13:47
ttxthe rest is the launchers, init scripts and tools around that13:47
ttxthat's all I wanted to talk about, so I open the floor for discussion13:48
darkwiseI get it ;) thanks ttx13:48
ttxAny other question ?13:49
ttxOK, thanks everyone for listening, hopefully I didn't make it look like more difficult than it really is :)13:50
ttxI expect the logs of the session to be available at http://irclogs.ubuntu.com/2009/06/11/%23ubuntu-classroom.txt in a few minutes13:51
darkwisethank you ttx13:51
ttxfor those that have been missing the beginning13:51
maxpaguruttx: thanks! Bye everybody13:51
ttxand soon on https://wiki.ubuntu.com/Packaging/Training/Logs13:52
derwasnice!13:52
ttxFor more questions you can always ping me on #ubuntu-java13:53
ttx(as long as it's Java packaging questions more than Java questions)13:53
ttxbye everyone !13:54
=== forevernoob is now known as livingdaylight
=== noodles776 is now known as noodles
mib_dg74kw7panyone know how to view or change uid to gain permissions for devices ?15:49
=== yofel_ is now known as yofel
=== rmcbride_ is now known as rmcbride
=== MaWaLe is now known as Mosquitoooo
=== ejat is now known as e-jat
=== ChanServ changed the topic of #ubuntu-classroom to: Ubuntu Classroom || https://wiki.ubuntu.com/Classroom || https://lists.ubuntu.com/mailman/listinfo/ubuntu-classroom || Upcoming: 25th June @ 00:00 UTC: Testing your packages using pbuilder || Run 'date -u' in a terminal to find out the UTC time

Generated by irclog2html.py 2.7 by Marius Gedminas - find it at mg.pov.lt!