(fix) IntelliJ IDEA support & (actually) Fix removing compiled protos

This commit is contained in:
KingRainbow44
2023-11-26 00:17:33 -05:00
parent 5930270e55
commit 0ec6117bc5

View File

@@ -17,6 +17,7 @@ plugins {
id 'com.google.protobuf' version '0.8.19' id 'com.google.protobuf' version '0.8.19'
id 'eclipse' id 'eclipse'
id 'idea'
} }
compileJava.options.encoding = "UTF-8" compileJava.options.encoding = "UTF-8"
@@ -25,6 +26,11 @@ compileTestJava.options.encoding = "UTF-8"
sourceCompatibility = JavaVersion.VERSION_17 sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17 targetCompatibility = JavaVersion.VERSION_17
var shouldGenerateProto = System.getenv("GENERATE_PROTO") == "true"
System.out.println(shouldGenerateProto ?
"Generating proto files" :
"Skipping proto generation")
repositories { repositories {
mavenCentral() mavenCentral()
jcenter() jcenter()
@@ -34,13 +40,13 @@ protobuf {
protoc { protoc {
artifact = 'com.google.protobuf:protoc:3.24.3' artifact = 'com.google.protobuf:protoc:3.24.3'
} }
plugins { plugins {
quickbuf { quickbuf {
artifact = 'us.hebi.quickbuf:protoc-gen-quickbuf:1.3.1' artifact = 'us.hebi.quickbuf:protoc-gen-quickbuf:1.3.1'
} }
} }
if (System.getenv("GENERATE_PROTO") == "true") {
generateProtoTasks { generateProtoTasks {
all().each { task -> all().each { task ->
task.builtins { task.builtins {
@@ -54,7 +60,6 @@ protobuf {
} }
} }
} }
}
generatedFilesBaseDir = "$projectDir/src/generated/" generatedFilesBaseDir = "$projectDir/src/generated/"
} }
@@ -143,6 +148,15 @@ sourceSets {
} }
} }
idea {
module {
// proto files and generated Java files are automatically added as
// source dirs.
// If you have additional sources, add them here:
sourceDirs += file('/proto/')
}
}
eclipse { eclipse {
classpath { classpath {
file.whenMerged { cp -> file.whenMerged { cp ->
@@ -172,7 +186,11 @@ public final class BuildConfig {
task updateProto { task updateProto {
group 'Build' group 'Build'
description 'Cleans generated proto folder and regenerates protos' description 'Cleans generated proto folder and regenerates protos'
if (shouldGenerateProto) {
dependsOn 'clean' dependsOn 'clean'
}
dependsOn 'generateProto' dependsOn 'generateProto'
} }