-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
127 lines (111 loc) · 4.87 KB
/
build.gradle
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
buildscript {
repositories {
mavenCentral()
jcenter()
}
dependencies {
// https://mvnrepository.com/artifact/com.nativelibs4java/jnaerator
classpath "com.nativelibs4java:jnaerator:0.12"
}
}
plugins {
// Apply the java plugin to add support for Java
id 'java'
id 'maven-publish'
id 'signing'
}
group = 'io.github.cyberpython'
version = '0.0.2'
def VLC_INCLUDES_DIR = '../third_party/vlc/include'
task generateBindings(type:JavaExec) {
main = "com.ochafik.lang.jnaerator.JNAerator"
classpath = buildscript.configurations.classpath
args "-f", "-noComments", "-arch", "linux_x64", "-arch", "win64", "-rootPackage", "io.github.cyberpython.libjvlc", "-package", "io.github.cyberpython.libjvlc", "-library", "vlc", "-runtime", "JNA", "-mode", "Directory", "${VLC_INCLUDES_DIR}/vlc/libvlc.h", "${VLC_INCLUDES_DIR}/vlc/libvlc_media.h", "${VLC_INCLUDES_DIR}/vlc/libvlc_media_player.h", "${VLC_INCLUDES_DIR}/vlc/libvlc_vlm.h", "-o", "${project.sourceSets.main.java.srcDirs[0]}"
}
task fixBindings{
dependsOn generateBindings
doFirst{
// Fix the return type of getFieldOrder to work with JNA 5.x:
ant.replaceregexp(match:'List\\<\\? \\>', replace:'List<String>', flags:'g', byline:true) {
fileset(dir: "${project.sourceSets.main.java.srcDirs[0]}/io/github/cyberpython/libjvlc", includes: '*.java')
}
// Fix type of int expression assigned to char by adding cast:
ant.replaceregexp(match:"\\= '([a-z])' \\<\\< ([0-9]+);", replace:"\\= \\(char\\) \\('\\1' \\<\\< \\2\\);", flags:'g', byline:true) {
fileset(dir: "${project.sourceSets.main.java.srcDirs[0]}/io/github/cyberpython/libjvlc", includes: 'VlcLibrary.java')
}
// Replace unused deprecated version of libvlc_media_parse_with_options() with libvlc_media_parse (WARNING: may not be present in VLC 3.x+ API)
ant.replaceregexp(match:"int libvlc_media_parse_with_options\\(Pointer p_md, int parse_flag, int timeout\\);", replace:"int libvlc_media_parse\\(PointerByReference p_md\\);", flags:'g', byline:true) {
fileset(dir: "${project.sourceSets.main.java.srcDirs[0]}/io/github/cyberpython/libjvlc", includes: 'VlcLibrary.java')
}
// Replace NativeSize from JNAerator's runtime with custom one:
ant.replaceregexp(match:"import com\\.ochafik\\.lang\\.jnaerator\\.runtime\\.NativeSize;", replace:"import io\\.github\\.cyberpython\\.jna\\.NativeSize;", flags:'g', byline:true) {
fileset(dir: "${project.sourceSets.main.java.srcDirs[0]}/io/github/cyberpython/libjvlc", includes: '*.java')
}
}
}
compileJava.dependsOn fixBindings
repositories {
jcenter()
}
dependencies {
implementation group: 'net.java.dev.jna', name: 'jna', version: '5.8.0'
// To get the OS name
implementation group: 'org.apache.commons', name: 'commons-lang3', version: '3.12.0'
// Use JUnit test framework
testImplementation 'junit:junit:4.12'
}
publishing {
publications {
mavenJava(MavenPublication) {
groupId = 'io.github.cyberpython'
artifactId = 'libjvlc'
from components.java
versionMapping {
usage('java-api') {
fromResolutionOf('runtimeClasspath')
}
usage('java-runtime') {
fromResolutionResult()
}
}
pom {
name = 'libjvlc'
description = 'Java bindings (JNA-based) for libvlc'
url = 'https://github.com/cyberpython/libjvlc'
licenses {
license {
name = 'GNU LGPL 2.1'
url = 'https://www.gnu.org/licenses/old-licenses/lgpl-2.1.en.html'
}
}
developers {
developer {
id = 'cyberpython'
name = 'George Migdos'
email = '[email protected]'
}
}
scm {
connection = 'scm:git:https://github.com/cyberpython/libjvlc.git'
developerConnection = 'scm:git:https://github.com/cyberpython/libjvlc.git'
url = 'https://github.com/cyberpython/libjvlc'
}
}
}
}
repositories {
maven {
name = 'ossrh'
credentials {
username "$ossrhUsername"
password "$ossrhPassword"
}
def releasesRepoUrl = 'https://s01.oss.sonatype.org/content/repositories/releases/'
def snapshotsRepoUrl = 'https://s01.oss.sonatype.org/content/repositories/snapshots/'
url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl
}
}
}
signing {
sign publishing.publications.mavenJava
}