/* * Copyright LWJGL. All rights reserved. * License terms: http://lwjgl.org/license.php */ project.buildDir = 'bin/MAVEN' apply plugin: "maven" apply plugin: "signing" project.group = "org.lwjgl" project.version = lwjglVersion def PATHS = [ release: 'bin/RELEASE' ] // Set build variables based on build type (release, continuous integration, development) enum BuildType { LOCAL, SNAPSHOT, RELEASE } class Deployment { BuildType type String repo String user String password } Deployment deployment; if ( hasProperty("release") ) { deployment = new Deployment( type: BuildType.RELEASE, repo: "https://oss.sonatype.org/service/local/staging/deploy/maven2/", user: sonatypeUsername, password: sonatypePassword ) println "Performing release build" } else if ( hasProperty("snapshot") ) { project.version += "-SNAPSHOT" deployment = new Deployment( type: BuildType.SNAPSHOT, repo: "https://oss.sonatype.org/content/repositories/snapshots/", user: sonatypeUsername, password: sonatypePassword ) println "Performing snapshot build" } else { deployment = new Deployment( type: BuildType.LOCAL, repo: repositories.mavenLocal().url ) } println "${deployment.type.name()} BUILD" artifacts { archives file: file("$buildDir/lwjgl.jar"), name: "lwjgl", type: "jar" archives file: file("$buildDir/src.jar"), name: "lwjgl", type: "jar", classifier: "sources" archives file: file("$buildDir/javadoc.jar"), name: "lwjgl", type: "jar", classifier: "javadoc" archives file: file("$buildDir/lwjgl-natives-windows.jar"), name: "lwjgl-platform", type: "jar", classifier: "natives-windows" archives file: file("$buildDir/lwjgl-natives-macosx.jar"), name: "lwjgl-platform", type: "jar", classifier: "natives-osx" archives file: file("$buildDir/lwjgl-natives-linux.jar"), name: "lwjgl-platform", type: "jar", classifier: "natives-linux" } if ( deployment.type == BuildType.RELEASE ) { signing { sign configurations.archives } } else { task signArchives { // do nothing } } def lwjglPOM = { String projectName, String packagingMethod -> return { project { name projectName packaging packagingMethod description 'LWJGL' url 'http://www.lwjgl.org' scm { url 'scm:git@github.com:LWJGL/lwjgl3.git' connection 'scm:git@github.com:LWJGL/lwjgl3.git' developerConnection 'scm:git@github.com:LWJGL/lwjgl3.git' } licenses { license { name 'BSD' url 'http://www.lwjgl.org/license' distribution 'repo' } } developers { developer { id "spasi" name "Ioannis Tsakpinis" } } } } } uploadArchives { repositories { mavenDeployer { repository(url: deployment.repo) { authentication(userName: deployment.user, password: deployment.password) } if ( deployment.type == BuildType.RELEASE ) { beforeDeployment { signing.signPom(it) } } addFilter("lwjgl") { artifact, file -> artifact.name == "lwjgl" } addFilter("lwjgl-platform") { artifact, file -> artifact.name == "lwjgl-platform" } pom("lwjgl", lwjglPOM("LWJGL", "jar")) pom("lwjgl-platform", lwjglPOM("LWJGL Platform", "pom")) } } } task copyArchives(type: Copy) { from "$PATHS.release/jar/lwjgl.jar", "$PATHS.release/src.zip", "$PATHS.release/doc/javadoc.zip" destinationDir file(buildDir) rename { it.replace(".zip", ".jar") } } signArchives.mustRunAfter copyArchives uploadArchives.dependsOn copyArchives [ [include: "*.dll", name: "Windows"], [include: "*.so", name: "Linux"], [include: "*.dylib", name: "MacOSX"] ].each { archive -> def zipNatives = task("zipNatives$archive.name", type: Zip) { from "$PATHS.release/native" include archive.include archiveName "lwjgl-natives-${archive.name.toLowerCase()}.jar" destinationDir file(buildDir) } signArchives.mustRunAfter zipNatives uploadArchives.dependsOn zipNatives }