* [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
* Re: [gentoo-java] java-pkg-simple and java-mvn-src eclasses
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 12:55 ` Martin von Gagern
2 siblings, 1 reply; 8+ messages in thread
From: Serkan Kaba @ 2009-01-02 20:21 UTC (permalink / raw
To: Martin von Gagern; +Cc: gentoo-java
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Martin von Gagern yazmış:
First of all I thank you for your suggestions. Integrating maven into
Gentoo Java infrastructure is in our TODO list for a long time and we
welcome any input trying to resolve this.
> 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 .
Some projects such as mina and slf4j distribute these versioned
- -source.jar files. I use the -source.jar files and I explicitly use
those to build the binaries.
>
> 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.
The in tree ebuilds follow two methods here. One like yours where ejavac
is called for a set of java files. See media-sound/jtagger ebuild as an
example. The other is having a simple build.xml file as in
dev-java/slf4j-* or dev-java/mina-core. There are numerous examples in
tree for both methods.
>
> Greetings,
> Martin von Gagern (aka MvG)
>
- --
Sincerely,
Serkan KABA
Gentoo/Java
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iEYEARECAAYFAkledzYACgkQRh6X64ivZaKrOQCcCVWoTubNV/XKIx+TIAtHJ9YB
MuAAn1i7A3kM+JNYA6N/ObWddpagZoGd
=dXf5
-----END PGP SIGNATURE-----
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [gentoo-java] java-pkg-simple and java-mvn-src eclasses
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-02 23:54 ` Alistair Bush
2009-01-03 0:23 ` Serkan Kaba
2009-01-03 9:28 ` Martin von Gagern
2009-01-03 12:55 ` Martin von Gagern
2 siblings, 2 replies; 8+ messages in thread
From: Alistair Bush @ 2009-01-02 23:54 UTC (permalink / raw
To: gentoo-java
Ok, things to note and it would be interesting to see whether other
dev's agree with me:
java-pkg-simple.eclass:
1) inherit java-utils-2 (this is required) instead of java-pkg-2. Add
checks to ensure java-pkg-2 is inheritted (so ebuild does it).
2) create the jar within src_compile, not src install.
3) I would like to see var's like JAVA_SRC_DIR(S) so that
java-pkg_dosrc and javadoc could be generated and installed. See what
you can do :)
java-mvn-src.eclass:
Have this inherit from java-pkg-simple.eclass
Im also concerned about how you are attempting to download a single
file from multiple locations. Im told it is valid, but would rather set
it up as a thirdpartymirror.
*.ebuilds:
inherit java-pkg-2 [java-pkg-simple java-mvn-src]
With the eclasses i'm trying to make them as similar to the layout (and
relationships) of java-pkg-2 and java-ant-2
Martin von Gagern wrote:
> 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.
My only concern with "simple eclasses" is it could compile, bundle and
install
tests, or even more concerning be used to bypass
a "better" build system that includes unit tests, etc, etc.
>
> Greetings,
> Martin von Gagern (aka MvG)
>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [gentoo-java] java-pkg-simple and java-mvn-src eclasses
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
1 sibling, 1 reply; 8+ messages in thread
From: Serkan Kaba @ 2009-01-03 0:23 UTC (permalink / raw
To: Alistair Bush; +Cc: gentoo-java
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Alistair Bush yazmış:
> Ok, things to note and it would be interesting to see whether other
> dev's agree with me:
>
> java-pkg-simple.eclass:
>
> 1) inherit java-utils-2 (this is required) instead of java-pkg-2. Add
> checks to ensure java-pkg-2 is inheritted (so ebuild does it).
> 2) create the jar within src_compile, not src install.
> 3) I would like to see var's like JAVA_SRC_DIR(S) so that
> java-pkg_dosrc and javadoc could be generated and installed. See what
> you can do :)
>
> java-mvn-src.eclass:
> Have this inherit from java-pkg-simple.eclass
> Im also concerned about how you are attempting to download a single
> file from multiple locations. Im told it is valid, but would rather set
> it up as a thirdpartymirror.
>
> *.ebuilds:
> inherit java-pkg-2 [java-pkg-simple java-mvn-src]
>
> With the eclasses i'm trying to make them as similar to the layout (and
> relationships) of java-pkg-2 and java-ant-2
>
> Martin von Gagern wrote:
>> 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.
>
> My only concern with "simple eclasses" is it could compile, bundle and
> install
> tests, or even more concerning be used to bypass
> a "better" build system that includes unit tests, etc, etc.
ejunit can be helpful there. But ant suits better imo. We can have a
more generic build.xml (possibly included with one of our own tools or
created in the eclass itself) and an option for the ebuilds to use their
own build.xml files as well (As already done in tree) Having an option
to override the default build.xml will help to overcome packages which
doesn't fit to generic. But still we should see if there are more
generaliations than exceptions.
>
>> Greetings,
>> Martin von Gagern (aka MvG)
>>
>
>
>
- --
Sincerely,
Serkan KABA
Gentoo/Java
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iEYEARECAAYFAkler+4ACgkQRh6X64ivZaJ0cgCcCJKF8kxr+xpLM/jvQ1gT08zE
II0An0kyaMNulk1lUmwzGzSQpcySxbVk
=BR4r
-----END PGP SIGNATURE-----
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [gentoo-java] java-pkg-simple and java-mvn-src eclasses
2009-01-03 0:23 ` Serkan Kaba
@ 2009-01-03 6:18 ` Alistair Bush
0 siblings, 0 replies; 8+ messages in thread
From: Alistair Bush @ 2009-01-03 6:18 UTC (permalink / raw
To: gentoo-java
Serkan Kaba wrote:
> Alistair Bush yazm1_:
>> Ok, things to note and it would be interesting to see whether other
>> dev's agree with me:
>
>> java-pkg-simple.eclass:
>
>> 1) inherit java-utils-2 (this is required) instead of java-pkg-2. Add
>> checks to ensure java-pkg-2 is inheritted (so ebuild does it).
>> 2) create the jar within src_compile, not src install.
>> 3) I would like to see var's like JAVA_SRC_DIR(S) so that
>> java-pkg_dosrc and javadoc could be generated and installed. See what
>> you can do :)
>
>> java-mvn-src.eclass:
>> Have this inherit from java-pkg-simple.eclass
>> Im also concerned about how you are attempting to download a single
>> file from multiple locations. Im told it is valid, but would rather set
>> it up as a thirdpartymirror.
>
>> *.ebuilds:
>> inherit java-pkg-2 [java-pkg-simple java-mvn-src]
>
>> With the eclasses i'm trying to make them as similar to the layout (and
>> relationships) of java-pkg-2 and java-ant-2
>
>> Martin von Gagern wrote:
>>> 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.
>> My only concern with "simple eclasses" is it could compile, bundle and
>> install
>> tests, or even more concerning be used to bypass
>> a "better" build system that includes unit tests, etc, etc.
> ejunit can be helpful there. But ant suits better imo. We can have a
> more generic build.xml (possibly included with one of our own tools or
> created in the eclass itself) and an option for the ebuilds to use their
> own build.xml files as well (As already done in tree) Having an option
> to override the default build.xml will help to overcome packages which
> doesn't fit to generic. But still we should see if there are more
> generaliations than exceptions.
I think you misunderstand where im coming from.
ejunit is going to run the unit tests. my problem isn't running them,
it is then being compiled within src_compile and ending up within the
resulting jar file in the first place.
java-pkg-simple_src_compile just runs `find * -name \*.java >
sources.lst` to find all the *.java files. even in they are with
directories src/test, test or JAVA_FILES_DO_NOT_COMPILE directory.
Why I like the JAVA_SRC_DIR ( or whatever ) variable is then at least we
could go and do something like
find ${JAVA_SRC_DIR} -name \*.java > source.lst
as long as we don't quote JAVA_SRC_DIR I believe it should work.
The eclass/default build.xml is also another option that has been thrown
around for a while either.
>>> Greetings,
>>> Martin von Gagern (aka MvG)
>>>
>
>
>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [gentoo-java] java-pkg-simple and java-mvn-src eclasses
2009-01-02 23:54 ` Alistair Bush
2009-01-03 0:23 ` Serkan Kaba
@ 2009-01-03 9:28 ` Martin von Gagern
1 sibling, 0 replies; 8+ messages in thread
From: Martin von Gagern @ 2009-01-03 9:28 UTC (permalink / raw
To: Alistair Bush; +Cc: gentoo-java
[-- Attachment #1: Type: text/plain, Size: 4600 bytes --]
Alistair Bush wrote:
> java-pkg-simple.eclass:
>
> 1) inherit java-utils-2 (this is required) instead of java-pkg-2. Add
> checks to ensure java-pkg-2 is inheritted (so ebuild does it).
I derived my eclass from java-pkg-2 instead of java-utils-2 because
conceptually I'm building a java package, so that seemed the right
eclass, and because technically I'd like to leverage the magic around
JAVA_PKG_IUSE and JAVA_PKG_E_DEPEND without copying the corresponding
sections from java-pkg-2.eclass.
I now see that if the ebuild also inherits from java-pkg-2, then I would
have to copy nothing. It would have to inherit in the right order,
htough. If every ebuild using java-pkg-simple.eclass also must inherit
java-pkg-2, what is the reason against making that dependency explicit
in the eclass? Is that what you mean by making the relationship similar
to java-pkg-2 and java-ant-2, as you wrote down there for *.ebuilds?
> 2) create the jar within src_compile, not src install.
I had that in a previous version, and changed it so that ebuilds cann
add resources to the target directory before it gets packaged. As an
alternative, ebuilds could create the target directory and add resources
before calling java-pkg-simple_src_compile in the first place. Would
mean one mkdir more in the ebuild, and no check by the eclass that the
target directory didn't exist in the archive, which should hold in all
sane cases anyway. I could also place the target dir in ${T} to be sure.
> 3) I would like to see var's like JAVA_SRC_DIR(S) so that
> java-pkg_dosrc and javadoc could be generated and installed. See what
> you can do :)
In most cases ${S} would suffice for this. At least javadoc should take
a file list just like javac does (in fact the very same list), so that
should be easy. For dosrc you need to indeed catch the root of the
source tree.
On the other hand, I like your idea about JAVA_SRC_DIR as an argument to
find, as it imposes no additional requirements on simple ebuilds but
adds flexibility for a bit more complex cases. I'll see that I integrate
that with dosrc as well.
> java-mvn-src.eclass:
> Have this inherit from java-pkg-simple.eclass
I thought I did. Yes, it says "inherit java-pkg-simple" in the ebuild.
> Im also concerned about how you are attempting to download a single
> file from multiple locations. Im told it is valid, but would rather set
> it up as a thirdpartymirror.
Technically this would give the same result, but conceptually we are not
talking about mirrors here. We have several separate repositories, and
the artifact might be located in any one of them, but usually not in
all, in contrast to a mirror. I also definitely want to give ebuilds the
option to specify the repository. Instead of adding to thirdpartymirror,
I guess I'd rather require ebuilds to specify the repository. The way it
is now allows for laziness of ebuild writers and for inclusion of
content into central repositories at a later point in time.
> *.ebuilds:
> inherit java-pkg-2 [java-pkg-simple java-mvn-src]
What do you wish to denote with the brackets? I guess I'll have to
inherit java-pkg-2 java-mvn-src
if I indeed drop the inherit java-pkg-2 from java-pkg-simple.eclass.
Or were you referring to ebuilds in general, not only my two istack ones?
> With the eclasses i'm trying to make them as similar to the layout (and
> relationships) of java-pkg-2 and java-ant-2
Is this the reason why java-pkg-simple shouldn't itself inherit java-pkg-2?
> My only concern with "simple eclasses" is it could compile, bundle and
> install tests,
You can't take all work from ebuild writers. They either have to remove
test code first, choose JAVA_SRC_DIR correctly (once I've introduced
it), choose S correctly (i.e. in src/main for common maven-like layout)
to eclude tests, or perhaps this eclass simply isn't for them.
> or even more concerning be used to bypass
> a "better" build system that includes unit tests, etc, etc.
Depending on circumstances, that might not even be wrong. If the
"better" build system is inherently tricky to handle, a simple eclass
might be used to get an important package into portage quickly, while
more elaborate ebuilds are still being developed.
I might add some QA tests, e.g. to have java-pkg-simple complain if it
finds a build.xml or pom.xml, or if there sources.lst seems to contain
tests (e.g. a subdirectory called test or tests).
I'll get back to my eclasses, send you the next iteration soon I guess.
Greetings,
Martin
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 260 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [gentoo-java] java-pkg-simple and java-mvn-src eclasses
2009-01-02 20:21 ` Serkan Kaba
@ 2009-01-03 9:33 ` Martin von Gagern
0 siblings, 0 replies; 8+ messages in thread
From: Martin von Gagern @ 2009-01-03 9:33 UTC (permalink / raw
To: Serkan Kaba; +Cc: gentoo-java
[-- Attachment #1: Type: text/plain, Size: 821 bytes --]
Serkan Kaba wrote:
> The in tree ebuilds follow two methods here. One like yours where ejavac
> is called for a set of java files. See media-sound/jtagger ebuild as an
> example. The other is having a simple build.xml file as in
> dev-java/slf4j-* or dev-java/mina-core. There are numerous examples in
> tree for both methods.
Thanks for these pointers. I had a look at them. I had considered an
ant-based approach myself, but decided against it, because it would be a
bit more difficult to implement, unnecessarily require ant, and give
little benefit over the simple javac-based approach.
I guess once my eclasses are in place, all the simple packages already
in the tree might be converted one by one.
Greetings,
Martin
P.S.: Forgot the list when first sending this, sorry for the duplicate.
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 260 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [gentoo-java] java-pkg-simple and java-mvn-src eclasses
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-02 23:54 ` Alistair Bush
@ 2009-01-03 12:55 ` Martin von Gagern
2 siblings, 0 replies; 8+ messages in thread
From: Martin von Gagern @ 2009-01-03 12:55 UTC (permalink / raw
To: gentoo-java
[-- Attachment #1.1: Type: text/plain, Size: 900 bytes --]
Hi!
After some the replies from Serkan and Alistair, I updated my
java-pkg-simple.eclass. Modifications:
* Inherit only java-utils-2, and have the ebuilds inherit java-pkg-2
* renamed JAVA_DEPEND to JAVA_GENTOO_CLASSPATH in correspondence to
EANT_GENTOO_CLASSPATH, now also allow space-separated items
* Introduced JAVA_SRC_DIR so people can specify directories with sources
* Introduced JAVA_ENCODING to not depend on default locale; default
setting of UTF-8 should fail for non-UTF-8 sources to expose error
* Introduced JAVAC_ARGS and JAVADOC_ARGS for more fine-grained control
* Added QA check to complain if build.xml or pom.xml exists
* Added javadoc and dosrc support
I'd commit the attached file along with an unmodified java-mvn-src and
appropriately modified istack ebuilds to java-experimental if I read no
objections here in the near future.
Greetings,
Martin
[-- Attachment #1.2: java-pkg-simple.eclass --]
[-- Type: text/plain, Size: 6941 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-utils-2
if ! hasq java-pkg-2 ${INHERITED}; then
eerror "java-pkg-simple eclass can only be inherited AFTER java-pkg-2"
fi
# -----------------------------------------------------------------------------
# @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 by putting corresponding files into the target directory
# before calling the src_compile function of this eclass.
# -----------------------------------------------------------------------------
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_GENTOO_CLASSPATH
# @variable-default ""
#
# Comma or space 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_GENTOO_CLASSPATH
# -----------------------------------------------------------------------------
# @variable-external JAVA_SRC_DIR
# @variable-default ""
#
# Directories relative to ${S} which contain the sources of the
# application. The default of "" will be treated mostly as ${S}
# itself. For the generated source package (if source is listed in
# ${JAVA_PKG_IUSE}), it is important that these directories are
# actually the roots of the corresponding source trees.
# -----------------------------------------------------------------------------
# JAVA_SRC_DIR
# -----------------------------------------------------------------------------
# @variable-external JAVA_ENCODING
# @variable-default UTF-8
#
# The character encoding used in the source files
# -----------------------------------------------------------------------------
: ${JAVA_ENCODING:=UTF-8}
# -----------------------------------------------------------------------------
# @variable-external JAVAC_ARGS
# @variable-default ""
#
# Additional arguments to be passed to javac
# -----------------------------------------------------------------------------
# JAVAC_ARGS
# -----------------------------------------------------------------------------
# @variable-external JAVADOC_ARGS
# @variable-default ""
#
# Additional arguments to be passed to javadoc
# -----------------------------------------------------------------------------
# JAVADOC_ARGS
# ------------------------------------------------------------------------------
# @eclass-src_compile
#
# src_compile for simple bare source java packages. Finds all *.java
# sources in ${JAVA_SRC_DIR}, compiles them with the classpath
# calculated from ${JAVA_GENTOO_CLASSPATH}, and packages the resulting
# classes to ${PN}.jar.
#
# variables:
# JAVA_GENTOO_CLASSPATH - list java packages to put on the classpath.
# JAVA_ENCODING - encoding of source files, used by javac and javadoc
# JAVA_SRC_DIR - directories containing source files, relative to ${S}
# JAVAC_ARGS - additional arguments to be passed to javac
# JAVADOC_ARGS - additional arguments to be passed to javadoc
# ------------------------------------------------------------------------------
java-pkg-simple_src_compile() {
local classes=target/classes apidoc=target/apidoc
# QA checks
[[ "$(find . -name build.xml -o -name pom.xml)" ]] &&
java-pkg_announce-qa-violation "Package ships with a build file, use that instead of java-pkg-simple!"
# gather sources
find ${JAVA_SRC_DIR:-*} -name \*.java > sources.lst
mkdir -p ${classes} || die "Could not create target directory"
# compile
local classpath=${classes} atom
for atom in ${JAVA_GENTOO_CLASSPATH}; do
classpath="${classpath}:$(java-pkg_getjars --with-dependencies ${atom})" \
|| die "getjars failed for ${atom}"
done
debug-print "CLASSPATH=${classpath}"
java-pkg-simple_verbose-cmd \
ejavac -d ${classes} -encoding ${JAVA_ENCODING} \
-cp "${classpath}" ${JAVAC_ARGS} @sources.lst
# javadoc
if hasq doc ${JAVA_PKG_IUSE} && use doc; then
mkdir -p ${apidoc}
java-pkg-simple_verbose-cmd \
javadoc -d ${apidoc} \
-encoding ${JAVA_ENCODING} -docencoding UTF-8 -charset UTF-8 \
${JAVADOC_ARGS:- -quiet} @sources.lst || die "javadoc failed"
fi
# package
local jar_args="cf ${PN}.jar"
if [[ -e ${classes}/META-INF/MANIFEST.MF ]]; then
jar_args="cfm ${PN}.jar ${classes}/META-INF/MANIFEST.MF"
fi
java-pkg-simple_verbose-cmd \
jar ${jar_args} -C ${classes} . || die "jar failed"
}
# ------------------------------------------------------------------------------
# @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 classes=target/classes apidoc=target/apidoc
# main jar
java-pkg-simple_verbose-cmd \
java-pkg_dojar ${PN}.jar
# javadoc
if hasq doc ${JAVA_PKG_IUSE} && use doc; then
java-pkg-simple_verbose-cmd \
java-pkg_dojavadoc ${apidoc}
fi
# dosrc
if hasq source ${JAVA_PKG_IUSE} && use source; then
local srcdirs=""
if [[ ${JAVA_SRC_DIR} ]]; then
local parent child
for parent in ${JAVA_SRC_DIR}; do
for child in ${parent}/*; do
srcdirs="${srcdirs} ${child}"
done
done
else
# take all directories actually containing any sources
srcdirs="$(cut -d/ -f1 sources.lst | sort -u)"
fi
java-pkg-simple_verbose-cmd \
java-pkg_dosrc ${srcdirs}
fi
}
# ------------------------------------------------------------------------------
# @internal-function java-pkg-simple_verbose-cmd
#
# Print a command before executing it. To give user some feedback
# about what is going on, where the time is being spent, and also to
# help debugging ebuilds.
#
# @param $@ - command to be called and its arguments
# ------------------------------------------------------------------------------
java-pkg-simple_verbose-cmd() {
echo "$*"
"$@"
}
# ------------------------------------------------------------------------------
# @eclass-end
# ------------------------------------------------------------------------------
[-- 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