xref: /aosp_15_r20/external/jspecify/build.gradle (revision 2167191df2fa07300797f1ac5b707370b5f38c48)
1*2167191dSAndroid Build Coastguard Worker/*
2*2167191dSAndroid Build Coastguard Worker * Copyright 2020 The JSpecify Authors.
3*2167191dSAndroid Build Coastguard Worker *
4*2167191dSAndroid Build Coastguard Worker * Licensed under the Apache License, Version 2.0 (the "License");
5*2167191dSAndroid Build Coastguard Worker * you may not use this file except in compliance with the License.
6*2167191dSAndroid Build Coastguard Worker * You may obtain a copy of the License at
7*2167191dSAndroid Build Coastguard Worker *
8*2167191dSAndroid Build Coastguard Worker *     http://www.apache.org/licenses/LICENSE-2.0
9*2167191dSAndroid Build Coastguard Worker *
10*2167191dSAndroid Build Coastguard Worker * Unless required by applicable law or agreed to in writing, software
11*2167191dSAndroid Build Coastguard Worker * distributed under the License is distributed on an "AS IS" BASIS,
12*2167191dSAndroid Build Coastguard Worker * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13*2167191dSAndroid Build Coastguard Worker * See the License for the specific language governing permissions and
14*2167191dSAndroid Build Coastguard Worker * limitations under the License.
15*2167191dSAndroid Build Coastguard Worker */
16*2167191dSAndroid Build Coastguard Worker
17*2167191dSAndroid Build Coastguard Workerplugins {
18*2167191dSAndroid Build Coastguard Worker    id 'java-library'
19*2167191dSAndroid Build Coastguard Worker    id 'com.diffplug.spotless' version '6.25.0'
20*2167191dSAndroid Build Coastguard Worker    id 'com.github.node-gradle.node' version '7.0.2'
21*2167191dSAndroid Build Coastguard Worker    id 'io.github.gradle-nexus.publish-plugin' version '1.3.0' apply false
22*2167191dSAndroid Build Coastguard Worker    id 'net.ltgt.errorprone' version '3.0.1'
23*2167191dSAndroid Build Coastguard Worker    id "biz.aQute.bnd.builder" version "7.0.0"
24*2167191dSAndroid Build Coastguard Worker}
25*2167191dSAndroid Build Coastguard Worker
26*2167191dSAndroid Build Coastguard Workerext {
27*2167191dSAndroid Build Coastguard Worker    junitVersion = '5.9.3'
28*2167191dSAndroid Build Coastguard Worker    errorproneVersion = '2.20.0'
29*2167191dSAndroid Build Coastguard Worker}
30*2167191dSAndroid Build Coastguard Worker
31*2167191dSAndroid Build Coastguard Workerrepositories { mavenCentral() }
32*2167191dSAndroid Build Coastguard Worker
33*2167191dSAndroid Build Coastguard Workerdef javaVersion = JavaLanguageVersion.of(System.env.JAVA_VERSION ?: 11)
34*2167191dSAndroid Build Coastguard Workerjava.toolchain.languageVersion = javaVersion
35*2167191dSAndroid Build Coastguard Worker
36*2167191dSAndroid Build Coastguard Workerapply from: "gradle/mrjar.gradle"
37*2167191dSAndroid Build Coastguard Workerapply from: "gradle/integration-test.gradle"
38*2167191dSAndroid Build Coastguard Workerapply from: "gradle/format.gradle"
39*2167191dSAndroid Build Coastguard Workerapply from: "gradle/publish.gradle"
40*2167191dSAndroid Build Coastguard Worker
41*2167191dSAndroid Build Coastguard Workerdependencies {
42*2167191dSAndroid Build Coastguard Worker    errorprone "com.google.errorprone:error_prone_core:${errorproneVersion}"
43*2167191dSAndroid Build Coastguard Worker}
44*2167191dSAndroid Build Coastguard Worker
45*2167191dSAndroid Build Coastguard Workerjava {
46*2167191dSAndroid Build Coastguard Worker    if (javaVersion.canCompileOrRun(15)) {
47*2167191dSAndroid Build Coastguard Worker        withJavadocJar()
48*2167191dSAndroid Build Coastguard Worker    }
49*2167191dSAndroid Build Coastguard Worker    withSourcesJar()
50*2167191dSAndroid Build Coastguard Worker
51*2167191dSAndroid Build Coastguard Worker    sourceCompatibility 8
52*2167191dSAndroid Build Coastguard Worker    targetCompatibility 8
53*2167191dSAndroid Build Coastguard Worker    // but compile against newer JDK libraries so that we can use @Target({..., MODULE})
54*2167191dSAndroid Build Coastguard Worker
55*2167191dSAndroid Build Coastguard Worker    tasks.named('sourcesJar') {
56*2167191dSAndroid Build Coastguard Worker        exclude('**.class')
57*2167191dSAndroid Build Coastguard Worker    }
58*2167191dSAndroid Build Coastguard Worker}
59*2167191dSAndroid Build Coastguard Worker
60*2167191dSAndroid Build Coastguard Workertasks.withType(AbstractArchiveTask).configureEach {
61*2167191dSAndroid Build Coastguard Worker    preserveFileTimestamps = false
62*2167191dSAndroid Build Coastguard Worker    reproducibleFileOrder = true
63*2167191dSAndroid Build Coastguard Worker    filePermissions {
64*2167191dSAndroid Build Coastguard Worker        unix('rw-r--r--')
65*2167191dSAndroid Build Coastguard Worker    }
66*2167191dSAndroid Build Coastguard Worker    dirPermissions {
67*2167191dSAndroid Build Coastguard Worker        unix('rwxr-xr-x')
68*2167191dSAndroid Build Coastguard Worker    }
69*2167191dSAndroid Build Coastguard Worker}
70*2167191dSAndroid Build Coastguard Worker
71*2167191dSAndroid Build Coastguard Worker
72*2167191dSAndroid Build Coastguard Workerjar {
73*2167191dSAndroid Build Coastguard Worker    manifest {
74*2167191dSAndroid Build Coastguard Worker        attributes(
75*2167191dSAndroid Build Coastguard Worker                "Bundle-Version": version,
76*2167191dSAndroid Build Coastguard Worker                "Implementation-Version": version
77*2167191dSAndroid Build Coastguard Worker                )
78*2167191dSAndroid Build Coastguard Worker    }
79*2167191dSAndroid Build Coastguard Worker}
80*2167191dSAndroid Build Coastguard Worker
81*2167191dSAndroid Build Coastguard Workerjavadoc {
82*2167191dSAndroid Build Coastguard Worker    options.encoding = 'UTF-8'
83*2167191dSAndroid Build Coastguard Worker}
84*2167191dSAndroid Build Coastguard Worker
85*2167191dSAndroid Build Coastguard Workernode {
86*2167191dSAndroid Build Coastguard Worker    download = true
87*2167191dSAndroid Build Coastguard Worker    nodeProjectDir = file("${project.projectDir}/docs")
88*2167191dSAndroid Build Coastguard Worker}
89*2167191dSAndroid Build Coastguard Worker
90*2167191dSAndroid Build Coastguard Workertasks.register('buildDocs') {
91*2167191dSAndroid Build Coastguard Worker    group 'Build'
92*2167191dSAndroid Build Coastguard Worker    description 'Builds the jspecify.org website.'
93*2167191dSAndroid Build Coastguard Worker    dependsOn('npm_run_build')
94*2167191dSAndroid Build Coastguard Worker    dependsOn('javadoc')
95*2167191dSAndroid Build Coastguard Worker    doLast {
96*2167191dSAndroid Build Coastguard Worker        copy {
97*2167191dSAndroid Build Coastguard Worker            from tasks.named('javadoc')
98*2167191dSAndroid Build Coastguard Worker            into "${project.projectDir}/docs/build/docs/api"
99*2167191dSAndroid Build Coastguard Worker        }
100*2167191dSAndroid Build Coastguard Worker    }
101*2167191dSAndroid Build Coastguard Worker}
102*2167191dSAndroid Build Coastguard Worker
103*2167191dSAndroid Build Coastguard WorkerdefaultTasks 'spotlessApply', 'build'
104