/[gentoo-x86]/eclass/java-ant-2.eclass
Gentoo

Contents of /eclass/java-ant-2.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (hide annotations) (download)
Fri Jul 21 15:31:50 2006 UTC (8 years, 5 months ago) by nichoj
Branch: MAIN
Changes since 1.1: +13 -13 lines
Update to java-ant-2 to use post phase hook instead of the annoying ant_src_unpack. Will warn when ant_src_unpack is used.

1 nichoj 1.1 # eclass for ant based Java packages
2     #
3     # Copyright (c) 2004-2005, Thomas Matthijs <axxo@gentoo.org>
4     # Copyright (c) 2004-2005, Gentoo Foundation
5     #
6     # Licensed under the GNU General Public License, v2
7     #
8    
9     inherit java-utils-2
10    
11     # This eclass provides functionality for Java packages which use
12     # ant to build. In particular, it will attempt to fix build.xml files, so that
13     # they use the appropriate 'target' and 'source' attributes.
14    
15 nichoj 1.2 # We need some tools from javatoolkit. We also need portage 2.1 for phase hooks
16     DEPEND=">=dev-java/javatoolkit-0.1.5 ${JAVA_PKG_PORTAGE_DEP}"
17 nichoj 1.1
18     # ------------------------------------------------------------------------------
19     # @global JAVA_ANT_BSFIX
20     #
21     # Should we attempt to 'fix' ant build files to include the source/target
22     # attributes when calling javac?
23     #
24     # default: on
25     # ------------------------------------------------------------------------------
26     JAVA_ANT_BSFIX=${JAVA_PKG_BSFIX:="on"}
27    
28     # ------------------------------------------------------------------------------
29     # @global JAVA_ANT_BSFIX_ALL
30     #
31     # If we're fixing build files, should we try to fix all the ones we can find?
32     #
33     # default: yes
34     # ------------------------------------------------------------------------------
35     JAVA_ANT_BSFIX_ALL=${JAVA_PKG_BSFIX_ALL:="yes"}
36    
37     # ------------------------------------------------------------------------------
38     # @global JAVA_ANT_BSFIX_NAME
39     #
40     # Filename of build files to fix/search for
41     #
42     # default: build.xml
43     # ------------------------------------------------------------------------------
44     JAVA_ANT_BSFIX_NAME=${JAVA_PKG_BSFIX_NAME:="build.xml"}
45    
46     # ------------------------------------------------------------------------------
47     # @global JAVA_ANT_BSFIX_TARGETS_TAGS
48     #
49     # Targets to fix the 'source' attribute in
50     #
51     # default: javac xjavac javac.preset
52     # ------------------------------------------------------------------------------
53     JAVA_ANT_BSFIX_TARGET_TAGS=${JAVA_PKG_BSFIX_TARGET_TAGS:="javac xjavac javac.preset"}
54    
55     # ------------------------------------------------------------------------------
56     # @global JAVA_ANT_BSFIX_SOURCE_TAGS
57     #
58     # Targets to fix the 'target' attribute in
59     #
60     # default: javacdoc javac xjavac javac.preset
61     # ------------------------------------------------------------------------------
62     JAVA_ANT_BSFIX_SOURCE_TAGS=${JAVA_PKG_BSFIX_SOURCE_TAGS:="javadoc javac xjavac javac.preset"}
63    
64     # ------------------------------------------------------------------------------
65     # @public java-ant_src_unpack
66     #
67     # Unpacks the source, and attempts to fix build files.
68     # ------------------------------------------------------------------------------
69 nichoj 1.2 post_src_unpack() {
70     if java-pkg_func-exists ant_src_unpack; then
71     java-pkg_announce-qa-violation "Using old ant_src_unpack. Should be src_unpack"
72     ant_src_unpack
73     fi
74 nichoj 1.1 java-ant_bsfix
75     }
76    
77     # ------------------------------------------------------------------------------
78     # @private ant_src_unpack
79     #
80     # Helper function which does the actual unpacking
81     # ------------------------------------------------------------------------------
82     # TODO maybe use base.eclass for some patching love?
83 nichoj 1.2 #ant_src_unpack() {
84     # debug-print-function ${FUNCNAME} $*
85     # if [[ -n "${A}" ]]; then
86     # unpack ${A}
87     # fi
88     #}
89 nichoj 1.1
90     # ------------------------------------------------------------------------------
91     # @private java-ant_bsfix
92     #
93     # Attempts to fix build files. The following variables will affect its behavior
94     # as listed above:
95     # JAVA_PKG_BSFIX
96     # JAVA_PKG_BSFIX_ALL
97     # JAVA_PKG_BSFIX_NAME,
98     # JAVA_PKG_BSFIX_SOURCE_TAGS
99     # JAVA_PKG_BSFIX_TARGET_TAGS)
100     # ------------------------------------------------------------------------------
101     java-ant_bsfix() {
102     debug-print-function ${FUNCNAME} $*
103    
104     [[ "${JAVA_PKG_BSFIX}" != "on" ]] && return
105     if ! java-pkg_needs-vm; then
106     echo "QA Notice: Package is using java-ant, but doesn't depend on a Java VM"
107     fi
108    
109     cd "${S}"
110    
111     local find_args="-type f"
112     if [[ "${JAVA_PKG_BSFIX_ALL}" == "yes" ]]; then
113     find_args="${find_args} -name ${JAVA_PKG_BSFIX_NAME// / -o -name }"
114     else
115     find_args="${find_args} -maxdepth 1 -name ${JAVA_PKG_BSFIX_NAME// / -o -name } "
116     fi
117    
118     local i=0
119     local -a bsfix_these
120     while read line; do
121     [[ -z ${line} ]] && continue
122     bsfix_these[${i}]="${line}"
123     let i+=1
124     done <<-EOF
125     $(find ${find_args})
126     EOF
127    
128     local want_source="$(java-pkg_get-source)"
129     local want_target="$(java-pkg_get-target)"
130    
131     debug-print "bsfix: target: ${want_target} source: ${want_source}"
132    
133     if [ -z "${want_source}" -o -z "${want_target}" ]; then
134     eerror "Could not find valid -source/-target values"
135     eerror "Please file a bug about this on bugs.gentoo.org"
136     die "Could not find valid -source/-target values"
137     else
138     for (( i = 0 ; i < ${#bsfix_these[@]} ; i++ )); do
139     local file="${bsfix_these[${i}]}"
140     echo "Rewriting ${file}"
141     debug-print "bsfix: ${file}"
142    
143     cp "${file}" "${file}.orig" || die "failed to copy ${file}"
144    
145     chmod u+w "${file}"
146    
147     xml-rewrite.py -f "${file}" -c -e ${JAVA_PKG_BSFIX_SOURCE_TAGS// / -e } -a source -v ${want_source} || die "xml-rewrite failed: ${file}"
148     xml-rewrite.py -f "${file}" -c -e ${JAVA_PKG_BSFIX_TARGET_TAGS// / -e } -a target -v ${want_target} || die "xml-rewrite failed: ${file}"
149    
150     if [[ -n "${JAVA_PKG_DEBUG}" ]]; then
151     diff -NurbB "${file}.orig" "${file}"
152     fi
153     done
154     fi
155     }

  ViewVC Help
Powered by ViewVC 1.1.20