xref: /aosp_15_r20/external/aws-crt-java/build.gradle.kts (revision 3c7ae9de214676c52d19f01067dc1a404272dc11)
1 /*
2  * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3  * SPDX-License-Identifier: Apache-2.0.
4  *
5  * Helpful resources/examples:
6  * http://gradle.monochromeroad.com/docs/userguide/nativeBinaries.html
7  * https://github.com/NationalSecurityAgency/ghidra/blob/master/Ghidra/Features/Decompiler/build.gradle
8  */
9 
<lambda>null10 plugins {
11     `java-library`
12     `maven-publish`
13 }
14 
<lambda>null15 repositories {
16     mavenLocal()
17     maven {
18         url = uri("https://repo.maven.apache.org/maven2")
19     }
20 }
21 
<lambda>null22 dependencies {
23     testImplementation("junit:junit:4.13.2")
24     testImplementation("commons-cli:commons-cli:1.5.0")
25     testImplementation("org.mockito:mockito-core:3.11.2")
26 }
27 
28 group = "software.amazon.awssdk.crt"
29 version = "1.0.0-SNAPSHOT"
30 description = "software.amazon.awssdk.crt:aws-crt"
31 
<lambda>null32 sourceSets {
33     main {
34         java {
35             setSrcDirs(listOf("src/main/java"))
36         }
37         // include shared libraries built by cmake/CI/CD in the lib folder
38         resources {
39             srcDir("${buildDir}/cmake-build/lib")
40         }
41     }
42     test {
43         java {
44             setSrcDirs(listOf("src/test/java"))
45         }
46     }
47 }
48 
<lambda>null49 java {
50     withJavadocJar()
51     withSourcesJar()
52     sourceCompatibility = JavaVersion.VERSION_1_8
53     targetCompatibility = JavaVersion.VERSION_1_8
54 }
55 
<lambda>null56 tasks.compileJava {
57     dependsOn(":native:cmakeBuild")
58 }
59 
<lambda>null60 tasks.processResources {
61     // sourceSets includes the compiled libs, so declare the dependency
62     dependsOn(":native:cmakeBuild")
63 }
64 
65 // withSourcesJar uses output of task :native:cmakeBuild so explicitly declaring dependency:
<lambda>null66 tasks.named("sourcesJar") {
67     dependsOn(":native:cmakeBuild")
68 }
69 
<lambda>null70 tasks.test {
71     useJUnit()
72     testLogging {
73         events("passed", "skipped", "failed")
74         showExceptions = true
75         showCauses = true
76     }
77     for (prop in listOf("certificate", "privatekey", "endpoint", "rootca", "privatekey_p8")) {
78         if (project.hasProperty(prop)) {
79             systemProperty(prop, project.property(prop).toString())
80         }
81     }
82     //uncomment the next line to attach the debugger to the JNI layer.
83     // systemProperty("aws.crt.debugwait", "1")
84 }
85 
<lambda>null86 tasks.compileTestJava {
87     dependsOn(tasks.compileJava)
88 }
89 
<lambda>null90 publishing {
91 
92     repositories {
93         maven { name = "testLocal"; url = file("${rootProject.buildDir}/m2").toURI() }
94     }
95 
96     publications {
97         create<MavenPublication>("maven") {
98             artifactId = project.name
99             from(components["java"])
100             pom {
101                 name.set(project.name)
102                 description.set(project.description)
103                 url.set("https://github.com/awslabs/aws-crt-java")
104                 licenses {
105                     license {
106                         name.set("The Apache License, Version 2.0")
107                         url.set("http://www.apache.org/licenses/LICENSE-2.0.txt")
108                     }
109                 }
110                 developers {
111                     developer {
112                         id.set("aws-sdk-common-runtime")
113                         name.set("AWS SDK Common Runtime Team")
114                         email.set("[email protected]")
115                     }
116                 }
117                 scm {
118                     connection.set("scm:git:git://github.com/awslabs/aws-crt-java.git")
119                     developerConnection.set("scm:git:ssh://github.com/awslabs/aws-crt-java.git")
120                     url.set("https://github.com/awslabs/aws-crt-java")
121                 }
122             }
123         }
124     }
125     repositories {
126         maven {
127             val releasesRepo = uri("https://aws.oss.sonatype.org/")
128             val snapshotRepo = uri("https://aws.oss.sonatype.org/content/repositories/snapshots")
129             url = if (version.toString().endsWith("SNAPSHOT")) snapshotRepo else releasesRepo
130         }
131     }
132 }
133