@@ -37,97 +37,85 @@ javadoc {
37
37
}
38
38
39
39
task cargoReleaseBuild (type : Exec ) {
40
- workingDir ' .. /datafusion-jni'
40
+ workingDir " $r ootDir /datafusion-jni"
41
41
executable " ${ System.getProperty('user.home')} /.cargo/bin/cargo"
42
42
args + = [' build' , ' --release' ]
43
43
}
44
44
45
- @SuppressWarnings ( ' GrMethodMayBeStatic ' )
46
- String getLibExtension () {
47
- if (osdetector . os == " windows " ) {
48
- return " dll"
49
- } else if (osdetector . os == " linux " ) {
50
- return " so "
51
- } else if (osdetector . os == " osx " ) {
52
- return " dylib "
53
- } else {
54
- throw new GradleException ( " Unsupported OS ${ osdetector.os } " )
55
- }
45
+ def extensionMapping = [
46
+ " osx " : " dylib " ,
47
+ " linux " : " so " ,
48
+ " windows " : " dll"
49
+ ]
50
+
51
+ task copyBuiltLibrary ( type : Copy ) {
52
+ def extension = extensionMapping[osdetector . os]
53
+ from " ${ rootDir } /datafusion-jni/target/release/libdatafusion_jni. $e xtension "
54
+ into layout . buildDirectory . dir( " jni_libs/ ${ osdetector.classifier } " )
55
+ dependsOn cargoReleaseBuild
56
56
}
57
57
58
- PublishArtifact getArtifact (String extension , String classifier ) {
59
- def jniFile = layout. buildDirectory. file(" ../../datafusion-jni/target/release/libdatafusion_jni.$extension " )
60
- return artifacts. add(' archives' , jniFile. get(). asFile) {
61
- type = extension
62
- extension = extension
63
- classifier = classifier
64
- }
58
+ def classifierOsx = ' osx-x86_64'
59
+ def extensionOsx = ' dylib'
60
+ def jniLibOsx = layout. buildDirectory. file(" jni_libs/$classifierOsx /libdatafusion_jni.$extensionOsx " )
61
+
62
+ def classifierLinux = ' linux-x86_64'
63
+ def extensionLinux = ' so'
64
+ def jniLibLinux = layout. buildDirectory. file(" jni_libs/$classifierLinux /libdatafusion_jni.$extensionLinux " )
65
+
66
+ task jarWithOsxLib (type : Jar ) {
67
+ from sourceSets. main. output
68
+ from jniLibOsx
69
+ rename " libdatafusion_jni.$extensionOsx " , " jni_libs/libdatafusion_jni.$extensionOsx "
70
+ archiveClassifier. set(classifierOsx)
71
+ }
72
+
73
+ task jarWithLinuxLib (type : Jar ) {
74
+ from sourceSets. main. output
75
+ from jniLibLinux
76
+ rename " libdatafusion_jni.$extensionLinux " , " jni_libs/libdatafusion_jni.$extensionLinux "
77
+ archiveClassifier. set(classifierLinux)
78
+ }
79
+
80
+ task jarWithLib (type : Jar ) {
81
+ from sourceSets. main. output
82
+ from jniLibOsx
83
+ rename " libdatafusion_jni.$extensionOsx " , " jni_libs/libdatafusion_jni.$extensionOsx "
84
+ from jniLibLinux
85
+ rename " libdatafusion_jni.$extensionLinux " , " jni_libs/libdatafusion_jni.$extensionLinux "
65
86
}
66
87
67
88
publishing {
68
89
publications {
69
- def artifactId = ' datafusion-java'
70
- if (System . getenv(" CI" ) != null ) {
71
- mavenJava(MavenPublication ) {
72
- artifactId
73
- from(components. java)
74
- artifact getArtifact(" so" , " linux-x86_64" )
75
- artifact getArtifact(" dylib" , " osx-x86_64" )
76
- pom {
77
- name = ' DataFusion Java'
78
- description = ' A Java binding to Apache Arrow DataFusion library'
79
- url = ' https://github.com/datafusion-contrib/datafusion-java'
80
- licenses {
81
- license {
82
- name = ' The Apache License, Version 2.0'
83
- url = ' http://www.apache.org/licenses/LICENSE-2.0.txt'
84
- }
85
- }
86
- developers {
87
- developer {
88
- id = ' dev'
89
- name = ' Apache Arrow Developers'
90
-
91
- }
90
+ mavenJava(MavenPublication ) {
91
+ artifactId ' datafusion-java'
92
+ artifact sourcesJar
93
+ artifact javadocJar
94
+ artifact jarWithLib
95
+ pom {
96
+ name = ' DataFusion Java'
97
+ description = ' A Java binding to Apache Arrow DataFusion library'
98
+ url = ' https://github.com/datafusion-contrib/datafusion-java'
99
+ licenses {
100
+ license {
101
+ name = ' The Apache License, Version 2.0'
102
+ url = ' http://www.apache.org/licenses/LICENSE-2.0.txt'
92
103
}
93
- scm {
94
- connection
= ' scm:git:[email protected] :datafusion-contrib/datafusion-java.git'
95
- developerConnection = ' scm:git:https://github.com/datafusion-contrib/datafusion-java.git'
96
- url = ' https://github.com/datafusion-contrib/datafusion-java'
104
+ }
105
+ developers {
106
+ developer {
107
+ id = ' dev'
108
+ name = ' Apache Arrow Developers'
109
+
97
110
}
98
111
}
99
- }
100
- } else {
101
- mavenJava(MavenPublication ) {
102
- artifactId
103
- from(components. java)
104
- artifact getArtifact(getLibExtension(), osdetector. classifier)
105
- pom {
106
- name = ' DataFusion Java'
107
- description = ' A Java binding to Apache Arrow DataFusion library'
112
+ scm {
113
+ connection
= ' scm:git:[email protected] :datafusion-contrib/datafusion-java.git'
114
+ developerConnection = ' scm:git:https://github.com/datafusion-contrib/datafusion-java.git'
108
115
url = ' https://github.com/datafusion-contrib/datafusion-java'
109
- licenses {
110
- license {
111
- name = ' The Apache License, Version 2.0'
112
- url = ' http://www.apache.org/licenses/LICENSE-2.0.txt'
113
- }
114
- }
115
- developers {
116
- developer {
117
- id = ' dev'
118
- name = ' Apache Arrow Developers'
119
-
120
- }
121
- }
122
- scm {
123
- connection
= ' scm:git:[email protected] :datafusion-contrib/datafusion-java.git'
124
- developerConnection = ' scm:git:https://github.com/datafusion-contrib/datafusion-java.git'
125
- url = ' https://github.com/datafusion-contrib/datafusion-java'
126
- }
127
116
}
128
117
}
129
118
}
130
-
131
119
}
132
120
repositories {
133
121
maven {
@@ -136,13 +124,24 @@ publishing {
136
124
def snapshotsRepoUrl = " https://s01.oss.sonatype.org/content/repositories/snapshots/"
137
125
url = version. endsWith(' SNAPSHOT' ) ? snapshotsRepoUrl : releasesRepoUrl
138
126
credentials {
139
- username = System . getenv( " MAVEN_USERNAME " ) != null ? System . getenv(" MAVEN_USERNAME" ) : findProperty( ' ossrhUsername ' )
140
- password = System . getenv( " MAVEN_PASSWORD " ) != null ? System . getenv(" MAVEN_PASSWORD" ) : findProperty( ' ossrhPassword ' )
127
+ username = findProperty( ' ossrhUsername ' ) ?: System . getenv(" MAVEN_USERNAME" )
128
+ password = findProperty( ' ossrhPassword ' ) ?: System . getenv(" MAVEN_PASSWORD" )
141
129
}
142
130
}
143
131
}
144
132
}
145
133
134
+ def artifacts = publishing. publications. mavenJava. artifacts
135
+
136
+ if (jniLibLinux. get(). asFile. exists()) {
137
+ artifacts. artifact jarWithLinuxLib
138
+ }
139
+
140
+ if (jniLibOsx. get(). asFile. exists()) {
141
+ artifacts. artifact jarWithOsxLib
142
+ }
143
+
144
+
146
145
signing {
147
146
required { ! version. endsWith(" SNAPSHOT" ) && gradle. taskGraph. hasTask(" publish" ) }
148
147
def signingKeyId = findProperty(" signingKeyId" )
0 commit comments