Skip to content

Commit d2f9212

Browse files
authored
Release 2.0.0
2 parents f3b82de + a452edf commit d2f9212

10 files changed

Lines changed: 172 additions & 239 deletions

File tree

README.md

Lines changed: 4 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,9 @@
22
This repository contains tools which simplify using PrivMX libraries in JVMs.
33

44
## privmx-endpoint-install-native
5-
The `com.simplito.privmx-endpoint-install-native` Gradle plugin automates the process of downloading
6-
and installing shared libraries for PrivMX Endpoint Java from [GitHub releases](https://github.com/simplito/privmx-endpoint-java/releases) assets
7-
into the module directory with version specified in `privmxEndpointInstallJni` task configuration.
8-
The downloaded libraries are installed in the `src/main/jniLibs` directory of your module.
9-
10-
## Options
11-
12-
### `version` (required)
13-
The version of the native shared libraries to download.
14-
15-
`public String version`
16-
17-
18-
### `platforms` (optional)
19-
A list of platforms (as a pair of operating system and architecture) for which to download the native shared library.
20-
The default is the building platform.
21-
22-
`public List<PrivmxEndpointPlatform> platforms`
23-
5+
The Gradle plugin automates the process of downloading native libraries artifacts and attaching
6+
them to `runtimeClasspath`. This plugin supports `com.simplito.java:privmx-endpoint` and
7+
`com.simplito.kotlin:privmx-endpoint` modules in **Java**, **Android** and **Kotlin** projects.
248

259
## Usage
2610

@@ -38,26 +22,11 @@ pluginManagement {
3822

3923
```groovy
4024
plugins {
41-
def pluginVersion = "1.1"
25+
def pluginVersion = "2.0.0"
4226
id "com.simplito.privmx-endpoint-install-native" version "$pluginVersion"
4327
}
4428
```
4529

46-
3. Configure plugin in `build.gradle`:
47-
48-
```groovy
49-
privmxEndpointInstallJni{
50-
version = $nativeLibVersion // Set the version of library to download, it should
51-
// match the privmx-endpoint-java dependency version
52-
53-
// Set project supported platforms to download native libraries for them.
54-
platforms = [
55-
SupportedPlatforms.Darwin.arm64.platform,
56-
*SupportedPlatforms.Android.values().platform
57-
]
58-
}
59-
```
60-
6130
## License information
6231

6332
PrivMX Endpoint Install Native. \

gradle/libs.versions.toml

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,11 @@
11
[versions]
22
agp = "8.6.0-alpha01"
3-
kotlin = "1.9.0"
4-
coreKtx = "1.13.1"
3+
kotlin = "2.2.0"
54
junit = "4.13.2"
6-
junitVersion = "1.1.5"
7-
espressoCore = "3.5.1"
8-
appcompat = "1.7.0"
9-
material = "1.12.0"
10-
jetbrainsKotlinJvm = "1.9.0"
5+
jetbrainsKotlinJvm = "2.2.0"
116

127
[libraries]
13-
androidx-core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "coreKtx" }
148
junit = { group = "junit", name = "junit", version.ref = "junit" }
15-
androidx-junit = { group = "androidx.test.ext", name = "junit", version.ref = "junitVersion" }
16-
androidx-espresso-core = { group = "androidx.test.espresso", name = "espresso-core", version.ref = "espressoCore" }
17-
androidx-appcompat = { group = "androidx.appcompat", name = "appcompat", version.ref = "appcompat" }
18-
material = { group = "com.google.android.material", name = "material", version.ref = "material" }
199

2010
[plugins]
2111
android-application = { id = "com.android.application", version.ref = "agp" }
Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,40 @@
1+
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
2+
13
plugins {
24
id("com.gradle.plugin-publish") version "1.2.1"
35
id("signing")
46
alias(libs.plugins.jetbrains.kotlin.jvm)
57
}
68

79
//Apply script for publishing maven dependency
8-
//if (file("build-publish-maven.gradle.kts").exists()) {
10+
if (file("build-publish-maven.gradle.kts").exists()) {
911
apply(from = project.file("build-publish-maven.gradle.kts"))
10-
//}
12+
}
13+
1114
dependencies {
1215
implementation(gradleApi())
13-
implementation("de.undercouch:gradle-download-task:5.6.0")
16+
compileOnly("com.android.tools.build:gradle:8.11.0")
17+
compileOnly("org.jetbrains.kotlin:kotlin-gradle-plugin:2.2.0")
1418
testImplementation(libs.junit)
1519
}
1620

17-
version = "1.1"
21+
version = "2.0.0"
1822
gradlePlugin {
1923
plugins {
2024
this.create("privmx-endpoint-install-native") {
2125
displayName = "privmx-endpoint-install-native"
2226
id = "com.simplito.privmx-endpoint-install-native"
2327
implementationClass =
24-
"com.simplito.tools.gradle.privmx_endpoint_install_native.PrivmxEndpointInstallNativePlugin"
28+
"com.simplito.tools.gradle.privmx_endpoint_install_native.PrivmxEndpointNativePlugin"
2529
}
2630
}
2731
}
2832

2933
kotlin {
30-
jvmToolchain(11)
31-
}
34+
compilerOptions{
35+
jvmTarget = JvmTarget.JVM_11
36+
}
37+
}
38+
java{
39+
targetCompatibility = JavaVersion.VERSION_11
40+
}

privmx-endpoint-install-native/src/main/java/com/simplito/tools/gradle/privmx_endpoint_install_native/PrivmxEndpointInstallNativePlugin.kt

Lines changed: 0 additions & 33 deletions
This file was deleted.

privmx-endpoint-install-native/src/main/java/com/simplito/tools/gradle/privmx_endpoint_install_native/PrivmxEndpointInstallNativeTask.kt

Lines changed: 0 additions & 89 deletions
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
//
2+
// PrivMX Endpoint Install Native.
3+
// Copyright © 2025 Simplito sp. z o.o.
4+
//
5+
// This file is part of the PrivMX Platform (https://privmx.dev).
6+
// This software is Licensed under the MIT License.
7+
//
8+
// See the License for the specific language governing permissions and
9+
// limitations under the License.
10+
//
11+
12+
package com.simplito.tools.gradle.privmx_endpoint_install_native
13+
14+
import com.android.build.gradle.internal.dsl.BaseAppModuleExtension
15+
import org.gradle.api.Plugin
16+
import org.gradle.api.Project
17+
import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi
18+
19+
abstract class PrivmxEndpointNativePlugin : Plugin<Project> {
20+
21+
override fun apply(project: Project) {
22+
//this is global for Java and Kotlin library
23+
project.dependencies.attributesSchema { handler ->
24+
handler.attribute(PrivMXNativeTargetAttribute)
25+
}
26+
27+
//If Java some code
28+
project.dependencies.components { handler ->
29+
handler.withModule("com.simplito.java:privmx-endpoint", PrivMXJavaRule::class.java)
30+
}
31+
32+
// If kotlin library then this code
33+
project.dependencies.components { handler ->
34+
handler.withModule("com.simplito.kotlin:privmx-endpoint-jvm", PrivMXKotlinRule::class.java)
35+
}
36+
37+
setJVMPrivmxRule(project)
38+
if(isAGP(project)) {
39+
setAndroidPrivmxRule(project)
40+
}
41+
}
42+
43+
private fun setJVMPrivmxRule(project: Project) {
44+
project.afterEvaluate {
45+
project.configurations.filter {
46+
it.name.lowercase().contains("runtimeclasspath")
47+
}.forEach {
48+
project.configurations.getAt(it.name).attributes { handler ->
49+
handler.attribute(PrivMXNativeTargetAttribute, "desktop")
50+
}
51+
}
52+
}
53+
}
54+
55+
@OptIn(ExperimentalKotlinGradlePluginApi::class)
56+
private fun setAndroidPrivmxRule(project: Project) {
57+
project.afterEvaluate {
58+
project.extensions.findByType(BaseAppModuleExtension::class.java)?.let { ext ->
59+
ext.applicationVariants.forEach { variant ->
60+
project.configurations.getAt("${variant.name}RuntimeClasspath").attributes { handler ->
61+
handler.attribute(PrivMXNativeTargetAttribute, "android")
62+
}
63+
project.configurations.getAt("${variant.name}UnitTestRuntimeClasspath").attributes { handler ->
64+
handler.attribute(PrivMXNativeTargetAttribute, "android")
65+
}
66+
}
67+
}
68+
}
69+
project.afterEvaluate {
70+
project.configurations.filter {
71+
it.name.lowercase().contains("runtimeclasspath") && it.name.lowercase().contains("android")
72+
}.forEach {
73+
project.configurations.getAt(it.name).attributes { handler ->
74+
handler.attribute(PrivMXNativeTargetAttribute, "android")
75+
}
76+
println(it)
77+
}
78+
}
79+
}
80+
}

privmx-endpoint-install-native/src/main/java/com/simplito/tools/gradle/privmx_endpoint_install_native/PrivmxEndpointPlatform.kt

Lines changed: 0 additions & 53 deletions
This file was deleted.

0 commit comments

Comments
 (0)