apply plugin: 'java' apply plugin: 'cpp' apply plugin: 'maven' apply plugin: 'eclipse' repositories { maven { url 'https://github.com/Boukefalos/jlibloader/raw/mvn-repo/' } mavenCentral() } dependencies { compile 'com.github.boukefalos:jlibloader:0.2' testCompile 'junit:junit:4.11' } group = 'com.github.boukefalos' project.archivesBaseName = 'wiiscan' version = '0.9' task wrapper(type: Wrapper) { gradleVersion = '1.12' } model { platforms { windows_i386 { architecture 'i386' operatingSystem 'windows' } windows_amd64 { architecture 'amd64' operatingSystem 'windows' } } toolChains { gcc(Gcc) { addPlatformConfiguration(new TargetPlatformConfiguration() { boolean supportsPlatform(Platform platform) { platform.operatingSystem.current && platform.operatingSystem.name == 'windows' && platform.architecture.name == 'amd64' } List getCppCompilerArgs() { ['-m64', '-fpermissive'] } List getCCompilerArgs() { ['-m64'] } List getObjectiveCCompilerArgs() { ['-m64'] } List getObjectiveCppCompilerArgs() { ['-m64'] } List getAssemblerArgs() { ['--64'] } List getLinkerArgs() { ['-m64'] } List getStaticLibraryArchiverArgs() { [] } }) } } repositories { libs(PrebuiltLibraries) { usb { lib -> binaries.withType(StaticLibraryBinary) { staticLibraryFile = file("lib/${targetPlatform.name}/libusb-1.0.dll") } } } } } libraries { main { baseName project.archivesBaseName } all { binaries.all { linker.args '-Wl,--kill-at', '-static-libgcc', '-static-libstdc++' // lib library: 'usb', linkage: 'static' } } } tasks.withType(Upload) { repositories { mavenDeployer { repository(url: uri('.maven')) } } } configurations { jni } def deployer = uploadJni.repositories.mavenDeployer binaries.withType(SharedLibraryBinary) { binary -> if (!buildable) { return } def variantName = "${targetPlatform.operatingSystem.name}-${targetPlatform.architecture.name}" def taskName = "jar-${variantName}" def nativeJar = project.tasks.findByName(taskName) if (nativeJar == null) { nativeJar = project.task(taskName, type: Jar) { baseName = "${project.archivesBaseName}-$variantName" } artifacts { jni nativeJar } def jniPom = deployer.addFilter(variantName) { artifact, file -> return file == nativeJar.archivePath } jniPom.groupId = project.group jniPom.artifactId = nativeJar.baseName jniPom.version = version jniPom.scopeMappings.mappings.clear() } def builderTask = binary.tasks.builder def libraryDirectory = project.group.replace('.', '/') + "/${project.archivesBaseName}/${variantName}" nativeJar.into(libraryDirectory) { from builderTask.outputFile from file("lib/${targetPlatform.name}/libusb0.dll") } // nativeJar.dependsOn builderTask } def mainPom = uploadArchives.repositories.mavenDeployer.pom mainPom.groupId = project.group mainPom.artifactId = jar.baseName mainPom.version = project.version mainPom.scopeMappings.mappings.clear() mainPom.withXml { provider -> def node = provider.asNode() def deps = node.appendNode('dependencies') ['windows-amd64', 'windows-i386'].each { platform -> def dep = deps.appendNode('dependency') dep.appendNode('groupId', project.group) dep.appendNode('artifactId', "${project.archivesBaseName}-${platform}") dep.appendNode('version', jniVersion) } def dep = deps.appendNode('dependency') dep.appendNode('groupId', 'com.github.boukefalos') dep.appendNode('artifactId', 'jlibloader') dep.appendNode('version', '0.3') }