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