Skip to content

Library update 9 #1163

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jan 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
set(_IS_CLANG_CL_COMPILER
${CMAKE_CXX_COMPILER_ID} STREQUAL Clang
AND "${CMAKE_CXX_COMPILER_FRONTEND_VARIANT}" STREQUAL "MSVC"
AND "${CMAKE_CXX_SIMULATE_ID}" STREQUAL "MSVC"
)
if(${CMAKE_CXX_COMPILER_ID} STREQUAL Clang
AND "${CMAKE_CXX_COMPILER_FRONTEND_VARIANT}" STREQUAL "MSVC"
AND "${CMAKE_CXX_SIMULATE_ID}" STREQUAL "MSVC")

set(_IS_CLANG_CL_COMPILER true)
else()
set(_IS_CLANG_CL_COMPILER false)
endif()

set(_WARNS_ENABLED
4018 # 'expression' : signed/unsigned mismatch
Expand Down
183 changes: 112 additions & 71 deletions build/export_generators/ide-gradle/build.gradle.kts.jinja
Original file line number Diff line number Diff line change
@@ -1,105 +1,152 @@
{%- set mainClassTargets = targets|selectattr("app_main_class") -%}
{%- set publish = targets|selectattr('publish') -%}
{%- set hasJunit5Test = targets|selectattr('junit5_test') -%}
{%- set target0 = targets[0] -%}
{%- set with_kotlin = target0.with_kotlin -%}
{%- set kotlin_version = target0.kotlin_version -%}
plugins {
{% if targets|selectattr("app_main_class") -%}
{%- if mainClassTargets %}
`application`
{% else -%}
{%- else %}
`java-library`
{% endif -%}
{% if targets|selectattr('publish') -%}
{%- endif %}
{%- if publish %}
`maven-publish`
`signing`
{% endif -%}
kotlin("jvm") version "1.8.22"
kotlin("plugin.allopen") version "1.8.22"
{%- endif -%}
{%- if with_kotlin and kotlin_version %}
kotlin("jvm") version "{{ kotlin_version }}"
{%- if target0.with_kotlinc_plugin_allopen %}
kotlin("plugin.allopen") version "{{ kotlin_version }}"
{% endif -%}
{%- if target0.with_kotlinc_plugin_lombok %}
kotlin("plugin.lombok") version "{{ kotlin_version }}"
{% endif -%}
{%- if target0.with_kotlinc_plugin_noarg %}
kotlin("plugin.noarg") version "{{ kotlin_version }}"
{% endif -%}
{%- if target0.with_kotlinc_plugin_serialization %}
kotlin("plugin.serialization") version "{{ kotlin_version }}"
{% endif -%}
{%- endif %}
}
{%- if target0.with_kotlinc_plugin_allopen %}

allOpen {
annotation("org.springframework.stereotype.Component")
}
{% endif -%}
{%- if with_kotlin %}

kotlin {
jvmToolchain(17)
jvmToolchain({%- if target0.required_jdk -%}{{ target0.required_jdk }}{%- else -%}17{%- endif -%})
}
{% endif -%}
{%- if publish %}

{% if targets|selectattr('publish') -%}
group = "{{ targets[0].publish_group }}"
version = project.properties["version"]
group = "{{ target0.publish_group }}"
version = {% if target0.publish_version and target0.publish_version != "no" -%}"{{ target0.publish_version }}"{%- else -%}project.properties["version"]{%- endif %}
{% endif %}

{% endif -%}
repositories {
mavenCentral()
}

configurations {
all {
exclude(group = "ch.qos.logback", module = "logback-classic")
exclude(group = "org.apache.logging.log4j", module = "log4j-to-slf4j")
}
}
val project_root="{%- if exportRoot.startswith(arcadiaRoot + '/') -%}{{ arcadiaRoot }}{%- else -%}{{ exportRoot }}{%- endif -%}"

{% if targets|selectattr("app_main_class") -%}
{% if mainClassTargets -%}
application {
{% for target in targets|selectattr("app_main_class") -%}
{%- for target in mainClassTargets %}
mainClass.set("{{ target.app_main_class }}")
{% endfor -%}
{% endfor -%}
}

{% endif -%}
{% endif -%}
java {
withSourcesJar()
withJavadocJar()
}

{% if target.jar_source_set is defined -%}
{% for source_set in target.jar_source_set -%}
{%- set srcdir, glob = source_set.split(':') -%}
sourceSets.main.java.srcDirs += '{{ srcdir }}'
{% endfor -%}
{% endif -%}
configurations.api {
isTransitive = false
}

dependencies {
{% for target in targets -%}
{% if target.junit5_test -%}
testImplementation("org.junit.jupiter:junit-jupiter:5.8.2")

api("org.apache.commons:commons-math3:3.6.1")

api("com.google.guava:guava:31.0.1-jre")
{% endif -%}
{% for library in target.consumer -%}
{% set classpath = library.classpath -%}
{% if targets|selectattr("app_main_class") -%}
{% if library.excludes.consumer is defined %}
implementation({{ classpath }}) {
{% for exclude in library.excludes.consumer -%}
{% set classpath_parts = exclude.classpath.split(':') -%}
exclude group: '{{ classpath_parts[0] }}', module: '{{ classpath_parts[1] }}'
{% endfor -%}
}
{% else -%}
implementation({{ classpath }})
{% endif -%}
{% elif target.isTest -%}
testImplementation({{ classpath }})
{% else -%}
api({{ classpath }})
{% endif -%}
{% endfor -%}
{% endfor -%}
configurations.implementation {
isTransitive = false
}

{% if targets|selectattr("junit5_test") -%}
tasks.named<Test>("test") {
useJUnitPlatform()
configurations.testImplementation {
isTransitive = false
}

{% endif -%}
{% if hasTest -%}
val testsJar by tasks.registering(Jar::class) {
dependsOn(JavaPlugin.COMPILE_TEST_JAVA_TASK_NAME)
archiveClassifier.set("tests")
from(sourceSets["test"].output)
}

artifacts.add(configurations.create("testArtifacts").name, testsJar)

tasks.test {
testLogging {
showStandardStreams = true
events("passed", "skipped", "failed")
}
}

{% endif -%}

{% for target in targets -%}
{%- if target.jar_source_set is defined -%}
{%- for source_set in target.jar_source_set -%}
{%- set srcdir_glob = split(source_set, ':') -%}
sourceSets.main.java.srcDirs += "{{ srcdir_glob[0] }}"
{% endfor -%}
{%- endif -%}
{%- endfor -%}

dependencies {
{%- for target in targets -%}
{%- for library in target.consumer if library.classpath -%}
{%- if library.prebuilt and library.jar and (library.type != "contrib" or build_contribs) -%}
{%- if target.isTest %}
testImplementation
{%- else %}
implementation
{%- endif -%}(files("$project_root/{{ library.jar }}"))
{%- else -%}
{%- if target.isTest %}
{%- if library.type != "contrib" and library.test2test %}
testImplementation(project(path = ":{{ library.test2test | replace("/", ":") }}", configuration = "testArtifacts"))
{%- else %}
testImplementation({{ library.classpath }})
{%- endif %}
{%- elif library.type != "contrib" %}
implementation({{ library.classpath }})
{%- else %}
api({{ library.classpath }})
{%- endif -%}
{%- if library.excludes.consumer is defined %} {
{% for exclude in library.excludes.consumer if exclude.classpath -%}
{% set classpath = exclude.classpath|replace('"','') -%}
{% set classpath_parts = split(classpath, ':') -%}
exclude(group = "{{ classpath_parts[0] }}", module = "{{ classpath_parts[1] }}")
{% endfor -%}
}
{%- endif -%}
{%- endif -%}
{%- endfor -%}
{%- endfor %}
}

{% if hasJunit5Test -%}
tasks.named<Test>("test") {
useJUnitPlatform()
}

{% endif -%}

{% set runs = targets|selectattr("runs") -%}
{% if runs -%}
{% for run in runs -%}
Expand Down Expand Up @@ -146,15 +193,9 @@ tasks.build.dependsOn(
{% endfor -%}
{% endif -%}

val testsJar by tasks.registering(Jar::class) {
dependsOn(JavaPlugin.COMPILE_TEST_JAVA_TASK_NAME)
archiveClassifier.set("tests")
from(sourceSets["test"].output)
}

artifacts.add(configurations.create("testOutput").name, testsJar)

{% include "extra-tests.gradle.kts" ignore missing %}
{% if targets|selectattr('publish') -%}
{% include 'publish.gradle.kts' -%}
{% if publish -%}
{% include 'publish.gradle.kts' ignore missing -%}
{% endif -%}

{{ dump }}
92 changes: 65 additions & 27 deletions build/export_generators/ide-gradle/build.gradle.kts.proto.jinja
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
{%- set publish = targets|selectattr('publish') -%}
{%- set target0 = targets[0] -%}
import com.google.protobuf.gradle.*

val buildProtoDir = File("${buildDir}", "__proto__")

plugins {
id("java-library")
id("com.google.protobuf") version "0.8.19"
{% if targets|selectattr('publish') -%}
{%- if publish %}
`maven-publish`
`signing`
{% endif -%}
{%- endif -%}
}
{%- if publish %}

{% if targets|selectattr('publish') -%}
group = "{{ targets[0].publish_group }}"
version = project.properties["version"]
{% endif -%}
group = "{{ target0.publish_group }}"
version = {% if target0.publish_version -%}"{{ target0.publish_version }}"{%- else -%}project.properties["version"]{%- endif %}
{%- endif %}

repositories {
mavenCentral()
Expand All @@ -25,15 +27,58 @@ java {
withJavadocJar()
}

configurations.api {
isTransitive = false
}

configurations.implementation {
isTransitive = false
}

configurations.testImplementation {
isTransitive = false
}

{% for target in targets -%}
{%- if target.jar_source_set is defined -%}
{%- for source_set in target.jar_source_set -%}
{%- set srcdir_glob = split(source_set, ':') -%}
sourceSets.main.java.srcDirs += "{{ srcdir_glob[0] }}"
{% endfor -%}
{%- endif -%}
{%- endfor -%}

dependencies {
{% if targets[0].consumer is defined -%}
{%- for library in targets[0].consumer -%}
api({{ library.classpath }})
{% endfor -%}
{%- endif -%}
{%- for target in targets -%}
{%- for library in target.consumer if library.classpath -%}
{%- if library.prebuilt and library.jar and (library.type != "contrib" or target.handler.build_contribs) -%}
{%- if target.isTest %}
testImplementation
{%- else %}
implementation
{%- endif -%}(files("$project_root/{{ library.jar }}"))
{%- else -%}
{%- if target.isTest %}
testImplementation
{%- elif library.type != "contrib" %}
implementation
{%- else %}
api
{%- endif -%}({{ library.classpath }})
{%- if library.excludes.consumer is defined %} {
{% for exclude in library.excludes.consumer -%}
{% set classpath = exclude.classpath|replace('"','') -%}
{% set classpath_parts = split(classpath, ':') -%}
exclude(group = "{{ classpath_parts[0] }}", module = "{{ classpath_parts[1] }}")
{% endfor -%}
}
{%- endif -%}
{%- endif -%}
{%- endfor -%}
{%- endfor %}

{% if targets[0].proto_namespace is defined -%}
protobuf(files(File(buildProtoDir, "{{ targets[0].proto_namespace }}")))
{% if target0.proto_namespace is defined -%}
protobuf(files(File(buildProtoDir, "{{ target0.proto_namespace }}")))
{% else -%}
protobuf(files(buildProtoDir))
{% endif -%}
Expand All @@ -42,18 +87,12 @@ dependencies {
protobuf {
protoc {
// Download from repositories
artifact = "com.google.protobuf:protoc:
{%- if targets[0].proto_compiler_version is defined -%}
{{ targets[0].proto_compiler_version }}
{%- else -%}
3.22.5
{%- endif -%}
"
artifact = "com.google.protobuf:protoc:{%- if target0.proto_compiler_version is defined -%}{{ target0.proto_compiler_version }}{%- else -%}3.22.5{%- endif -%}"
}
{% if targets[0].proto_grpc is defined -%}
{% if target0.proto_grpc is defined -%}
plugins {
id("grpc") {
artifact = "io.grpc:protoc-gen-grpc-java:1.45.0"
artifact = "io.grpc:protoc-gen-grpc-java:{%- if target0.proto_grpc_version -%}{{ target0.proto_grpc_version }}{%- else -%}1.45.0{%- endif -%}"
}
}
generateProtoTasks {
Expand All @@ -68,16 +107,15 @@ protobuf {

val prepareProto = tasks.register<Copy>("prepareProto") {
from(rootDir) {
{% for proto in targets[0].proto_files -%}
{%- for proto in target0.proto_files %}
include("{{ proto }}")
{% endfor -%}
{%- endfor %}
}
into(buildProtoDir)
}

afterEvaluate {
tasks.getByName("extractProto").dependsOn(prepareProto)
}
{% if targets|selectattr('publish') -%}
{% include 'publish.gradle.kts' -%}
{% endif -%}

{{ dump }}
2 changes: 2 additions & 0 deletions build/export_generators/ide-gradle/generator.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use_managed_peers_closure = true

[root]
template="settings.gradle.kts.jinja"
copy=[
Expand Down
Loading