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

fix json render;print with variable name;add some magic(compile ... etc);upgrade some dep; #145

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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
47 changes: 47 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time
# Docs: https://docs.github.com/en/actions/learn-github-actions/understanding-github-actions
# Docs: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle
# Docs: https://github.com/softprops/action-gh-release

name: Build And Release

#on: push
on:
push:
# Sequence of patterns matched against refs/tags
tags:
- 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10

# softprops/action-gh-release need write perm
permissions:
contents: write

jobs:
build:
runs-on: ubuntu-latest
steps:
- run: echo github workspace=${{ github.workspace }}
- uses: actions/checkout@v3

- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'

- name: Setup Gradle
uses: gradle/gradle-build-action@v2

- name: Change wrapper permissions
run: chmod +x ./gradlew

- name: Execute Gradle build
run: ./gradlew packDist

- name: Release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
body_path: UPGRADE.md
files: |
build/distributions/ijava-latest.zip
4 changes: 2 additions & 2 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2018 Spencer Park
Copyright (c) ${year} ${author}

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand All @@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
SOFTWARE.
166 changes: 113 additions & 53 deletions README.md

Large diffs are not rendered by default.

9 changes: 9 additions & 0 deletions UPGRADE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Updated:

1. fix `CompilerMagics.compile` auto generated package path error
2. remain `JupyterIO.jupyterXXX.env`, keep thread stdout rewrite to jupyter

TODO:

1. reload `CompilerMagics.compile` class? DirectExecutionControl > DefaultLoaderDelegate
2. thread stdout JupyterIO.retractEnv; BaseKernel.replaceOutputStreams
225 changes: 112 additions & 113 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,153 +1,152 @@
plugins {
id 'java'
id 'maven-publish'
id('com.github.hierynomus.license') version '0.14.0'
id('io.github.spencerpark.jupyter-kernel-installer') version '2.1.0'
id('com.github.jk1.dependency-license-report')
}

import com.github.jk1.license.filter.LicenseBundleNormalizer
import com.github.jk1.license.render.InventoryHtmlReportRenderer
import com.github.jk1.license.render.JsonReportRenderer
import org.apache.tools.ant.filters.ReplaceTokens
import com.github.jk1.license.render.*
import com.github.jk1.license.filter.*
import io.github.spencerpark.gradle.*

group = 'io.github.spencerpark'
version = '1.3.0'

wrapper {
gradleVersion = '4.8.1'
distributionType = Wrapper.DistributionType.ALL
}

// Add the license header to source files
license {
header = file('LICENSE')
exclude '**/*.json'
mapping {
// Use a regular multiline comment rather than a javadoc comment
java = 'SLASHSTAR_STYLE'
}
}
build.dependsOn 'licenseFormat'

// Configures the license report generated for the dependencies.
licenseReport {
excludeGroups = []
renderers = [
// Generate a pretty HTML report that groups dependencies by their license.
new NewInventoryHtmlReportRenderer('dependencies.html'),
// TODO make sure ci verifies that all licenses are know to be allowed to redistribute before publishing
new JsonReportRenderer('dependencies.json')
]

// Group same licenses despite names being slightly different (ex. Apache 2.0 vs Apache version 2)
filters = [new LicenseBundleNormalizer()]

configurations = ['compile']
}

compileJava {
sourceCompatibility = 1.9
targetCompatibility = 1.9
plugins {
id 'java-library'
// id 'maven-publish' // use johnrengelman.shadow instead
id 'com.github.hierynomus.license' version '0.16.1'
id "com.github.jk1.dependency-license-report" version "2.1"
id 'com.github.johnrengelman.shadow' version '7.1.2'
// id 'io.github.spencerpark.jupyter-kernel-installer' version '2.1.0'
}

configurations {
shade
// transitive true to make sure that the dependencies of shade dependencies also get shaded
// into the jar
shade.transitive = true
compile.extendsFrom(shade)
}
group = 'io.github.spencerpark'
version = '1.4.4'

repositories {
mavenLocal()
mavenCentral()
maven {
url = 'https://oss.sonatype.org/content/repositories/snapshots/'
}
mavenLocal()
}

dependencies {
shade group: 'io.github.spencerpark', name: 'jupyter-jvm-basekernel', version: '2.3.0'
implementation('io.github.spencerpark:jupyter-jvm-basekernel:2.3.0') {
exclude group: 'com.google.code.gson', module: 'gson'
}
implementation 'com.google.code.gson:gson:2.10'

shade group: 'org.apache.ivy', name: 'ivy', version: '2.5.0-rc1'
//shade group: 'org.apache.maven', name: 'maven-settings-builder', version: '3.6.0'
shade group: 'org.apache.maven', name: 'maven-model-builder', version: '3.6.0'
// ------ for maven resolve and download ------
// implementation 'org.apache.maven:maven-resolver-provider:4.0.0-alpha-2'
implementation('org.apache.maven:maven-resolver-provider:3.8.6') {
exclude group: 'org.apache.maven.resolver' // manual include 1.8.2
}
implementation 'org.apache.maven.resolver:maven-resolver-impl:1.8.2'
implementation 'org.apache.maven.resolver:maven-resolver-connector-basic:1.8.2'
implementation 'org.apache.maven.resolver:maven-resolver-transport-file:1.8.2'
implementation 'org.apache.maven.resolver:maven-resolver-transport-http:1.8.2'
implementation 'org.apache.maven.resolver:maven-resolver-transport-classpath:1.8.2'
// ------ for maven resolve and download ------

testCompile group: 'junit', name: 'junit', version: '4.12'
}
implementation 'org.apache.logging.log4j:log4j-core:2.19.0'

jar {
//Include all shaded dependencies in the jar
from configurations.shade
.collect { it.isDirectory() ? it : zipTree(it) }
testImplementation group: 'junit', name: 'junit', version: '4.13.2'
}

manifest {
attributes('Main-class': 'io.github.spencerpark.ijava.IJava')
}
// Add the license header to source files
license {
header = file('LICENSE')
include "**/*.java"
exclude "**/Test*.java"
mapping java: 'SLASHSTAR_STYLE'
ext.year = Calendar.getInstance().get(Calendar.YEAR)
}
licenseMain.dependsOn 'licenseFormat'

// replace @symbol@ in properties
processResources {
def tokens = [
'version': project.version,
'project': project.name
]
inputs.properties(tokens)
filter ReplaceTokens, tokens: tokens
filter tokens: tokens, ReplaceTokens
}

publishing {
publications {
mavenJava(MavenPublication) {
from components.java
}
//java {
// withJavadocJar()
// withSourcesJar()
//}

compileJava {
options.compilerArgs << '-parameters'
// ignore deprecation for jupyter-jvm-basekernel gson JsonParser api
// options.compilerArgs << '-Xlint:all' << '-Xlint:-deprecation' << '-Xlint:-rawtypes' << '-Xlint:-serial'
}

jar {
manifest {
attributes 'Main-class': 'io.github.spencerpark.ijava.IJava'
}
}

jupyter {
kernelName = 'java'
kernelDisplayName = 'Java'
kernelLanguage = 'java'
kernelInterruptMode = 'message'

kernelParameters {
list('classpath', 'IJAVA_CLASSPATH') {
separator = PATH_SEPARATOR
description = '''A file path separator delimited list of classpath entries that should be available to the user code. **Important:** no matter what OS, this should use forward slash "/" as the file separator. Also each path may actually be a simple glob.'''
}

list('comp-opts', 'IJAVA_COMPILER_OPTS') {
separator = ' '
description = '''A space delimited list of command line options that would be passed to the `javac` command when compiling a project. For example `-parameters` to enable retaining parameter names for reflection.'''
}

list('startup-scripts-path', 'IJAVA_STARTUP_SCRIPTS_PATH') {
separator = PATH_SEPARATOR
description = '''A file path seperator delimited list of `.jshell` scripts to run on startup. This includes ijava-jshell-init.jshell and ijava-display-init.jshell. **Important:** no matter what OS, this should use forward slash "/" as the file separator. Also each path may actually be a simple glob.'''
}

string('startup-script', 'IJAVA_STARTUP_SCRIPT') {
description = '''A block of java code to run when the kernel starts up. This may be something like `import my.utils;` to setup some default imports or even `void sleep(long time) { try {Thread.sleep(time); } catch (InterruptedException e) { throw new RuntimeException(e); }}` to declare a default utility method to use in the notebook.'''
}

string('timeout', 'IJAVA_TIMEOUT') {
aliases NO_TIMEOUT: '-1'
description = '''A duration specifying a timeout (in milliseconds by default) for a _single top level statement_. If less than `1` then there is no timeout. If desired a time may be specified with a `TimeUnit` may be given following the duration number (ex `"30 SECONDS"`).'''
}
// shadow Jar config
shadowJar {
// inherit from the manifest of the standard jar task
// manifest {
// attributes 'Main-class': 'io.github.spencerpark.ijava.IJava'
// }

// copy build.gradle to shadowed jar
from("./") {
include 'build.gradle'
}
}
build.dependsOn 'shadowJar'

// publish
//publishing {
// publications {
// shadow(MavenPublication) { publication ->
// project.shadow.component(publication)
// }
// }
// repositories {
// maven {
// url "http://repo.myorg.com"
// }
// }
//}

// create license report
licenseReport {
renderers = [
new InventoryHtmlReportRenderer('license-report.html'),
new JsonReportRenderer('license-report.json')
]

installKernel {
kernelInstallPath = commandLineSpecifiedPath(userInstallPath)
filters = [new LicenseBundleNormalizer()]
}

zipKernel {
installers {
with 'python'
// pack up
tasks.register('packDist', Zip) {
archiveFileName = project.name + "-latest.zip"

from(layout.buildDirectory.dir("resources/main")) {
include "install.py"
}

from(generateLicenseReport.outputFolder) {
into 'dependency-licenses'
from(layout.buildDirectory.dir("libs")) {
include "*-all.jar"
into "java"
}

from(layout.buildDirectory.dir("resources/main")) {
include "kernel.json"
into "java"
}

from(layout.buildDirectory.dir("reports/dependency-license")) {
into "java/dependency-license"
}

dependsOn generateLicenseReport
dependsOn build
}
zipKernel.dependsOn 'generateLicenseReport'

// execute task after build
//build.finalizedBy(packDist)
13 changes: 0 additions & 13 deletions buildSrc/build.gradle

This file was deleted.

This file was deleted.

Loading