aboutsummaryrefslogtreecommitdiff
blob: 543aebb76cfc9c33069bba2930c36eb98d6fe599 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
# Copyright 1999-2007 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $

inherit base java-pkg-2 java-ant-2

JAVA_MAVEN_COMMON_DEPS=">=dev-java/javatoolkit-0.2.0-r5"
DEPEND=">=dev-java/javatoolkit-0.2.0-r3 source? ( app-arch/zip )
${JAVA_MAVEN_COMMON_DEPS}"
RDEPEND=">=dev-java/javatoolkit-0.2.0-r3
${JAVA_MAVEN_COMMON_DEPS}"

# We provide two ways to build maven based ebuilds.
# The first is with maven itself
# The second is via generated build.xml by the maven-ant plugin
# to control how to handle it there is two variables
# JAVA_MAVEN_BUILD_SYSTEM :
# possibles values:
# 	eant:  if set use any generated build.xml found.
# 	maven; if set use maven as the builder : TODO implement
#
# For multi projects you can use JAVA_MAVEN_PROJECTS which is a space separated
# list of inner modules to build in a maven multiproject based build.
# Remember to generate all necessary build.xml.
# Normally, doing mvn ant:ant on the parent project is suffisant.
#
# If the generated build.xml doesn't fit to your needs,
# you can use your own build.xml to compile and assembly
# sources by placing it in ${FILESDIR}/build-${PV}.xml.
# eg: doesn't contain any javac target but some is needed,

# For javadoc generation and source bundling,
# you can set JAVA_MAVEN_SRC_DIRS as a comma sepated
# list of java source directories and add "doc" and
# "source" uses in IUSE.

if [[ -n ${JAVA_MAVEN_BUILD_SYSTEM} ]]; then
	if [[ ! ${JAVA_MAVEN_BUILD_SYSTEM} == "eant" ]] && \
		[[ ! ${JAVA_MAVEN_BUILD_SYSTEM} == "maven" ]]; then
		die "Please choose between eant or maven build system."
	fi
fi

# using maven by default
[[ -z ${JAVA_MAVEN_BUILD_SYSTEM} ]] && JAVA_MAVEN_BUILD_SYSTEM="maven"

# If the ebuild is part of maven boostrap, we use only and only ant !
# if this variable is present in an ebuild, dont remove it and
# use don't rely on maven for build the package !
[[ -n ${JAVA_MAVEN_BOOTSTRAP} ]] && JAVA_MAVEN_BUILD_SYSTEM="eant"

# grab maven dependency
if [[ ! ${JAVA_MAVEN_BUILD_SYSTEM} == "eant"  ]]; then
	local  ECLASS_DEP="dev-java/gentoo-void-jar  =dev-java/maven-2*"
	DEPEND="${DEPEND} ${ECLASS_DEP}"
	RDEPEND="${RDEPEND} ${ECLASS_DEP}"
fi


# TO MANUALLY ADD Generated stuff to src/main :
# set the following variable JAVA_MAVEN_ADD_GENERATED_STUFF
# used to facilitate modello and others plugins integration with mvn ant plugin
# - generate sources with a maven installation, compress them
#   to fit in subdirs of src/main/
# - if you want to unpack elsewhere set the variable
#   JAVA_MAVEN_GENERATED_STUFF_UNPACK_DIR to where you want to unpack.
# - name the tarball ${P}-gen-src.tar.bz2
if [[ -n ${JAVA_MAVEN_ADD_GENERATED_STUFF} ]]; then
	MVN_MOD_GEN_SRC="${P}-gen-src.tar.bz2"
	BASE_URL="http://dev.gentooexperimental.org/~kiorky"
	SRC_URI="${BASE_URL}/${P}.tar.bz2 ${BASE_URL}/${MVN_MOD_GEN_SRC} ${SRC_URI}"
fi

JAVA_MAVEN_VERSION=${JAVA_MAVEN_VERSION:=2}
#SLOT="${JAVA_MAVEN_VERSION}"

case "${JAVA_MAVEN_VERSION}" in
	"1")
	JAVA_MAVEN_EXEC="/usr/bin/maven-1"
	;;
	"1.1")
	JAVA_MAVEN_EXEC="/usr/bin/maven-1.1"
	;;
	"2")
	JAVA_MAVEN_EXEC="/usr/bin/mvn"
	;;
esac

JAVA_MAVEN_SYSTEM_HOME="/usr/share/maven-${JAVA_MAVEN_VERSION}/maven_home"

# our pom helper
JAVA_MAVEN_POM_HELPER="/usr/share/javatoolkit/maven-helper.py"

# maven 1 and 1.1 share the same repo
JAVA_MAVEN_SYSTEM_REPOSITORY="/usr/share/maven-${JAVA_MAVEN_VERSION//1.1/1}/maven_home/gentoo-repo"
JAVA_MAVEN_SYSTEM_PLUGINS="${JAVA_MAVEN_SYSTEM_HOME}/plugins"
JAVA_MAVEN_SYSTEM_BIN="${JAVA_MAVEN_SYSTEM_HOME}/bin"

# repo used by maven when running as root
# that s what upstream calls glocal repository, something available for all
# users
JAVA_MAVEN_ROOT_HOME="/usr/share/maven-${JAVA_MAVEN_VERSION}/maven_root"
JAVA_MAVEN_ROOT_REPOSITORY="/usr/share/maven-${JAVA_MAVEN_VERSION//1.1/1}/maven_root/gentoo-repo"
JAVA_MAVEN_ROOT_PLUGINS="${JAVA_MAVEN_ROOT_HOME}/plugins"
JAVA_MAVEN_ROOT_BIN="${JAVA_MAVEN_ROOT_HOME}/bin"

# multiproject
JAVA_MAVEN_MULTIPROJECT_CLASSESPATH="${WORKDIR}/maven_classes"

# Where sources are hold in a maven project
JAVA_MAVEN_SOURCES="src/main/"
JAVA_MAVEN_SRC_DIRS=${JAVA_MAVEN_SRC_DIRS}

# maven build file
POM_XML="pom.xml"

# for patches in src_unpack
# a list of patches ..
JAVA_MAVEN_PATCHES=""

# classpath for build with maven
# same construction as ANT 's one
JAVA_MAVEN_CLASSPATH=""

# Filename where to store original poms for history
JAVA_MAVEN_POMS_TARBALL="${WORKDIR}/poms.tbz2"
JAVA_MAVEN_ORIGINAL_POMS_DIR="${WORKDIR}/${PN}_poms"

#shortcut variable
JAVA_MAVEN_PN_SLOT="${PN}"

# maven launcher function
# first, we rewrite pom.xml release-pom.xml in the current dir
# and in parent dir if this is a child pom.
# Please do not put in extra args  some -f arg as we rewrite
# poms not to use maven dependencies.
# Goal is to feed maven with our classpath, set source/target versions
# and desactivate its own dependencies.
# Also, use profile with caution for the same reason !
emaven() {
	# make maven knows we call it from portage
	local maven_flags="fromportage"

	# finnaly launch maven
	${JAVA_MAVEN_EXEC} ${maven_flags} "${@}" || die "maven failed"
}


# calculate pn_slot
java-maven-2_get_pn_slot() {
	if [[ ! "${SLOT}" == "0" ]] && [[ ! -z "${SLOT}" ]]; then
		JAVA_MAVEN_PN_SLOT="${PN}-${SLOT}"
	fi
	echo ${JAVA_MAVEN_PN_SLOT}
}


# rewrite poms to be portage friendly :p
# take poms as args
java-maven-2_rewrite_poms() {
	local want_source="$(java-pkg_get-source)"
	local want_target="$(java-pkg_get-target)"
	local gcp=""

	# parse cli args
	local poms=""
	for pom in ${@};do
		[[ -f ${pom} ]] && poms="${poms} ${pom}"
	done

	# generate classpath
	for atom in ${JAVA_MAVEN_CLASSPATH}; do
		gcp="${gcp}:$(java-pkg_getjars ${atom})"
	done

	local rewritten_poms=""
	local current_poms=""
	# rewrite current and parent if any
	for pom in ${poms};do
		current_poms="${pom}"
		# adding parent pom
		for pomname in "pom.xml" "release-pom.xml";do
			if [[ -f "$(dirname ${pom})/../${pomname}" ]];then
				# getting an absolute path !
				pushd "$(dirname ${pom})/.."  >> /dev/null || die
				current_poms="${current_poms} $(pwd)/${pomname}"
				popd >> /dev/null || die
			fi
		done
		# removing allready rewritten stuff
		#einfo $rewritten_poms
		for i in $rewritten_poms;do
			local rewritten_pom=${i//\//\\\/}
			current_poms="${current_poms//$rewritten_pom/}"
		done
		#einfo $current_poms
		rewritten_poms="${rewritten_poms} ${current_poms}"
	done
	# finnaly that we have got all poms, eliminated doublons, we can rewrite the
	# whole just once :)
	#einfo $rewritten_poms
	for current_pom  in $rewritten_poms; do
		if [[ -f "${current_pom}" ]];then
			cp -f "${current_pom}" "${current_pom}.sav" || die
			einfo "Rewriting ${current_pom//${WORKDIR}\//}"
			${JAVA_MAVEN_POM_HELPER} -r \
			-c "${gcp}" \
			-s "${want_source}" \
			-t "${want_target}" \
			-f "${current_pom}" || die "failed rewriting ${current_pom}"
		fi
	done
}

# in case we re using maven1, we will need to generate
# a build.xml to apply our classpath
java-maven-2-gen_build_xml() {
	# generate build.xml whereever there is a project.xml
	for project in $(find "${WORKDIR}" -name project*xml);do
		cd "$(dirname ${project})" || die
		emaven ant:ant\
		|| die "Generation of build.xml failed for ${project}"
	done
}


# take a list of patch as arguments
java-maven-2_src_unpack() {
	if  ! has_version ">=dev-java/javatoolkit-0.2.0-r2"; then
		die "please upgrade to at least dev-java/javatoolkit-0.2.0-r2"
	fi

	# unpack time.
	if [[ -z "${JAVA_MAVEN_ADD_GENERATED_STUFF}" ]]; then
		base_src_unpack
	else
		# only unpack base tarball, we unpack generated stuff later
		unpack "${P}.tar.bz2"
	fi

	# patch if neccessary
	if [[ -n "${JAVA_MAVEN_PATCHES}" ]]; then
		for i in ${JAVA_MAVEN_PATCHES};do
			[[ -f "${i}" ]] && epatch ${i}
		done
	fi

	# if build.xml are present we suppose they re generated from maven pom
	# then we rewrite them, see the rewrite function
	if [[ ${JAVA_MAVEN_BUILD_SYSTEM} == "eant" ]]; then
		# if present using specific build.xml
		if [[ -f "${FILESDIR}/build-${PV}.xml" ]]; then
			cp "${FILESDIR}/build-${PV}.xml" "${S}/build.xml" || die
		fi
		# specific to modello based ebuild
		# eventually copy build.xml from filesdir then unpack pre-generated sources.
		if [[ -n "${JAVA_MAVEN_ADD_GENERATED_STUFF}" ]]; then
			if [[ ! -d "${S}/src/main" ]]; then
				mkdir -p "${S}/src/main" || die
			fi
			cd "${JAVA_MAVEN_GENERATED_STUFF_UNPACK_DIR:-${S}/src/main}" || die
			unpack "${MVN_MOD_GEN_SRC}"
		fi
		for build in $(find "${WORKDIR}" -name build.xml || die);do
			pushd "$(dirname ${build} || die )" > /dev/null || die
			# make specials dir and put generated stuff in there
			local maven_group="" maven_artifact="" maven_version="" maven_dest_dir=""
			if [[ -f "${POM_XML}" ]]; then
				maven_group=$(${JAVA_MAVEN_POM_HELPER}     -g -f ${POM_XML})
				maven_group="${maven_group//*:/}"
				maven_artifact=$(${JAVA_MAVEN_POM_HELPER}  -a -f ${POM_XML})
				maven_artifact="${maven_artifact//*:}"
				maven_version=$(${JAVA_MAVEN_POM_HELPER}   -v -f ${POM_XML})
				maven_version=${maven_version//*:/}
				maven_dest_dir="src/main/resources/META-INF/maven/${maven_group}/${maven_artifact}"
				maven_pom_properties="${maven_dest_dir}/pom.properties"
				mkdir -p "${maven_dest_dir}" || die
				cp ${POM_XML} "${maven_dest_dir}" || die
				# fake properties
				echo "#Generated by Maven" > ${maven_pom_properties}
				echo "#$(date  +"%a %b %d %H:%M:%S %Z %Y")" >> ${maven_pom_properties}
				echo "version=${maven_version}" >> ${maven_pom_properties}
				echo "groupId=${maven_group}" >> ${maven_pom_properties}
				echo "artifactId=${maven_artifact}" >> ${maven_pom_properties}
			fi
			popd > /dev/null || die
		done
	fi

	# * rewrite poms to adapt dependency stuff to our system.
	#
	# * set default source directories and javadoc input directories
	#  maven projects may not contain java sources or maybe
	#  in a non-standart place, in this case
	#  please use JAVA_ANT_JAVADOC_INPUT_DIRS directly
	cd ${S} || die
	for project in ${JAVA_MAVEN_PROJECTS} ./;do
		# rewrite poms
		pushd "${project}" >> /dev/null || die
		for localpom in "${POM_XML}" "release-pom.xml"; do
			if [[ -f "${localpom}" ]]; then
				# backup the original before rewritting !
				cp "${localpom}" "${localpom}.sav"
				# java-maven-2_rewrite_poms ${localpom}
				localregisteredpom="${localregisteredpom} $(pwd)/${localpom}"
			fi
		done
		popd >> /dev/null || die

		# add src dirs
		if [[ -d "${S}/${project}/${JAVA_MAVEN_SOURCES}/java" ]]; then
			JAVA_MAVEN_SRC_DIRS="${JAVA_MAVEN_SRC_DIRS} ${S}/${project//.\//}/${JAVA_MAVEN_SOURCES}/java"
		fi
	done

	if hasq doc ${IUSE} && use doc; then
		JAVA_ANT_JAVADOC_INPUT_DIRS="${JAVA_ANT_JAVADOC_INPUT_DIRS} ${JAVA_MAVEN_SRC_DIRS}"
	fi
	# now rewriting all the poms
	java-maven-2_rewrite_poms ${localregisteredpom}

	# create temporary class output for classpath and interdeps
	# for multi project based maven ebuilds.
	if [[ -n "${JAVA_MAVEN_PROJECTS}" ]]; then
		mkdir -p "${JAVA_MAVEN_MULTIPROJECT_CLASSESPATH}" || die
	fi

	# disabling bsfix auto-call as wa need to call it with our maven args.
	JAVA_PKG_BSFIX="off"
}

java-maven-2_src_compile_from_build_xml() {
	# compile order
	EANT_BUILD_TARGET="clean compile jar"

	# remove maven predefined depends to let us control the build
	# steps (order, and not use external jars)
	JAVA_ANT_BSFIX_EXTRA_ARGS="${JAVA_ANT_BSFIX_EXTRA_ARGS} --maven-cleaning"

	# set classpath for eant
	EANT_GENTOO_CLASSPATH="${EANT_GENTOO_CLASSPATH} ${JAVA_MAVEN_CLASSPATH}"

	# javadoc is controlled as in ant builds, see ant eclass.
	if [[ -n "${JAVA_MAVEN_PROJECTS}" ]]; then
		# use our own classpath and append it tempory classes path in case of maven
		# multiproject
		JAVA_ANT_BSFIX_EXTRA_ARGS="${JAVA_ANT_BSFIX_EXTRA_ARGS} -s ${JAVA_MAVEN_MULTIPROJECT_CLASSESPATH}"
		for module in ${JAVA_MAVEN_PROJECTS};do
			einfo "Compiling module: ${module}"
			pushd "${module}" >> /dev/null || die
			[[ -f build.xml ]] && java-ant_bsfix_files build.xml
			java-pkg-2_src_compile
			# need to unset unless bsfix will just die after the first call as
			# EANT_DOC_TARGET cannot be set if JAVA_ANT_JAVADOC_INPUT_DIRS is
			# set.
			EANT_DOC_TARGET=""
			# if we compilked something, copy resulted classes in our shareproject classes path
			if [[ -d target/classes ]]; then
				for i in $(ls -1 target/classes);do
					#can be file or dir !
					cp -rf "target/classes/${i}"  "${JAVA_MAVEN_MULTIPROJECT_CLASSESPATH}" || die
				done
			fi
			popd >> /dev/null || die
		done
	fi

	if [[ -z "${JAVA_MAVEN_PROJECTS}" ]]; then
		[[ -f build.xml ]] && java-ant_bsfix_files build.xml
		java-pkg-2_src_compile
	fi

}

java-maven-2_src_compile() {
	einfo "Building with ${JAVA_MAVEN_BUILD_SYSTEM}"
	if [[  "${JAVA_MAVEN_BUILD_SYSTEM}" == "eant" ]]; then
		java-maven-2_src_compile_from_build_xml
	fi
}

#java-maven-2_src_test() {
# there isnt any maven running out there for the moment
#	emaven test || die "Tests failed"
#}

# do md5sum and sha1sum of a specified file in maven format
java-maven-2_do_sig() {
	if [[ -f "${1}" ]]; then
		local input_file=$(basename $1)
		md5sum  "${1}" | awk '{print $1}' > "${input_file}.md5"
		sha1sum "${1}" | awk '{print $1}' > "${input_file}.sha1"
	else
		die "please specify input file"
	fi
}

# do signatures and install into maven repository
# first arguement is inner repository directory where the files goes
# it must be created before calling this funcion.
# second argument is the file itself
java-maven-2_install_file_into_repo() {
	local rep_dir="${1//\/\//\/}" \
	input_file="${2}" \
	dest_dir="${D}${rep_dir}"
	# remove double slash
	dest_dir=${dest_dir//\/\//\/}
	[[ ! -d "${dest_dir}" ]] && die "Directory in repository doesn't exist"
	[[ ! -e "${input_file}" ]] && die "Input file doesn't exists"
	java-maven-2_do_sig  "${input_file}"
	insinto "${rep_dir}"
	# in case of jar, do not try to install them as the symlink to the real jar
	# is allready done
	if [[ ! -e "${dest_dir}/${input_file}" ]] ;then
		doins "${input_file}"
	fi
	if [[ ! -e "${dest_dir}/${input_file}.md5" ]] ;then
		doins "${input_file}.md5"
	fi
	if [[ ! -e "${dest_dir}/${input_file}.sha1" ]] ;then
		doins "${input_file}.sha1"
	fi
}

# if repositories are not created yet, create them
java-maven-2_ensure_repo_exists() {
	if [[ ! -d "${JAVA_MAVEN_SYSTEM_REPOSITORY}" ]]; then
		keepdir "${JAVA_MAVEN_SYSTEM_HOME}"
		keepdir "${JAVA_MAVEN_SYSTEM_PLUGINS}"
		keepdir "${JAVA_MAVEN_SYSTEM_REPOSITORY}"
	fi
}

# get versionnated name of a pom taking ${POM_XML} as default
java-maven-2_get_name() {
	local pom="$(java-maven-2_verify_pom ${1})"
	local name="" maven_artifact="" maven_version=""
	maven_artifact="$(${JAVA_MAVEN_POM_HELPER}  -a -f ${pom})"
	maven_artifact="${maven_artifact//*:}"
	maven_version="$(${JAVA_MAVEN_POM_HELPER}   -v -f ${pom})"
	maven_version="${maven_version//*:/}"
	name="${maven_artifact}"
	[[ -n "${maven_version}" ]] && name="${maven_artifact}-${maven_version}"
	echo ${name}
}

# return the directory into the repo where will be installed all stuff of a
# specified pom.
# take a pom in input or ${POM_XML} as default
java-maven-2_get_repo_dir() {
	local pom="$(java-maven-2_verify_pom ${1})"
	local maven_group="" maven_artifact="" maven_version=""
	maven_group=$(${JAVA_MAVEN_POM_HELPER}     -g -f ${pom})
	maven_group="${maven_group//*:}"
	maven_artifact=$(${JAVA_MAVEN_POM_HELPER}  -a -f ${pom})
	maven_artifact="${maven_artifact//*:}"
	maven_version=$(${JAVA_MAVEN_POM_HELPER}   -v -f ${pom})
	maven_version=${maven_version//*:/}
	# returning in our faked repository directory
	echo "${JAVA_MAVEN_SYSTEM_REPOSITORY}/${maven_group//.//}/${maven_artifact}/${maven_version}"
}

# return ${POM_XML} or arg1 if arg1 is given and is a pom
java-maven-2_verify_pom() {
	local pom="${1}"
	[[ ! -f "${1}" ]] && pom="${POM_XML}"
	[[ ! -f "${pom}" ]] && die "${pom} is not a valid pom"
	echo ${pom}
}

# prepare to a file in a repository
# all jar installed will be symlink and real location
# will be in /usr/share/PN_SLOT/lib as usual
# don't forget to cd to pom dir before calling
#  * take a maven pom as input and use ${POM_XML} as default pom.
java-maven-2_install_one() {
	local pom="$(java-maven-2_verify_pom ${1})"
	local rep_dir="$(java-maven-2_get_repo_dir ${pom})"
	local myname="$(java-maven-2_get_name ${pom})"
	local myjar="${myname}.jar"
	local maven_pom="${myname}.pom" maven_artifact=""
	local poms_tarball="poms.tbz2"

	if [[ -f "${pom}" ]]; then
		if [[ -n "${rep_dir}" ]]; then
			dodir "${rep_dir}"
			# install jar if existing
			if [[ -f  "target/${myjar}" ]]; then
				# get a non versionnated name for our jar
				maven_artifact="$(${JAVA_MAVEN_POM_HELPER}  -a -f ${pom})"
				maven_artifact="${maven_artifact//*:}"
				java-pkg_newjar "target/${myjar}" "${maven_artifact}.jar"
			fi
			if [[ -n "${maven_artifact}" ]]; then
				# if it is not allready done ...
				if [[ ! -e "${D}${rep_dir}/${maven_artifact}.jar" ]] \
					&& [[ -f "target/${myjar}" ]]; then
					# ... symlink our jar in the maven repo
					dosym \
					"/usr/share/${JAVA_MAVEN_PN_SLOT}/lib/${maven_artifact}.jar" \
					"${rep_dir}/${myjar}"
					# install jar in repo
					# use the target jar instead one in /usr/share/pnslot/lib
					# to allow dosig to generate the right name and version
					pushd target >> /dev/null || die
					java-maven-2_install_file_into_repo "${rep_dir}" "${myjar}"
					popd >> /dev/null || die
				fi
			fi
			# install REWRITTEN pom in repo
			cp "${pom}" "${maven_pom}" || die
			java-maven-2_install_file_into_repo ${rep_dir} ${maven_pom}
			# install originals pom in packages dir for history
			local pomstosave=""
			for localpom in "${pom}" "release-pom.xml"; do
				if [[ -f "${localpom}.sav" ]];then
					 pomstosave="${pomstosave} ${localpom}"
				 fi
			done
			if [[ -n ${pomstosave} ]]; then
				# in case there are multiple poms
				if [[ ! -d "${JAVA_MAVEN_ORIGINAL_POMS_DIR}"  ]]; then
					mkdir "${JAVA_MAVEN_ORIGINAL_POMS_DIR}" || die
				fi
				for localpom in ${pomstosave};do
					dir="$(pwd)"
					mkdir -p "${JAVA_MAVEN_ORIGINAL_POMS_DIR}/${myname}" || die
					cp -f "${localpom}.sav"	\
					"${JAVA_MAVEN_ORIGINAL_POMS_DIR}/${myname}/${localpom}" || die
				done
			fi
		fi
	fi
}

# basic src_install which can install in most cases (multi and single project
# mode)
java-maven-2_src_install() {
	hasq doc ${IUSE} && use doc \
	&& [[ -n "${JAVA_ANT_JAVADOC_INPUT_DIRS}" ]] \
	&& java-pkg_dojavadoc ${JAVA_ANT_JAVADOC_OUTPUT_DIR}
	if hasq source ${IUSE} && use source; then
		for dir in ${JAVA_MAVEN_SRC_DIRS};do
			[[ -d "${dir}" ]] && java-pkg_dosrc ${dir}
		done
	fi

	# install all subprojects
	# then  either install parent pom in multi-projects mode
	# or just install in single project mode
	# ensure to be in ${S} if ${S} is not workdir for some ebuilds (example
	# doxia)
	cd "${S}" || die
	for module in ${JAVA_MAVEN_PROJECTS} $([[ "${S}" != "$WORKDIR" ]] && echo "${S}");do
		pushd "${module}" >> /dev/null || die "pushd into $module failed"
		java-maven-2_install_one
		popd >> /dev/null || die "popd out of  $module failed"
	done

	# if we have some orginal poms, save them
	if [[ -d "${JAVA_MAVEN_ORIGINAL_POMS_DIR}"  ]]; then
		cd  "${JAVA_MAVEN_ORIGINAL_POMS_DIR}/.." || die
		# getin' relative path to not have crappy path in the tar file!
		tar cjf "${JAVA_MAVEN_POMS_TARBALL}" \
		"${JAVA_MAVEN_ORIGINAL_POMS_DIR//*\//}"
		if [[ -f "${JAVA_MAVEN_POMS_TARBALL}" ]]; then
			dodir "/usr/share/$(java-maven-2_get_pn_slot)/poms"
			insinto "/usr/share/$(java-maven-2_get_pn_slot)/poms"
			doins "${JAVA_MAVEN_POMS_TARBALL}"
		fi
	fi
}

EXPORT_FUNCTIONS src_unpack src_compile src_install