Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
cmdjulian committed Jul 3, 2023
1 parent 7b0cbb4 commit daf8cac
Show file tree
Hide file tree
Showing 14 changed files with 525 additions and 0 deletions.
9 changes: 9 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#
# https://help.github.com/articles/dealing-with-line-endings/
#
# Linux start script should use lf
/gradlew text eol=lf

# These are Windows script files and should use crlf
*.bat text eol=crlf

27 changes: 27 additions & 0 deletions .github/workflows/gradle-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Publish package to GitHub Packages

on:
release:
types: [ created ]

jobs:
publish:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v3
- uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'adopt'
- name: Validate Gradle wrapper
uses: gradle/wrapper-validation-action@064a97fb0b4cef86a65f09898c572382f3af10e0
- name: Publish package
uses: gradle/gradle-build-action@bde650d6f1426615a60165575bc9cdad3e54d975
with:
arguments: publishAllPublicationsToGitHubPackagesRepository
env:
USERNAME: ${{ github.actor }}
TOKEN: ${{ secrets.GITHUB_TOKEN }}
34 changes: 34 additions & 0 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
# This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-gradle

name: Java CI with Gradle

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

permissions:
contents: read

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Set up JDK 11
uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'liberica'
- name: Build with Gradle
uses: gradle/gradle-build-action@bde650d6f1426615a60165575bc9cdad3e54d975
with:
arguments: check assemble
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Ignore Gradle project-specific cache directory
.gradle

# Ignore Gradle build output directory
build
/.idea/
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
[![](https://jitpack.io/v/cmdjulian/kirc.svg)](https://jitpack.io/#cmdjulian/bouncy-castle-graalvm)

# bouncy-castle-graalvm
GraalVM feature to contribute BouncyCastle into native image
47 changes: 47 additions & 0 deletions bouncy-castle/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import org.jetbrains.kotlinx.publisher.apache2
import org.jetbrains.kotlinx.publisher.developer
import org.jetbrains.kotlinx.publisher.githubRepo

plugins {
id("org.jetbrains.kotlin.jvm") version "1.8.22"
kotlin("libs.publisher") version "0.0.61-dev-34"
}

repositories {
mavenCentral()
}

dependencies {
implementation("org.graalvm.nativeimage:svm:23.0.0")
}

java {
toolchain {
languageVersion.set(JavaLanguageVersion.of(11))
}
}

kotlinPublications {
defaultGroup.set("com.github.cmdjulian")
fairDokkaJars.set(false)

pom {
inceptionYear.set("2023")
licenses {
apache2()
}
githubRepo("cmdjulian", "bouncy-castle-graalvm")
developers {
developer("cmdjulian", "Julian Goede", "[email protected]")
}
}

localRepositories {
defaultLocalMavenRepository()
}

publication {
publicationName.set("graal-bouncy-castle")
description.set("kirc core components")
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package de.cmdjulian.graal.bouncycastle

import org.graalvm.nativeimage.hosted.Feature
import org.graalvm.nativeimage.hosted.Feature.AfterRegistrationAccess
import org.graalvm.nativeimage.hosted.RuntimeClassInitialization
import java.security.Provider
import java.security.Security

@Suppress("unused")
class BouncyCastleFeature : Feature {
override fun afterRegistration(access: AfterRegistrationAccess?) {
val clazz = try {
Class.forName("org.bouncycastle.jce.provider.BouncyCastleProvider")
} catch (e: Exception) {
return println(
if (e is ClassNotFoundException) {
"bouncy castle not present -> not loading it"
} else {
"unknown exception when loading bouncy castle: ${e.message}"
},
)
}

val bc = clazz.getConstructor().newInstance() as Provider

Security.addProvider(bc)

RuntimeClassInitialization.initializeAtBuildTime("org.bouncycastle")
RuntimeClassInitialization.initializeAtRunTime(Class.forName("org.bouncycastle.jcajce.provider.drbg.DRBG\$Default"))
RuntimeClassInitialization.initializeAtRunTime(Class.forName("org.bouncycastle.jcajce.provider.drbg.DRBG\$NonceAndIV"))
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Args = --features=de.cmdjulian.graal.bouncycastle.BouncyCastleFeature
6 changes: 6 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# This file was generated by the Gradle 'init' task.
# https://docs.gradle.org/current/userguide/build_environment.html#sec:gradle_configuration_properties

org.gradle.parallel=true
org.gradle.caching=true

Binary file added gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
7 changes: 7 additions & 0 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.2-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Loading

0 comments on commit daf8cac

Please sign in to comment.