Skip to content

Commit

Permalink
Update Kotlin and set up Bintray/OJO publishing
Browse files Browse the repository at this point in the history
  • Loading branch information
thecodewarrior committed Nov 18, 2020
1 parent ee34c8b commit eda4094
Show file tree
Hide file tree
Showing 29 changed files with 566 additions and 544 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/publish_release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# This workflow will build a package using Gradle and then publish it to Bintray when a release is created
# For more information see: https://github.com/actions/setup-java#publishing-using-gradle

name: Publish Releases

on:
release:
types: [published]

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Set up JDK 1.8
uses: actions/setup-java@v1
with:
java-version: 1.8
server-id: github # Value of the distributionManagement/repository/id field of the pom.xml
settings-path: ${{ github.workspace }} # location for the settings.xml file

- name: Build with Gradle
run: ./gradlew build

- name: Publish to Bintray
run: ./gradlew bintrayUpload
env:
BINTRAY_USER: ${{ secrets.BINTRAY_USER }}
BINTRAY_API_KEY: ${{ secrets.BINTRAY_API_KEY }}
31 changes: 31 additions & 0 deletions .github/workflows/publish_snapshot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# This workflow will build a package using Gradle and then publish it oss.jfrog.org when a release is created
# For more information see: https://github.com/actions/setup-java#publishing-using-gradle

name: Publish Snapshots

on: push

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Set up JDK 1.8
uses: actions/setup-java@v1
with:
java-version: 1.8
server-id: github # Value of the distributionManagement/repository/id field of the pom.xml
settings-path: ${{ github.workspace }} # location for the settings.xml file

- name: Build with Gradle
run: ./gradlew build

- name: Publish to oss.jfrog.org
run: ./gradlew artifactoryPublish
env:
SNAPSHOT_BRANCH: ${{ github.ref }}
BINTRAY_USER: ${{ secrets.BINTRAY_USER }}
BINTRAY_API_KEY: ${{ secrets.BINTRAY_API_KEY }}
ARTIFACTORY_BUILD_NUMBER: ${{ github.run_number }}
125 changes: 112 additions & 13 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,19 +1,44 @@
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'org.jfrog.buildinfo:build-info-extractor-gradle:latest.release'
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.+'
}
}

plugins {
id 'java'
id 'maven'
id 'org.jetbrains.kotlin.jvm' version '1.3.72'
id 'org.jetbrains.kotlin.jvm' version '1.4.0'
}

apply plugin: 'maven-publish'
apply plugin: 'com.jfrog.bintray'
apply plugin: 'com.jfrog.artifactory'

def maven_version = library_version
def snapshotBranch = System.getenv('SNAPSHOT_BRANCH')
if(snapshotBranch != null) {
if(snapshotBranch.startsWith('refs/heads/'))
snapshotBranch = snapshotBranch.substring('refs/heads/'.length())
maven_version = snapshotBranch.replaceAll('[^.\\w-]', '-') + '-SNAPSHOT'
logger.lifecycle('Using SNAPSHOT version `{}`', version)
}

group = "dev.thecodewarrior.mirror"
version = "0.1.0"
// pass `-PmirrorVersion=foo` to set the version directly. Useful for publishing to the local maven repository
if(hasProperty('mirrorVersion')) {
maven_version = mirrorVersion
}

group = 'dev.thecodewarrior.mirror'
archivesBaseName = 'mirror'
version = maven_version

repositories {
mavenCentral()
jcenter()
maven { url = "https://jitpack.io" }
}

sourceSets {
}

dependencies {
Expand All @@ -24,30 +49,104 @@ dependencies {
testImplementation('io.mockk:mockk:1.10.0')
}

kotlin {
explicitApi = 'warning'
}

compileKotlin {
kotlinOptions {
jvmTarget = "1.8"
jvmTarget = '1.8'
javaParameters = true
freeCompilerArgs += "-Xjvm-default=enable"
freeCompilerArgs += '-Xjvm-default=all'
}
}

compileTestKotlin {
kotlinOptions {
jvmTarget = "1.8"
jvmTarget = '1.8'
javaParameters = true
freeCompilerArgs += "-Xjvm-default=enable"
freeCompilerArgs += '-Xjvm-default=all'
}
}

compileJava {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
options.compilerArgs.add("-parameters")
options.compilerArgs.add('-parameters')
}

compileTestJava {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
options.compilerArgs.add("-parameters")
options.compilerArgs.add('-parameters')
}

task sourcesJar(type: Jar) {
classifier = 'sources'
from sourceSets.main.allSource
}

jar.dependsOn sourcesJar

publishing {
publications {
create('maven', MavenPublication) {
groupId = 'dev.thecodewarrior.mirror'
artifactId = 'mirror'
version = project.version

artifact sourcesJar
from components.java

pom {
name = 'Mirror'
description = 'A library that makes advanced Java reflection features viable for the non-expert to use'
url = 'http://github.com/thecodewarrior/Mirror'
licenses {
license {
name = 'BSD 2-Clause'
}
}
scm {
connection = 'scm:git:https://github.com/thecodewarrior/Mirror.git'
developerConnection = 'scm:git:ssh://github.com/thecodewarrior/Mirror.git'
url = 'https://github.com/thecodewarrior/Mirror'
}
}
}
}
}

bintray {
user = System.getenv('BINTRAY_USER')
key = System.getenv('BINTRAY_API_KEY')
publications = ['maven']
pkg {
repo = 'thecodewarrior'
name = 'mirror'
desc = project.description
labels = ['java', 'reflection']
licenses = ['BSD 2-Clause']

websiteUrl = 'https://github.com/thecodewarrior/Mirror'
githubRepo = 'thecodewarrior/Mirror'
vcsUrl = 'https://github.com/thecodewarrior/Mirror.git'
issueTrackerUrl = 'https://github.com/thecodewarrior/Mirror/issues'
}
}

artifactory {
setContextUrl 'https://oss.jfrog.org'
publish {
repository {
repoKey = project.version.endsWith('-SNAPSHOT') ? 'oss-snapshot-local' : 'oss-release-local'
username = System.getenv('BINTRAY_USER')
password = System.getenv('BINTRAY_API_KEY')
maven = true
}
defaults {
publications 'maven'
}
}
clientConfig.info.setBuildNumber(System.getenv('ARTIFACTORY_BUILD_NUMBER')) // no env = null = default value
}
1 change: 1 addition & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
library_version=1.0.0b1
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
5 changes: 2 additions & 3 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#Sat May 23 13:11:03 PDT 2020
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.3-all.zip
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
51 changes: 20 additions & 31 deletions gradlew
Original file line number Diff line number Diff line change
@@ -1,21 +1,5 @@
#!/usr/bin/env sh

#
# Copyright 2015 the original author or authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

##############################################################################
##
## Gradle start up script for UN*X
Expand Down Expand Up @@ -44,7 +28,7 @@ APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`

# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
DEFAULT_JVM_OPTS=""

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
Expand Down Expand Up @@ -125,8 +109,8 @@ if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi

# For Cygwin or MSYS, switch paths to Windows format before running java
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
# For Cygwin, switch paths to Windows format before running java
if $cygwin ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"`
Expand Down Expand Up @@ -154,19 +138,19 @@ if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
else
eval `echo args$i`="\"$arg\""
fi
i=`expr $i + 1`
i=$((i+1))
done
case $i in
0) set -- ;;
1) set -- "$args0" ;;
2) set -- "$args0" "$args1" ;;
3) set -- "$args0" "$args1" "$args2" ;;
4) set -- "$args0" "$args1" "$args2" "$args3" ;;
5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
(0) set -- ;;
(1) set -- "$args0" ;;
(2) set -- "$args0" "$args1" ;;
(3) set -- "$args0" "$args1" "$args2" ;;
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac
fi

Expand All @@ -175,9 +159,14 @@ save () {
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
echo " "
}
APP_ARGS=`save "$@"`
APP_ARGS=$(save "$@")

# Collect all arguments for the java command, following the shell quoting and substitution rules
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"

# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
cd "$(dirname "$0")"
fi

exec "$JAVACMD" "$@"
18 changes: 1 addition & 17 deletions gradlew.bat
Original file line number Diff line number Diff line change
@@ -1,19 +1,3 @@
@rem
@rem Copyright 2015 the original author or authors.
@rem
@rem Licensed under the Apache License, Version 2.0 (the "License");
@rem you may not use this file except in compliance with the License.
@rem You may obtain a copy of the License at
@rem
@rem https://www.apache.org/licenses/LICENSE-2.0
@rem
@rem Unless required by applicable law or agreed to in writing, software
@rem distributed under the License is distributed on an "AS IS" BASIS,
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem

@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
Expand All @@ -30,7 +14,7 @@ set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%

@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
set DEFAULT_JVM_OPTS=

@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
Expand Down
Loading

0 comments on commit eda4094

Please sign in to comment.