Skip to content
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

Java example for 0.15.2 #1028

Merged
merged 4 commits into from
Oct 4, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions docs/examples/java/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Java example

## Run
```
JAVA_TOOL_OPTIONS=-Djava.library.path=/opt/homebrew/lib ./gradlew run
```

41 changes: 25 additions & 16 deletions docs/examples/java/app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,27 +1,36 @@
apply plugin: 'java'
/*
* This file was generated by the Gradle 'init' task.
*
* This generated file contains a sample Java application project to get you started.
* For more details take a look at the 'Building Java & JVM projects' chapter in the Gradle
* User Manual available at https://docs.gradle.org/8.0.2/userguide/building_java_projects.html
*/

plugins {
// Apply the application plugin to add support for building a CLI application in Java.
id 'application'
}

repositories {
// Use Maven Central for resolving dependencies.
mavenCentral()
}

dependencies {
implementation 'com.cossacklabs.com:java-themis:0.14.0'
}
// Use JUnit Jupiter for testing.
testImplementation 'org.junit.jupiter:junit-jupiter:5.9.1'

sourceSets {
main {
java.srcDirs = ["src"]
}
// This dependency is used by the application.
implementation 'com.google.guava:guava:31.1-jre'
implementation("com.cossacklabs.com:java-themis:0.15.2")
}

// Pack *everything* into JAR, including dependencies and their dependencies.
// By default this will pack only local classes, compiled here.
jar {
manifest {
attributes "Main-Class": "main"
}
application {
// Define the main class for the application.
mainClass = 'java_themis_example.App'
}

from {
configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) }
}
tasks.named('test') {
// Use JUnit Platform for unit tests.
useJUnitPlatform()
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
/*
* This Java source file was generated by the Gradle 'init' task.
*/
package java_themis_example;

import com.cossacklabs.themis.*;

import java.io.IOException;
Expand All @@ -8,7 +13,7 @@
import java.util.Base64;


public class main {
public class App {

static Charset charset = StandardCharsets.UTF_8;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/*
* This Java source file was generated by the Gradle 'init' task.
*/
package java_themis_example;

import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;

class AppTest {
@Test void appHasAGreeting() {
App classUnderTest = new App();
assertNotNull(classUnderTest.getGreeting(), "app should have a greeting");
}
}
17 changes: 0 additions & 17 deletions docs/examples/java/build.gradle

This file was deleted.

Binary file modified docs/examples/java/gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
6 changes: 3 additions & 3 deletions docs/examples/java/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Mon Dec 20 16:40:39 EET 2021
distributionUrl=https\://services.gradle.org/distributions/gradle-6.3-bin.zip
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0.2-bin.zip
networkTimeout=10000
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Loading
Loading