-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle.kts
148 lines (129 loc) · 4.92 KB
/
build.gradle.kts
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
plugins {
val kotlinVersion: String by System.getProperties()
val buildconfigVersion: String by System.getProperties()
java
`maven-publish`
signing
kotlin("jvm") version kotlinVersion
id("com.github.gmazzo.buildconfig") version buildconfigVersion
}
val projectGroup: String by project
val jvmVersion: String by project
val junitVersion: String by project
val javaVersion = JavaVersion.toVersion(jvmVersion)
val pluginVersion: String by project
subprojects {
apply(plugin = "java")
apply(plugin = "kotlin")
apply(plugin = "maven-publish")
apply(plugin = "signing")
apply(plugin = "com.github.gmazzo.buildconfig")
group = projectGroup
version = when (project.name) {
"restrikt2-gradle-plugin",
"restrikt2-compiler-plugin" -> pluginVersion
"restrikt2-annotations" -> project.properties["annotationsVersion"]
else -> throw AssertionError("Unknown project name: ${project.name}")
} as String
repositories {
mavenCentral()
}
java {
sourceCompatibility = javaVersion
targetCompatibility = javaVersion
withSourcesJar()
withJavadocJar()
}
kotlin {
jvmToolchain {
languageVersion.set(JavaLanguageVersion.of(javaVersion.majorVersion))
}
}
tasks {
test {
useJUnitPlatform()
}
}
val repositoryUrl = if (version.toString().endsWith("SNAPSHOT")) {
"https://s01.oss.sonatype.org/content/repositories/snapshots/"
} else {
"https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/"
}
publishing {
publications {
create<MavenPublication>("mavenJava") {
from(components["java"])
groupId = project.group.toString()
artifactId = project.name
version = project.version.toString()
pom {
name.set(project.name)
description.set("A compiler plugin to restrict API visibility from Kotlin sources.")
url.set("https://github.com/ZwenDo/${project.name}")
licenses {
license {
name.set("MIT License")
url.set("https://mit-license.org/")
}
}
developers {
developer {
id.set("ZwenDo")
name.set("Lorris Creantor")
email.set("[email protected]")
}
}
scm {
connection.set("scm:git:git://github.com/ZwenDo/${project.name}.git")
developerConnection.set("scm:git:ssh://github.com/ZwenDo/${project.name}.git")
url.set("https://github.com/Zwendo/${project.name}.git")
}
}
}
repositories {
maven {
name = "MavenCentral"
setUrl(repositoryUrl)
credentials {
username = project.properties["ossrhUsername"] as String
password = project.properties["ossrhPassword"] as String
}
}
}
}
}
signing {
sign(publishing.publications)
}
}
val pluginEnabled: String by project
val toplevelPrivateConstructor: String by project
val automaticInternalHiding: String by project
val annotationProcessing: String by project
val hideFromJava: String by project
val hideFromKotlin: String by project
val packagePrivate: String by project
val ignoreDefaultAnnotations: String by project
val ignoreLegacyAnnotations: String by project
fun buildConfigGenericSetup(vararg projects: Project) {
projects.forEach {
it.buildConfig {
buildConfigField("String", "PLUGIN_ID", "\"$projectGroup.${rootProject.name}\"")
buildConfigField("String", "ENABLED", "\"$pluginEnabled\"")
buildConfigField("String", "TOPLEVEL_PRIVATE_CONSTRUCTOR", "\"$toplevelPrivateConstructor\"")
buildConfigField("String", "AUTOMATIC_INTERNAL_HIDING", "\"$automaticInternalHiding\"")
buildConfigField("String", "ANNOTATION_PROCESSING", "\"$annotationProcessing\"")
buildConfigField("String", "HIDE_FROM_JAVA_ANNOTATION", "\"$hideFromJava\"")
buildConfigField("String", "HIDE_FROM_KOTLIN_ANNOTATION", "\"$hideFromKotlin\"")
buildConfigField("String", "PACKAGE_PRIVATE_ANNOTATION", "\"$packagePrivate\"")
buildConfigField("String", "IGNORE_DEFAULT_ANNOTATIONS", "\"$ignoreDefaultAnnotations\"")
useKotlinOutput {
internalVisibility = true
}
}
}
}
buildConfigGenericSetup(
project(":restrikt2-gradle-plugin"),
project(":restrikt2-compiler-plugin"),
)