File: indy.gradle

package info (click to toggle)
groovy 2.4.21-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, sid
  • size: 30,708 kB
  • sloc: java: 157,114; xml: 728; sh: 357; makefile: 64; javascript: 15
file content (84 lines) | stat: -rw-r--r-- 2,990 bytes parent folder | download | duplicates (4)
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
/*
 *  Licensed to the Apache Software Foundation (ASF) under one
 *  or more contributor license agreements.  See the NOTICE file
 *  distributed with this work for additional information
 *  regarding copyright ownership.  The ASF licenses this file
 *  to you under the Apache License, Version 2.0 (the
 *  "License"); you may not use this file except in compliance
 *  with the License.  You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing,
 *  software distributed under the License is distributed on an
 *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 *  KIND, either express or implied.  See the License for the
 *  specific language governing permissions and limitations
 *  under the License.
 */
// This file contains support tools for the Gradle build
// with regards to invoke dynamic support (indy)

rootProject.ext.indyCapable = {
    boolean capable = true
    try {
        Class.forName('java.lang.invoke.MethodHandle')
    } catch (e) {
        capable = false
    }

    capable && !rootProject.hasProperty('skipIndy')
}

rootProject.ext.useIndy = {
    boolean indy = false

    // first, check if a system property activates indy support
    indy |= System.hasProperty('indy') && Boolean.valueOf(System.getProperty('indy'))

    // ultimately, check if the main project has an extension property setting indy to true
    // which is the case if the build is started with -Pindy=true or during install/dist tasks
    indy |= rootProject.hasProperty('indy') && (Boolean.valueOf(rootProject.indy))

    indy && rootProject.indyCapable()
}
rootProject.ext.indyBanner = {
    if (project==rootProject && useIndy()) {
        logger.lifecycle '''

         DM .N$?
          $I?7OM.
        .7+?II77MZ       ,:~~
        +I$7O$8?  .M..DMMNNMMNZ.
         ONDOMI.     7MMMMMMOO$I.
         DOM87=      ZMNM8NMI77$.
    .MNDO?$8$?       8MMNMMMN7II.
   MMMO. O$7Z.   OI8?MDNNM$$$$7OM
    M8  ZZ7$.    MMMMMDD7I77I777MMMM.
       ZZ$7$     DMM$N$ZNMZDMODNDM. DD
     .Z$$I$$       .ZI777777II778     ?D.
    8$$7I$I+         .$I7?I7II7D.       ?Z
   .O$$7I$78         N77O+??I?$.          Z
   =7$7777$7 .    .=7NZ?I$7I+$.             O
  ~:7$$7$7D+$~:=Z:=~++77Z$?IIZ~.             N
  $Z$7O8D8=Z8I7==I~I:+~OZ887$MOI$O           .7
  :O$I+~=?:O8?I$=++=:===Z$77ZN++$+~.          Z.
   :7$78ZZZZZ=ZZ$~?==~+DD$8O$OO$7+?:.         $
    .=~=+Z7I7?7I$+~=:~+~O~???77?~+??~         O
        +=IZ7$7OI$=Z:~:~=8I?I?+$Z8++:        N.
          =$+8ZO$$==+=~=?=8$IIIIID$ZZ.      Z

                   INDY ENABLED !
'''

    }
}

if (useIndy()) {
    gradle.taskGraph.whenReady { graph ->
        graph.allTasks.findAll { it instanceof org.gradle.process.JavaForkOptions }.unique().each { task ->
            logger.debug "Adding indy target to project ${task.project.name} task ${task.name}"
            task.systemProperties 'groovy.target.indy': true
        }
    }
}