public inbox for gentoo-java@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-java] java-pkg-simple and java-mvn-src eclasses
@ 2009-01-02 12:51 Martin von Gagern
  2009-01-02 20:21 ` Serkan Kaba
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Martin von Gagern @ 2009-01-02 12:51 UTC (permalink / raw
  To: gentoo-java


[-- Attachment #1.1: Type: text/plain, Size: 910 bytes --]

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)

[-- Attachment #1.2: java-pkg-simple.eclass --]
[-- Type: text/plain, Size: 3224 bytes --]

# 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
# ------------------------------------------------------------------------------

[-- Attachment #1.3: java-mvn-src.eclass --]
[-- Type: text/plain, Size: 2806 bytes --]

# 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
# ------------------------------------------------------------------------------

[-- Attachment #1.4: istack-commons-runtime-1.0.ebuild --]
[-- Type: text/plain, Size: 475 bytes --]

# 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"

[-- Attachment #1.5: istack-commons-tools-1.1.ebuild --]
[-- Type: text/plain, Size: 495 bytes --]

# 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 #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 260 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2009-01-03 12:55 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-01-02 12:51 [gentoo-java] java-pkg-simple and java-mvn-src eclasses Martin von Gagern
2009-01-02 20:21 ` Serkan Kaba
2009-01-03  9:33   ` Martin von Gagern
2009-01-02 23:54 ` Alistair Bush
2009-01-03  0:23   ` Serkan Kaba
2009-01-03  6:18     ` Alistair Bush
2009-01-03  9:28   ` Martin von Gagern
2009-01-03 12:55 ` Martin von Gagern

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox