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

Copy changes from 0.15.2 to master #1041

Closed
wants to merge 13 commits into from
Closed
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
Prev Previous commit
Next Next commit
Java example for 0.15.2 (#1028)
* new java project, but old source code

* update self tests for the example app

* fix test workflow, fix Makefile
radetsky committed Dec 7, 2023

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit cc9ff853dd541f81df8161562f3c822f1baea941
8 changes: 4 additions & 4 deletions .github/workflows/test-java.yaml
Original file line number Diff line number Diff line change
@@ -112,13 +112,13 @@ jobs:

java-example:
name: Example project – JavaThemis
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
steps:
- name: Install system dependencies
run: |
sudo sh -c 'echo "DEBIAN_FRONTEND=noninteractive" >> /etc/environment'
sudo apt update
sudo apt install --yes gcc make libssl-dev default-jdk
sudo apt install --yes gcc make libssl-dev default-jdk dpkg-dev
- name: Check out code
uses: actions/checkout@v2
- name: Install Themis Core with JNI
@@ -128,10 +128,10 @@ jobs:
- name: Build JavaThemis example
run: |
cd docs/examples/java
./gradlew --no-daemon build
JAVA_TOOL_OPTIONS=-Djava.library.path=/usr/local/lib ./gradlew --no-daemon build
# Thus runs a bit of an abomination: Themis Core and JNI libs are built
# from source while JavaThemis binaries are installed from Maven Central.
- name: Run JavaThemis example
run: |
cd docs/examples/java
java -Djava.library.path=/usr/local/lib -jar app/build/libs/app.jar
JAVA_TOOL_OPTIONS=-Djava.library.path=/usr/local/lib ./gradlew --no-daemon run
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -93,6 +93,11 @@ LDFLAGS += -L$(BIN_PATH)
# Build shared libraries
CFLAGS += -fPIC

#----- Mode packaging ----------------------------------------------------------
# Default value is not packaging mode. Goals: dev, rpm, deb_php will set it to 1
MODE_PACKAGING = 0


########################################################################
#
# Pretty-printing utilities
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;
@@ -8,7 +13,7 @@
import java.util.Base64;


public class main {
public class App {

static Charset charset = StandardCharsets.UTF_8;

Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/*
* 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 appDoesNotThrow() {
App classUnderTest = new App();
assertDoesNotThrow(() -> App.encryptDataForStoring(), "encryptDataForStoring() should run without exceptions");
assertDoesNotThrow(() -> App.encryptDataForMessaging(), "encryptDataForMessaging() should run without exceptions");
}
}


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