buildscript { repositories { maven { url "https://plugins.gradle.org/m2/" } } dependencies { classpath "com.bmuschko:gradle-tomcat-plugin:2.2.4" } } subprojects { apply plugin: 'java-library' apply plugin: 'eclipse' apply plugin: 'maven-publish' apply plugin: 'maven' repositories { mavenCentral() maven { url "https://apps.egiz.gv.at/maven/" mavenContent { releasesOnly() } } maven { url "https://apps.egiz.gv.at/maven-snapshot/" mavenContent { snapshotsOnly() } } } dependencies { testImplementation 'junit:junit:4.13.2' } version = '3.1.4-RC2' jar { manifest.attributes provider: 'EGIZ', 'Specification-Version': getCheckedOutGitCommitHash(), 'Implementation-Version': project.version } compileJava { sourceCompatibility = 1.8 targetCompatibility = 1.8 } tasks.withType(JavaCompile) { options.compilerArgs << '-Xlint:-options' } publishing { publications { mavenJava(MavenPublication) { from components.java // more goes in here } } repositories { maven { // change to point to your repo, e.g. http://my.org/repo url = "$buildDir/repo" } mavenLocal() } } task deployJar(type: Jar) configurations { deployerJars } //configurations.archives.artifacts.removeAll {PublishArtifact publishArtifact -> publishArtifact.extension == 'zip'} //configurations.archives.artifacts.removeAll { // exclude from the archives configuration all artifacts that were generated by distZip & distTar // def depTasks = it.getBuildDependencies().getDependencies() // depTasks.contains(distZip) || depTasks.contains(distTar) //} dependencies { deployerJars "org.apache.maven.wagon:wagon-ssh:2.9" } uploadArchives { repositories.mavenDeployer { configuration = configurations.deployerJars repository(url: "sftp://apps.egiz.gv.at/maven") { authentication(userName: System.getenv("EGIZ_MAVEN_USER"), password: System.getenv("EGIZ_MAVEN_PASSWORD")) } snapshotRepository(url: "sftp://apps.egiz.gv.at/maven-snaphot") { authentication(userName: System.getenv("EGIZ_MAVEN_USER"), password: System.getenv("EGIZ_MAVEN_PASSWORD")) } } } } def getCheckedOutGitCommitHash() { def gitFolder = "$projectDir/../.git/" def takeFromHash = 40 def head = new File(gitFolder + "HEAD").text.split(":") def isCommit = head.length == 1 if(isCommit) return head[0].trim().take(takeFromHash) def refHead = new File(gitFolder + head[1].trim()) refHead.text.trim().take takeFromHash }