def jgit = new org.mdonoughe.JGitDescribeTask() jgit.dir = new File(projectDir, '.git') project.version = jgit.getDescription() + '-SNAPSHOT' group = 'com.dmdirc' apply plugin: 'maven-publish' apply plugin: 'java' apply plugin: 'findbugs' apply plugin: 'pmd' configurations { bundle plugin { transitive = false } compile { extendsFrom bundle } } configurations.all { resolutionStrategy.cacheDynamicVersionsFor 2, 'minutes' resolutionStrategy.cacheChangingModulesFor 2, 'minutes' } dependencies { compile group: 'com.google.code.findbugs', name: 'jsr305', version: '3.0.0' compile group: 'com.squareup.dagger', name: 'dagger-compiler', version: '1.2.1' compile group: 'com.google.auto.value', name: 'auto-value', version: '1.0-rc4' bundle group: 'com.squareup.dagger', name: 'dagger', version: '1.2.1' bundle group: 'com.esotericsoftware.yamlbeans', name: 'yamlbeans', version: '1.08' bundle group: 'com.brsanthu', name: 'migbase64', version: '2.2' bundle group: 'net.kencochrane.raven', name: 'raven', version: '5.0.1' bundle group: 'com.google.guava', name:'guava', version: '18.0' bundle group: 'net.engio', name: 'mbassador', version: '1.2.0' bundle group: 'com.dmdirc', name: 'util', version: '+', changing: true bundle group: 'com.dmdirc.parser', name: 'common', version: '+', changing: true plugin group: 'com.dmdirc', name: 'ui_swing', version: '+', changing: true plugin group: 'com.dmdirc', name: 'parser_irc', version: '+', changing: true plugin group: 'com.dmdirc', name: 'tabcompletion_bash', version: '+', changing: true plugin group: 'com.dmdirc', name: 'tabcompletion_mirc', version: '+', changing: true testCompile group: 'junit', name: 'junit', version: '4.12' testCompile group: 'org.mockito', name: 'mockito-all', version: '1.10.17' testCompile group: 'com.google.jimfs', name: 'jimfs', version: '1.0' pmd group: 'net.sourceforge.pmd', name: 'pmd-core', version: '5.2.3' pmd group: 'net.sourceforge.pmd', name: 'pmd-java', version: '5.2.3' } publishing { publications { mavenJava(MavenPublication) { groupId 'com.dmdirc' artifactId 'client' artifact jar } } repositories { maven { name 'snapshots' url 'http://artifactory.dmdirc.com/artifactory/repo' } } } sourceSets { main { java.srcDirs = ['src'] resources.srcDirs = ['res'] } test { java.srcDirs = ['test'] resources.srcDirs = ['test-res'] } } sourceCompatibility = 1.8 targetCompatibility = 1.8 repositories { mavenCentral() maven { url 'http://artifactory.dmdirc.com/artifactory/repo' } } pmd { ruleSets = [] ruleSetFiles = files("$rootDir/etc/pmd/full.xml") toolVersion = '5.2.3' ignoreFailures = true } tasks.withType(FindBugs) { reports { html.enabled = true xml.enabled = false } } findbugs { reportLevel = 'low' effort = 'max' ignoreFailures = true } task getCredentials << { def target = file('nexus-teamcity.gradle') if (!target.exists()) { new URL('http://www.dmdirc.com/private/nexus-teamcity.gradle').withInputStream{ i -> target.withOutputStream { it << i } } } apply from: 'nexus-teamcity.gradle' project.publishing.repositories[0].credentials { username "$nexusUser" password "$nexusPass" } } task publishSnapshot(dependsOn: ['getCredentials', 'publishMavenJavaPublicationToSnapshotsRepository']) << { } task createVersionConfig { inputs.dir 'src' inputs.dir 'res' outputs.file new File(buildDir, 'version.config') dependsOn classes doLast { def targetFile = new File(buildDir, 'version.config') targetFile.text = '' targetFile << "keysections:\n identity\n version\n updater\n bundledplugins_versions\n\n" targetFile << "identity:\n name=DMDirc version information\n globaldefault=true\n order=95000\n\n" targetFile << "version:\n version=${version}\n\n" targetFile << "updater:\n channel=${updaterChannel}\n\n" targetFile << "buildenv:\n" def compileConfiguration = project.configurations.getByName("compile") def resolvedConfiguration = compileConfiguration.resolvedConfiguration def resolvedArtifacts = resolvedConfiguration.resolvedArtifacts resolvedArtifacts.each { dp -> def version = dp.moduleVersion.id targetFile << " " + version.group + " " + version.name + " " + version.version + "\n" } } } task createFatVersionConfig { inputs.file new File(buildDir, 'version.config') outputs.file new File(buildDir, 'fat.version.config') dependsOn createVersionConfig doLast { def sourceFile = new File(buildDir, 'version.config') def targetFile = new File(buildDir, 'fat.version.config') java.nio.file.Files.copy(sourceFile.toPath(), targetFile.toPath(), java.nio.file.StandardCopyOption.REPLACE_EXISTING) targetFile << "\nbundledplugins_versions:\n" configurations.plugin.each { p -> targetFile << " " + p.name.replaceFirst('-', '=').replaceAll('.jar$', '\n'); } } } test.dependsOn createVersionConfig jar { outputs.file "dist/DMDirc.jar" dependsOn createVersionConfig exclude 'com/dmdirc/version.config' from("$buildDir/version.config") { into 'com/dmdirc/' } from { configurations.bundle.collect { it.isDirectory() ? it : zipTree(it) } } { exclude 'META-INF/**' } manifest { attributes 'Main-Class': 'com.dmdirc.Main' } doLast { copy { from jar.archivePath into "dist/" rename ".*", "DMDirc.jar" } } } task('fatjar', type: Jar) { dependsOn createFatVersionConfig baseName = 'fat-client' from("$buildDir/fat.version.config") { into 'com/dmdirc' rename 'fat.version.config', 'version.config' } into('plugins') { from configurations.plugin rename '(.*?)-.*(\\.jar)', '$1$2' } with jar { exclude 'com/dmdirc/version.config' } manifest { attributes 'Main-Class': 'com.dmdirc.Main' } } buildscript { repositories { mavenCentral() maven { url 'http://artifactory.dmdirc.com/artifactory/repo' } } dependencies { classpath group: 'com.github.shanemcc', name: 'jgit-describe', version: '0.5' classpath group: 'org.eclipse.jgit', name: 'org.eclipse.jgit', version: '2.3.1.+' } } task wrapper(type: Wrapper) { gradleVersion = '2.2.1' }