diff --git a/README.md b/README.md index e614148..109a900 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ [![Maintainer Status](http://stillmaintained.com/akhikhl/unpuzzle.png)](http://stillmaintained.com/akhikhl/unpuzzle) [![Build Status](https://travis-ci.org/akhikhl/unpuzzle.png?branch=master)](https://travis-ci.org/akhikhl/unpuzzle) -[![Latest Version](http://img.shields.io/badge/latest_version-0.0.11-3f6498.svg)](https://github.com/akhikhl/unpuzzle/tree/v0.0.11) +[![Latest Version](http://img.shields.io/badge/latest_version-0.0.12-3f6498.svg)](https://github.com/akhikhl/unpuzzle/tree/v0.0.12) [![License](http://img.shields.io/badge/license-MIT-d63434.svg)](#copyright-and-license) **Unpuzzle** is a set of tools for mavenizing OSGi-bundles. You can consume Unpuzzle in two forms: diff --git a/build.gradle b/build.gradle index 0f3b93e..b53c928 100644 --- a/build.gradle +++ b/build.gradle @@ -12,11 +12,23 @@ buildscript { ext { group = 'org.akhikhl.unpuzzle' - version = '0.0.11' + version = '0.0.12' groovy_version = '1.8.6' spock_version = '0.7-groovy-1.8' + + project_id = 'unpuzzle' + project_description = 'Tool for mavenizing OSGi-bundles' + developer_id = 'akhikhl' + developer_name = 'Andrey Hihlovskiy' + project_website = "https://github.com/${developer_id}/${project_id}" + project_scm = "scm:git@github.com:${developer_id}/${project_id}.git" + license = 'The MIT License' + license_url = "https://raw.github.com/${developer_id}/${project_id}/master/LICENSE" + labels = ['unpuzzle', 'gradle', 'plugin', 'eclipse', 'osgi', 'maven'] } +description = ext.project_description + apply plugin: 'base' // add "clean" task to the root project. task('build') @@ -35,134 +47,3 @@ task('cleanExamples', type: GradleBuild) { task -> // clean.dependsOn cleanExamples -subprojects { - if(project.parent.name == 'libs') { - - apply plugin: 'maven' - apply plugin: 'groovy' - apply plugin: 'signing' - apply plugin: 'maven-publish' - apply plugin: 'bintray' - - repositories { - mavenLocal() - jcenter() - mavenCentral() - } - - group = rootProject.ext.group - version = rootProject.ext.version - - dependencies { - compile "org.codehaus.groovy:groovy-all:${rootProject.ext.groovy_version}" - testCompile "org.spockframework:spock-core:${rootProject.ext.spock_version}" - } - - // lib projects should be always installed into "$HOME/.m2" - project.tasks.build.finalizedBy project.tasks.install - rootProject.tasks.buildExamples.dependsOn project.tasks.install - - task sourcesJar(type: Jar, dependsOn: classes, description: 'Creates sources jar') { - classifier = 'sources' - from sourceSets.main.allSource - } - - task javadocJar(type: Jar, description: 'Creates javadoc jar') { - dependsOn javadoc - classifier = 'javadoc' - from javadoc.destinationDir - if(tasks.findByName('groovydoc')) { - dependsOn groovydoc - from groovydoc.destinationDir - } - } - - artifacts { - archives sourcesJar, javadocJar - } - - if(project.hasProperty('publishToSonatype')) { - - assert project.hasProperty('signing.keyId') - assert project.hasProperty('signing.password') - assert project.hasProperty('signing.secretKeyRingFile') - assert project.hasProperty('sonatypeUsername') - assert project.hasProperty('sonatypePassword') - - signing { - sign configurations.archives - } - - uploadArchives { - repositories { - mavenDeployer { - beforeDeployment { deployment -> signing.signPom(deployment) } - - repository(url: 'https://oss.sonatype.org/service/local/staging/deploy/maven2/') { - authentication(userName: project.sonatypeUsername, password: project.sonatypePassword) - } - - pom.project { - name project.name - packaging 'jar' - description 'Tools for mavenizing OSGi-bundles' - url 'https://github.com/akhikhl/unpuzzle' - - scm { - url 'scm:https://github.com/akhikhl/unpuzzle.git' - connection 'scm:https://github.com/akhikhl/unpuzzle.git' - developerConnection 'scm:git@github.com:akhikhl/unpuzzle.git' - } - - licenses { - license { - name 'The MIT License' - url 'https://raw.github.com/akhikhl/unpuzzle/master/license.txt' - distribution 'repo' - } - } - - developers { - developer { - id 'akhikhl' - name 'Andrey Hihlovskiy' - } - } - } - } - } - } // uploadArchives - } // publishToSonatype - - // used by bintray - publishing { - publications { - mavenAll(MavenPublication) { - if (plugins.hasPlugin('java')) { - from components.java - } - artifact sourcesJar { - classifier "sources" - } - artifact javadocJar { - classifier "javadoc" - } - } - } - } // publishing - - bintray { - user = project.hasProperty('bintrayUser') ? project.bintrayUser : '' - key = project.hasProperty('bintrayKey') ? project.bintrayKey : '' - publications = ['mavenAll'] // When uploading Maven-based publication files - pkg { - repo = 'maven' - name = 'unpuzzle' - desc = 'Tools for mavenizing OSGi-bundles' - licenses = ['MIT'] - labels = ['unpuzzle', 'gradle', 'plugin', 'osgi', 'eclipse'] - } - dryRun = false - } - } // if libs -} // subprojects diff --git a/libs/common.gradle b/libs/common.gradle new file mode 100644 index 0000000..85b9946 --- /dev/null +++ b/libs/common.gradle @@ -0,0 +1,43 @@ +// include this file in subprojects: +// apply from: rootProject.file('libs/common.gradle') + +apply plugin: 'maven' +apply plugin: 'groovy' + +repositories { + mavenLocal() + jcenter() + mavenCentral() +} + +group = rootProject.ext.group +version = rootProject.ext.version + +dependencies { + compile "org.codehaus.groovy:groovy-all:${rootProject.ext.groovy_version}" + testCompile "org.spockframework:spock-core:${rootProject.ext.spock_version}" +} + +// lib projects should be always installed into "$HOME/.m2" +project.tasks.build.finalizedBy project.tasks.install +rootProject.tasks.buildExamples.dependsOn project.tasks.install + +task sourcesJar(type: Jar, dependsOn: classes, description: 'Creates sources jar') { + classifier = 'sources' + from sourceSets.main.allSource +} + +task javadocJar(type: Jar, description: 'Creates javadoc jar') { + dependsOn javadoc + classifier = 'javadoc' + from javadoc.destinationDir + if(tasks.findByName('groovydoc')) { + dependsOn groovydoc + from groovydoc.destinationDir + } +} + +artifacts { + archives sourcesJar, javadocJar +} + diff --git a/libs/publish.gradle b/libs/publish.gradle new file mode 100644 index 0000000..b4cd3e1 --- /dev/null +++ b/libs/publish.gradle @@ -0,0 +1,70 @@ +// include this file in subprojects: +// apply from: rootProject.file('libs/publish.gradle') + +apply plugin: 'signing' +apply plugin: 'maven-publish' +apply plugin: 'bintray' + +import org.gradle.api.internal.artifacts.publish.DefaultPublishArtifact + +def thisProject = project + +install.repositories.mavenInstaller.pom*.whenConfigured { pom -> + pom.project { + name thisProject.name + packaging 'jar' + description thisProject.project_description + url thisProject.project_website + + scm { + url thisProject.project_scm + connection thisProject.project_scm + developerConnection thisProject.project_scm + } + + licenses { + license { + name thisProject.license + url thisProject.license_url + distribution 'repo' + } + } + + developers { + developer { + id thisProject.developer_id + name thisProject.developer_name + } + } + } +} + +bintray { + user = project.hasProperty('bintrayUser') ? project.bintrayUser : '' + key = project.hasProperty('bintrayKey') ? project.bintrayKey : '' + configurations = ['archives'] + pkg { + repo = 'maven' + name = thisProject.rootProject.project_id + desc = thisProject.rootProject.description + licenses = ['MIT'] + labels = thisProject.rootProject.labels + } + dryRun = false +} + +bintrayUpload { + doFirst { + def signatureArtifacts = [] + collectArtifacts(project.configurations.archives).each { a -> + def s = signing.sign(a.file) + s.signatureFiles.each { f -> + def fname = f.name + def ext = fname.substring(fname.lastIndexOf('.') + 1) + signatureArtifacts.add(new DefaultPublishArtifact(a.name, a.extension + '.' + ext, ext, a.classifier, new Date(), f, [] as Object[])) + } + } + project.configurations.archives.artifacts.addAll(signatureArtifacts) + } +} + diff --git a/libs/unpuzzle-eclipse2maven/build.gradle b/libs/unpuzzle-eclipse2maven/build.gradle index 2af5d58..fc28114 100644 --- a/libs/unpuzzle-eclipse2maven/build.gradle +++ b/libs/unpuzzle-eclipse2maven/build.gradle @@ -1,4 +1,5 @@ -apply plugin: 'groovy' +apply from: rootProject.file('libs/common.gradle') +apply from: rootProject.file('libs/publish.gradle') dependencies { compile project(':libs:unpuzzle-osgi2maven') diff --git a/libs/unpuzzle-osgi2maven/build.gradle b/libs/unpuzzle-osgi2maven/build.gradle index 27e387d..1fe46d9 100644 --- a/libs/unpuzzle-osgi2maven/build.gradle +++ b/libs/unpuzzle-osgi2maven/build.gradle @@ -1,7 +1,8 @@ -apply plugin: 'groovy' +apply from: rootProject.file('libs/common.gradle') +apply from: rootProject.file('libs/publish.gradle') dependencies { compile 'org.osgi:org.osgi.core:5.0.0' compile 'org.apache.maven:maven-ant-tasks:2.1.3' testCompile 'xmlunit:xmlunit:1.4' -} \ No newline at end of file +} diff --git a/libs/unpuzzle-plugin/build.gradle b/libs/unpuzzle-plugin/build.gradle index 23561d6..d0a1613 100644 --- a/libs/unpuzzle-plugin/build.gradle +++ b/libs/unpuzzle-plugin/build.gradle @@ -1,3 +1,6 @@ +apply from: rootProject.file('libs/common.gradle') +apply from: rootProject.file('libs/publish.gradle') + dependencies { compile project(':libs:unpuzzle-eclipse2maven') compile gradleApi() diff --git a/libs/unpuzzle-utils/build.gradle b/libs/unpuzzle-utils/build.gradle index c21e46d..b6c8d8e 100644 --- a/libs/unpuzzle-utils/build.gradle +++ b/libs/unpuzzle-utils/build.gradle @@ -1,4 +1,5 @@ -apply plugin: 'groovy' +apply from: rootProject.file('libs/common.gradle') +apply from: rootProject.file('libs/publish.gradle') dependencies { compile 'commons-io:commons-io:2.4' diff --git a/libs/unpuzzle-utils/src/main/groovy/org/akhikhl/unpuzzle/utils/Downloader.groovy b/libs/unpuzzle-utils/src/main/groovy/org/akhikhl/unpuzzle/utils/Downloader.groovy index e67823e..e4a3cd9 100644 --- a/libs/unpuzzle-utils/src/main/groovy/org/akhikhl/unpuzzle/utils/Downloader.groovy +++ b/libs/unpuzzle-utils/src/main/groovy/org/akhikhl/unpuzzle/utils/Downloader.groovy @@ -65,7 +65,12 @@ final class Downloader { } void downloadFile(URL url, File file) throws IOException { - long remoteContentLength = Long.parseLong(url.openConnection().getHeaderField('Content-Length')) + Long remoteContentLength + try { + remoteContentLength = Long.parseLong(url.openConnection().getHeaderField('Content-Length')) + } catch(NumberFormatException e) { + // no header, download anyway + } if (file.exists() && remoteContentLength == file.length()) { console.info("File ${file.getName()} already downloaded, skipping download") return diff --git a/pluginScripts/unpuzzle-0.0.12.plugin b/pluginScripts/unpuzzle-0.0.12.plugin new file mode 100644 index 0000000..b639f05 --- /dev/null +++ b/pluginScripts/unpuzzle-0.0.12.plugin @@ -0,0 +1,19 @@ +buildscript { + repositories { + mavenLocal() + jcenter() + mavenCentral() + } + + dependencies { + classpath 'org.akhikhl.unpuzzle:unpuzzle-plugin:0.0.12' + } +} + +// apply plugin: 'unpuzzle-plugin' + +import org.akhikhl.unpuzzle.UnpuzzlePlugin + +if (!project.plugins.findPlugin(UnpuzzlePlugin)) + project.apply(plugin: UnpuzzlePlugin) +