Skip to content

Commit

Permalink
improved file-not-found handling in Downloader, bumped version to 0.0.12
Browse files Browse the repository at this point in the history
  • Loading branch information
akhikhl committed Jun 22, 2014
1 parent 1c04aa4 commit ab2b20a
Show file tree
Hide file tree
Showing 10 changed files with 162 additions and 138 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
145 changes: 13 additions & 132 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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:[email protected]:${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')
Expand All @@ -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:[email protected]: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
43 changes: 43 additions & 0 deletions libs/common.gradle
Original file line number Diff line number Diff line change
@@ -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
}

70 changes: 70 additions & 0 deletions libs/publish.gradle
Original file line number Diff line number Diff line change
@@ -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)
}
}

3 changes: 2 additions & 1 deletion libs/unpuzzle-eclipse2maven/build.gradle
Original file line number Diff line number Diff line change
@@ -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')
Expand Down
5 changes: 3 additions & 2 deletions libs/unpuzzle-osgi2maven/build.gradle
Original file line number Diff line number Diff line change
@@ -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'
}
}
3 changes: 3 additions & 0 deletions libs/unpuzzle-plugin/build.gradle
Original file line number Diff line number Diff line change
@@ -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()
Expand Down
3 changes: 2 additions & 1 deletion libs/unpuzzle-utils/build.gradle
Original file line number Diff line number Diff line change
@@ -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'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
19 changes: 19 additions & 0 deletions pluginScripts/unpuzzle-0.0.12.plugin
Original file line number Diff line number Diff line change
@@ -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)

0 comments on commit ab2b20a

Please sign in to comment.