File tree Expand file tree Collapse file tree 9 files changed +66
-34
lines changed Expand file tree Collapse file tree 9 files changed +66
-34
lines changed Original file line number Diff line number Diff line change 13
13
matrix :
14
14
os : [ubuntu-latest, macos-latest, windows-latest]
15
15
java : [8, 17-ea]
16
- go : ['1.15 ', '1.17', '1.19']
16
+ go : ['1.16 ', '1.17', '1.19']
17
17
# Run all tests even if one fails
18
18
fail-fast : false
19
19
name : Test with JDK ${{ matrix.java }}, Go ${{ matrix.go }}, ${{ matrix.os }}
40
40
- name : Test
41
41
run : |
42
42
make test
43
-
44
- deploy :
45
- runs-on : ubuntu-latest
46
- steps :
47
- - name : Checkout
48
- uses : actions/checkout@v3
49
-
50
- - name : Setup Go
51
-
52
- with :
53
- go-version : 1.15
54
-
55
- - name : Setup Java
56
- uses : actions/setup-java@v3
57
- with :
58
- distribution : ' temurin'
59
- java-version : 8
60
- cache : ' maven'
61
-
62
- - name : Publish to GitHub Packages Apache Maven
63
- env :
64
- GITHUB_USERNAME : ${{ secrets.GITHUB_USERNAME }}
65
- GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
66
- run : |
67
- make deploy
Original file line number Diff line number Diff line change
1
+ name : Release
2
+
3
+ on :
4
+ push :
5
+ branches :
6
+ - main
7
+
8
+ jobs :
9
+ release :
10
+ runs-on : ubuntu-latest
11
+
12
+ steps :
13
+ - name : Checkout
14
+ uses : actions/checkout@v3
15
+
16
+ - name : Setup Go
17
+
18
+ with :
19
+ go-version : 1.16
20
+
21
+ - name : Setup Java
22
+ uses : actions/setup-java@v3
23
+ with :
24
+ distribution : ' temurin'
25
+ java-version : 8
26
+ cache : ' maven'
27
+
28
+ - name : Publish to GitHub Packages Apache Maven
29
+ env :
30
+ GITHUB_USERNAME : ${{ secrets.GITHUB_USERNAME }}
31
+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
32
+ run : |
33
+ make deploy
Original file line number Diff line number Diff line change 1
- go /awesome.so
2
- go /awesome.h
3
- awesome.so
1
+ go /libawesome.so
2
+ go /libawesome.dylib
3
+ go /awesome.dll
4
+ go /* .h
5
+ libawesome. *
4
6
target /*
5
7
6
8
.classpath
Original file line number Diff line number Diff line change 1
1
# init command params
2
2
GO := go
3
+ OS_NAME := linux
4
+ NATIVE_LIB := awesome.so
5
+
6
+ ifeq ($(OS ) ,Windows_NT)
7
+ OS_NAME = win32
8
+ NATIVE_LIB = awesome.dll
9
+ else
10
+ UNAME_S := $(shell uname -s)
11
+ ifeq ($(UNAME_S),Linux)
12
+ OS_NAME = linux
13
+ NATIVE_LIB = libawesome.so
14
+ endif
15
+ ifeq ($(UNAME_S),Darwin)
16
+ OS_NAME = darwin
17
+ NATIVE_LIB = libawesome.dylib
18
+ endif
19
+ endif
3
20
4
21
# env
5
22
export GO111MODULE := on
6
23
7
24
build-go : # # build go shared library
8
- cd go && $(GO ) build -o awesome.so -buildmode=c-shared awesome.go
9
- cp go/awesome.so src/main/resources/
25
+ cd go && $(GO ) build -o $( NATIVE_LIB ) -buildmode=c-shared awesome.go
26
+ cp go/$( NATIVE_LIB ) src/main/resources/$( OS_NAME ) -x86-64
10
27
11
28
build : # # build jar
12
29
make build-go
13
30
mvn clean package assembly:single
14
31
15
32
deploy : # # deploy
16
- make build-go
33
+ cd go && $(GO ) build -o libawesome.so -buildmode=c-shared awesome.go
34
+ cd go && CGO_ENABLED=1 GOOS=darwin GOARCH=amd64 $(GO ) build -o libawesome.dylib -buildmode=c-shared awesome.go
35
+ cd go && CGO_ENABLED=1 GOOS=windows GOARCH=amd64 $(GO ) build -o libawesome.dll -buildmode=c-shared awesome.go
36
+ cp go/libawesome.so src/main/resources/linux-x86-64/
37
+ cp go/libawesome.dylib src/main/resources/darwin-x86-64/
38
+ cp go/awesome.dll src/main/resources/win32-x86-64/
17
39
mvn deploy
18
40
19
41
test : # # test
Original file line number Diff line number Diff line change 1
1
module github.com/superbear/java-call-go/go
2
2
3
- go 1.15
3
+ go 1.16
Original file line number Diff line number Diff line change @@ -11,7 +11,7 @@ public class Client {
11
11
12
12
static {
13
13
try {
14
- File file = Native .extractFromResourcePath ("/ awesome.so " , Client .class .getClassLoader ());
14
+ File file = Native .extractFromResourcePath ("awesome" , Client .class .getClassLoader ());
15
15
Awesome lib = Native .load (file .getAbsolutePath (), Awesome .class );
16
16
handle = (Awesome )Native .synchronizedLibrary (lib );
17
17
} catch (Exception e ) {
You can’t perform that action at this time.
0 commit comments