aboutsummaryrefslogtreecommitdiff
blob: a4d1bac09f2abb55ebf8382a58a2f973b5ae72d5 (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
#!/usr/bin/env bash
source /etc/java-ebuilder.conf

clean-maven() {
    rm -f "${CACHEDIR}"/maven-cache
    rm -rf "${MAVEN_OVERLAY_DIR}"/app-maven
}

clean-pom() {
    rm -f "${POMDIR}"/*.pom
}

clean-cache() {
    rm -f "${CACHEDIR}"/cache.{raw,}{0,1}
    rm -f "${CACHEDIR}"/b{ebd,pom}
}

clean() {
    clean-cache
    clean-pom
    clean-maven
}

build() {
    : ${PORTDIR:=$(portageq get_repo_path $(portageq envvar EROOT) gentoo)}
    : ${PORTAGE_TMPDIR:=$(portageq envvar PORTAGE_TMPDIR)}
    export PORTAGE_TMPDIR

    if [[ ! -f "${CACHEDIR}"/cache.0 ]]; then
        # 1. Generate cache of java related packages from portage tree.
        [[ -f "${CACHEDIR}"/cache.raw0 ]] || \
            java-ebuilder --refresh-cache -t "${PORTDIR}" --cache-file "${CACHEDIR}"/cache.raw0

        # 2. Find corresponding maven groupId, artifactId and version in the cache.
        pushd "${CACHEDIR}" > /dev/null
        ( echo 1.0; tail -n +2 cache.raw0 | parallel -j -1 /usr/lib/java-ebuilder/meta.sh; ) > cache.0
        popd > /dev/null
    fi

    # do the same to java overlay
    if [[ ! -f "${CACHEDIR}"/cache.1 ]]; then
        if [[ -n "${JAVA_OVERLAY_DIR}" ]]; then
            [[ -f "${CACHEDIR}"/cache.raw1 ]] || \
                java-ebuilder --refresh-cache -t "${JAVA_OVERLAY_DIR}" --cache-file "${CACHEDIR}"/cache.raw1
            pushd "${CACHEDIR}" > /dev/null
            tail -n +2 cache.raw1 | parallel -j -1 /usr/lib/java-ebuilder/meta.sh > cache.1
            popd > /dev/null
        else
            touch "${CACHEDIR}"/cache.1
        fi
    fi

    for M in ${MAVEN_ARTS}; do
        /usr/lib/java-ebuilder/tree.sh ${M}
    done

    ls -1 "${MAVEN_OVERLAY_DIR}"/app-maven/*/*.ebuild | parallel ebuild {} digest
}

if [[ $# -gt 0 ]]; then
    funcs=$@
else
    funcs=build
fi

for func in ${funcs}; do
    ${func}
done