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' version = '3.2.2-SNAPSHOT' 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' } 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 } dependencies { deployerJars "org.apache.maven.wagon:wagon-ssh:3.4.3" } 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-snapshot") { 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 }