Skip to content
Merged
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
27 changes: 1 addition & 26 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
java: [8, 17-ea]
go: ['1.15', '1.17', '1.19']
go: ['1.16', '1.17', '1.19']
# Run all tests even if one fails
fail-fast: false
name: Test with JDK ${{ matrix.java }}, Go ${{ matrix.go }}, ${{ matrix.os }}
Expand All @@ -40,28 +40,3 @@ jobs:
- name: Test
run: |
make test

deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Setup Go
uses: actions/setup-go@v3.3.0
with:
go-version: 1.15

- name: Setup Java
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: 8
cache: 'maven'

- name: Publish to GitHub Packages Apache Maven
env:
GITHUB_USERNAME: ${{ secrets.GITHUB_USERNAME }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
make deploy
33 changes: 33 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Release

on:
push:
branches:
- main

jobs:
release:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Setup Go
uses: actions/setup-go@v3.3.0
with:
go-version: 1.16

- name: Setup Java
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: 8
cache: 'maven'

- name: Publish to GitHub Packages Apache Maven
env:
GITHUB_USERNAME: ${{ secrets.GITHUB_USERNAME }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
make deploy
8 changes: 5 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
go/awesome.so
go/awesome.h
awesome.so
go/libawesome.so
go/libawesome.dylib
go/awesome.dll
go/*.h
libawesome.*
target/*

.classpath
Expand Down
28 changes: 25 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,19 +1,41 @@
# init command params
GO := go
OS_NAME := linux
NATIVE_LIB := awesome.so

ifeq ($(OS),Windows_NT)
OS_NAME = win32
NATIVE_LIB = awesome.dll
else
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),Linux)
OS_NAME = linux
NATIVE_LIB = libawesome.so
endif
ifeq ($(UNAME_S),Darwin)
OS_NAME = darwin
NATIVE_LIB = libawesome.dylib
endif
endif

# env
export GO111MODULE := on

build-go: ## build go shared library
cd go && $(GO) build -o awesome.so -buildmode=c-shared awesome.go
cp go/awesome.so src/main/resources/
cd go && $(GO) build -o $(NATIVE_LIB) -buildmode=c-shared awesome.go
cp go/$(NATIVE_LIB) src/main/resources/$(OS_NAME)-x86-64

build: ## build jar
make build-go
mvn clean package assembly:single

deploy: ## deploy
make build-go
cd go && $(GO) build -o libawesome.so -buildmode=c-shared awesome.go
cd go && CGO_ENABLED=1 GOOS=darwin GOARCH=amd64 $(GO) build -o libawesome.dylib -buildmode=c-shared awesome.go
cd go && CGO_ENABLED=1 GOOS=windows GOARCH=amd64 $(GO) build -o libawesome.dll -buildmode=c-shared awesome.go
cp go/libawesome.so src/main/resources/linux-x86-64/
cp go/libawesome.dylib src/main/resources/darwin-x86-64/
cp go/awesome.dll src/main/resources/win32-x86-64/
mvn deploy

test: ## test
Expand Down
2 changes: 1 addition & 1 deletion go/go.mod
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module github.com/superbear/java-call-go/go

go 1.15
go 1.16
2 changes: 1 addition & 1 deletion src/main/java/go/Client.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public class Client {

static {
try {
File file = Native.extractFromResourcePath("/awesome.so", Client.class.getClassLoader());
File file = Native.extractFromResourcePath("awesome", Client.class.getClassLoader());
Awesome lib = Native.load(file.getAbsolutePath(), Awesome.class);
handle = (Awesome)Native.synchronizedLibrary(lib);
} catch (Exception e) {
Expand Down
Empty file.
Empty file.
Empty file.