Gentoo Logo
Gentoo Spaceship




Note: Due to technical difficulties, the Archives are currently not up to date. GMANE provides an alternative service for most mailing lists.
c.f. bug 424647
List Archive: gentoo-java
Navigation:
Lists: gentoo-java: < Prev By Thread Next > < Prev By Date Next >
Headers:
To: gentoo-java@g.o
From: Martin von Gagern <Martin.vGagern@...>
Subject: java-pkg-simple and java-mvn-src eclasses
Date: Fri, 02 Jan 2009 13:51:17 +0100
Hi!

I propose two new eclasses. One is for building java packages from their
*.java source files, without any additional build instructions. The
second builds on it and is intended for source bundles exported by the
source:jar goal of Maven2. Two parts of istack-commons can be bumped
using these, in order to address https://bugs.gentoo.org/188015 .

I would like to commit all of these to java-experimental if there are no
objectsion. If you leave the Subject in place, I will catch replies to
this list. Otherwise please Cc me personally, as I don't read every mail
to the list.

On IRC selckin1 said: "simple eclass to build simple java packages has
been proposed many times. my main question would be why doesn't it exist
allready, this been suggested many times going back years, must be a
reason." Any input on this would be useful as well.

Greetings,
 Martin von Gagern (aka MvG)
# Eclass for simple bare-source Java packages
#
# Copyright (c) 2004-2008, Gentoo Foundation
#
# Licensed under the GNU General Public License, v2
#
# $Header: $

inherit java-pkg-2

# -----------------------------------------------------------------------------
# @eclass-begin
# @eclass-summary Eclass for Java sources without build instructions
#
# This class is intended to build pure Java packages from Java sources
# without the use of any build instructions shipped with the sources.
# There is no support for resources besides the generated class files,
# or for generating source files, or for controlling the META-INF of
# the resulting jar, although these issues may be addressed by an
# ebuild between the src_compile and the src_install phase.
# -----------------------------------------------------------------------------

EXPORT_FUNCTIONS src_compile src_install

# We are only interested in finding all java source files, wherever they may be.
S="${WORKDIR}"

# -----------------------------------------------------------------------------
# @variable-external JAVA_DEPEND
# @variable-default ""
#
# Comma separated list of java packages to include in the class path.
# The packages will also be registered as runtime dependencies of this
# new package. Dependencies will be calculated transitively. See
# "java-config -l" for appropriate package names.
# -----------------------------------------------------------------------------
# JAVA_DEPEND

# ------------------------------------------------------------------------------
# @eclass-src_compile
#
# src_compile for simple bare source java packages. Finds all *.java
# sources in ${S}, compiles them with the classpath calculated from
# ${JAVA_DEPEND}, and packages the resulting classes to ${PN}.jar.
#
# variables: JAVA_DEPEND - list java packages to put on the classpath.
# ------------------------------------------------------------------------------
java-pkg-simple_src_compile() {
	find * -name \*.java > sources.lst
	mkdir target || die "Could not create target directory"
	local classpath="target"
	if [[ ${JAVA_DEPEND} ]]; then
		classpath="${classpath}:$(java-pkg_getjars --with-dependencies ${JAVA_DEPEND})"
	fi
	debug-print "CLASSPATH=${classpath}"
	echo "javac -d target -cp ${classpath} @sources.lst"
	ejavac -d target -cp "${classpath}" @sources.lst
}

# ------------------------------------------------------------------------------
# @eclass-src_install
#
# src_install for simple single jar java packages. Simply packages the
# contents from the target directory and installs it as ${PN}.jar. If
# the file target/META-INF/MANIFEST.MF exists, it is used as the
# manifest of the created jar.
# ------------------------------------------------------------------------------
java-pkg-simple_src_install() {
	local jar_args="cf ${PN}.jar"
	if [[ -e target/META-INF/MANIFEST.MF ]]; then
		jar_args="cfm ${PN}.jar target/META-INF/MANIFEST.MF"
	fi
	echo "jar ${jar_args} -C target ."
	jar ${jar_args} -C target . || die "jar failed"
	java-pkg_dojar ${PN}.jar
}

# ------------------------------------------------------------------------------
# @eclass-end
# ------------------------------------------------------------------------------
# Eclass for Java packages from bare sources exported by Maven
#
# Copyright (c) 2004-2008, Gentoo Foundation
#
# Licensed under the GNU General Public License, v2
#
# $Header: $

inherit java-pkg-simple

# -----------------------------------------------------------------------------
# @eclass-begin
# @eclass-summary Eclass for Java packages from bare sources exported by Maven
#
# This class is intended to build pure Java packages from the sources exported
# from the source:jar goal of Maven 2. These archives contain bare Java source
# files, with no build instructions or additional resource files. They are
# unsuitable for packages that require resources besides compiled class files.
# The benefit is that for artifacts developed with Maven, these source files
# are often released together with binary packages, whereas the full build
# environment might be contained in some revision control system or not
# available at all.
# -----------------------------------------------------------------------------

# -----------------------------------------------------------------------------
# @variable-external GROUP_ID
# @variable-default ${PN}
#
# The groupId of the artifact, in dotted notation.
# -----------------------------------------------------------------------------
: ${GROUP_ID:=${PN}}

# -----------------------------------------------------------------------------
# @variable-external ARTIFACT_ID
# @variable-default ${PN}
#
# The artifactId of the artifact.
# -----------------------------------------------------------------------------
: ${ARTIFACT_ID:=${PN}}

# -----------------------------------------------------------------------------
# @variable-external MAVEN2_REPOSITORIES
# @variable-default http://repo2.maven.org/maven2 http://download.java.net/maven/2
#
# The repositories to search for the artifacts. Must follow Maven2 layout.
# -----------------------------------------------------------------------------
: ${MAVEN2_REPOSITORIES:="http://repo2.maven.org/maven2 http://download.java.net/maven/2"}

# -----------------------------------------------------------------------------
# @variable-internal RELATIVE_SRC_URI
#
# The path of the source artifact relative to the root of the repository.
# Will be set by the eclass to follow Maven 2 repository layout.
# -----------------------------------------------------------------------------
RELATIVE_SRC_URI=${GROUP_ID//./\/}/${ARTIFACT_ID}/${PV}/${ARTIFACT_ID}-${PV}-sources.jar

# Look for source jar in all listed repositories
for repo in ${MAVEN2_REPOSITORIES}; do
    SRC_URI="${SRC_URI} ${repo}/${RELATIVE_SRC_URI}"
done
unset repo

# ------------------------------------------------------------------------------
# @eclass-end
# ------------------------------------------------------------------------------
# Copyright 1999-2008 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $

GROUP_ID="com.sun.istack"

inherit java-mvn-src

DESCRIPTION="Runtime library of istack-commons"
HOMEPAGE="https://istack-commons.dev.java.net/"

LICENSE="CDDL"
SLOT="0"
KEYWORDS="~x86"

COMMON_DEP="java-virtuals/jaf
	java-virtuals/stax-api"
DEPEND=">=virtual/jdk-1.5
	${COMMON_DEP}"
RDEPEND=">=virtual/jre-1.5
	${COMMON_DEP}"
JAVA_DEPEND="stax-api,jaf"
# Copyright 1999-2008 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $

GROUP_ID="com.sun.istack"

inherit java-mvn-src

DESCRIPTION="Tools from istack-commons"
HOMEPAGE="https://istack-commons.dev.java.net/"

LICENSE="CDDL"
SLOT="0"
KEYWORDS="~x86"

COMMON_DEP="dev-java/apt-mirror
	java-virtuals/jaf
	java-java/ant-core"
DEPEND=">=virtual/jdk-1.5
	${COMMON_DEP}"
RDEPEND=">=virtual/jre-1.5
	${COMMON_DEP}"
JAVA_DEPEND="apt-mirror,jaf,ant-core"
Attachment:
signature.asc (OpenPGP digital signature)
Replies:
Re: java-pkg-simple and java-mvn-src eclasses
-- Martin von Gagern
Re: java-pkg-simple and java-mvn-src eclasses
-- Alistair Bush
Re: java-pkg-simple and java-mvn-src eclasses
-- Serkan Kaba
Navigation:
Lists: gentoo-java: < Prev By Thread Next > < Prev By Date Next >
Previous by thread:
Last mile for nuking generation 1
Next by thread:
Re: java-pkg-simple and java-mvn-src eclasses
Previous by date:
Last mile for nuking generation 1
Next by date:
Re: java-pkg-simple and java-mvn-src eclasses


Updated Jun 17, 2009

Summary: Archive of the gentoo-java mailing list.

Donate to support our development efforts.

Copyright 2001-2013 Gentoo Foundation, Inc. Questions, Comments? Contact us.