Skip to content

Commit

Permalink
fixes #3, #4, #5, #6
Browse files Browse the repository at this point in the history
  • Loading branch information
aalmiray committed Mar 5, 2014
1 parent f26db24 commit 2cd596d
Show file tree
Hide file tree
Showing 11 changed files with 141 additions and 141 deletions.
11 changes: 5 additions & 6 deletions README.adoc
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
= Gipsy
:author: Andres Almiray
:version: 0.3.0
:version: 0.4.0

image::https://travis-ci.org/aalmiray/gipsy.png?branch=master["Build Status", link="https://travis-ci.org/aalmiray/gipsy"]

image::https://d2weczhvl823v0.cloudfront.net/aalmiray/gipsy/trend.png["Bitdeli Badge", link="https://bitdeli.com/free"]
image:https://travis-ci.org/aalmiray/gipsy.png?branch=master["Build Status", link="https://travis-ci.org/aalmiray/gipsy"]
image:http://img.shields.io/:semver-{version}-blue.svg["Semantic Versioning", link="http://semver.org"]

image::https://api.bintray.com/packages/aalmiray/kordamp/jipsy/images/download.png["Bintray", link="https://bintray.com/aalmiray/kordamp/gipsy/{version}"]

Expand All @@ -29,7 +28,6 @@ This library provides a mechanism for enforcing those rules by simply adding an
example say there exists the following `Calculator` service interface

[source,groovy]
[subs="verbatim,attributes"]
----
package com.acme
Expand All @@ -41,7 +39,6 @@ interface Calculator {
A basic implementation of such service may be as follows

[source,groovy]
[subs="verbatim,attributes"]
----
package com.acme
Expand Down Expand Up @@ -112,3 +109,5 @@ consumers of your library.
== Creating Your Own AST Transformations

TBD

image::https://d2weczhvl823v0.cloudfront.net/aalmiray/gipsy/trend.png["Bitdeli Badge", link="https://bitdeli.com/free"]
31 changes: 28 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,25 @@
* limitations under the License.
*/

buildscript {
repositories {
jcenter()
}

dependencies {
classpath 'net.saliman:gradle-cobertura-plugin:2.2.2'
classpath 'org.kt3k.gradle.plugin:coveralls-gradle-plugin:0.2.4'
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:0.3'
}
}

apply plugin: 'idea'
apply plugin: 'java'
apply plugin: 'cobertura'
apply plugin: 'coveralls'
apply plugin: 'build-dashboard'
apply from: 'gradle/idea.gradle'
apply from: 'gradle/coverage.gradle'
apply from: 'gradle/codeQuality.gradle'
apply from: 'gradle/code-quality.gradle'
apply from: 'gradle/publish.gradle'

repositories {
Expand All @@ -33,8 +46,20 @@ dependencies {
testCompile 'junit:junit:4.11'
}

cobertura {
coverageFormats = ['html', 'xml']
coverageSourceDirs = sourceSets.main.java.srcDirs
}

task sourceJar(type: Jar) {
from sourceSets.main.allJava
group 'Build'
description 'An archive of the source code'
from sourceSets.main.allSource
classifier 'sources'
}

artifacts {
sourceJar
}

compileJava {
Expand Down
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
version=0.3.0
version=0.4.0
group=org.kordamp.gipsy
groovyVersion=2.2.1
groovyVersion=2.2.2

sourceCompatibility = 1.6
targetCompatibility = 1.6
File renamed without changes.
80 changes: 0 additions & 80 deletions gradle/coverage.gradle

This file was deleted.

110 changes: 67 additions & 43 deletions gradle/publish.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,53 +16,15 @@

import java.text.SimpleDateFormat

apply plugin: 'maven-publish'

publishing {
publications {
mavenJava(MavenPublication) {
from components.java

pom.withXml {
asNode().with {
appendNode('name', 'gipsy')
appendNode('description',
'Groovy version of the Jipsy Annotation Processor')
appendNode('url', 'http://github.com/aalmiray/gipsy')
appendNode('inceptionYear', '2013')
appendNode('licenses')
.appendNode('license')
.appendNode('name', 'The Apache Software License, Version 2.0').parent()
.appendNode('url', 'http://www.apache.org/licenses/LICENSE-2.0.txt').parent()
.appendNode('distribution', 'repo')
appendNode('scm')
.appendNode('url', 'https://github.com/aalmiray/gipsy')
Node developers = appendNode('developers')
[
aalmiray: 'Andres Almiray',
].each { devId, devName ->
developers.appendNode('developer')
.appendNode('id', devId).parent()
.appendNode('name', devName).parent()
.appendNode('roles')
.appendNode('role', 'Developer')
}
}
}

artifact sourceJar {
classifier "sources"
}
}
}
}

Date buildTimeAndDate = new Date()
ext {
buildTime = new SimpleDateFormat('dd-MMM-yyyy').format(buildTimeAndDate)
buildDate = new SimpleDateFormat('hh:mm aa').format(buildTimeAndDate)
buildTime = new SimpleDateFormat('yyyy-MM-dd').format(buildTimeAndDate)
buildDate = new SimpleDateFormat('HH:mm:ss.SSSZ').format(buildTimeAndDate)
}

apply plugin: 'maven-publish'
apply plugin: 'bintray'

jar {
manifest {
attributes(
Expand All @@ -78,4 +40,66 @@ jar {
'Implementation-Vendor': 'Kordamp'
)
}
}

def pomConfig = {
name project.name
description 'Groovy version of Jipsy, a configurable AST Transformation to simplify the use of the Service Provider Interface.'
url 'http://github.com/aalmiray/gipsy'
inceptionYear '2013'
licenses {
license([:]) {
name 'The Apache Software License, Version 2.0'
url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
distribution 'repo'
}
}
scm {
url 'https://github.com/aalmiray/gipsy'
}
developers {
[
aalmiray: 'Andres Almiray',
].each { devId, devName ->
developer {
id devId
name devName
roles {
role 'Developer'
}
}
}
}
}

publishing {
publications {
mavenCustom(MavenPublication) {
from components.java
artifact sourceJar

pom.withXml {
asNode().children().last() + pomConfig
}
}
}
}

task install(dependsOn: publishToMavenLocal)

if (!project.hasProperty('bintrayUsername')) ext.bintrayUsername = ''
if (!project.hasProperty('bintrayApiKey')) ext.bintrayApiKey = ''

bintray {
user = project.bintrayUsername
key = project.bintrayApiKey
publications = ['mavenCustom']
pkg {
repo = 'kordamp'
userOrg = 'aalmiray'
name = 'gipsy'
desc = 'Groovy version of Jipsy, a configurable AST Transformation to simplify the use of the Service Provider Interface.'
licenses = ['Apache-2.0']
labels = ['groovy', 'jipsy', 'gipsy', 'annotation', 'processor']
}
}
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Wed Dec 25 23:53:16 CET 2013
#Fri Feb 28 15:36:50 CET 2014
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=http\://services.gradle.org/distributions/gradle-1.10-bin.zip
distributionUrl=http\://services.gradle.org/distributions/gradle-1.11-bin.zip
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,31 @@
* @author Andres Almiray
*/
public abstract class AbstractFilePersistence extends AbstractPersistence {
private static final String DEFAULT_TARGET_DIR = "org.kordamp.gipsy.DEFAULT_TARGET_DIR";

protected final File outputDir;

public AbstractFilePersistence(File outputDir, String name, Logger logger, String path) {
super(name, logger, path);
this.outputDir = outputDir;
if (outputDir == null) {
String defaultPath = System.getProperty(DEFAULT_TARGET_DIR);
if (defaultPath != null && defaultPath.trim().length() > 0) {
try {
this.outputDir = new File(defaultPath);
this.outputDir.mkdirs();
} catch (Exception e) {
throw new IllegalArgumentException(e);
}
} else {
try {
this.outputDir = File.createTempFile(new File(path).getName(), "");
} catch (IOException e) {
throw new IllegalArgumentException(e);
}
}
} else {
this.outputDir = outputDir;
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import org.kordamp.jipsy.processor.ProcessorLogger;
import org.kordamp.jipsy.processor.service.ServiceProviderProcessor;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

Expand All @@ -49,7 +50,18 @@ public void visit(ASTNode[] nodes, SourceUnit source) {
return;
}

String mainClassName = moduleNode.getMainClassName();
PackageNode modulePackage = moduleNode.getPackage();
List<AnnotationNode> packageAnnotations = modulePackage != null ? modulePackage.getAnnotations() : new ArrayList<AnnotationNode>();

for (ClassNode classNode : moduleNode.getClasses()) {
if (classNode.isDerivedFrom(ClassHelper.SCRIPT_TYPE) &&
mainClassName.equals(classNode.getName()) &&
!packageAnnotations.isEmpty()) {
process(classNode, packageAnnotations, moduleNode);
continue;
}

List<AnnotationNode> annotations = classNode.getAnnotations(getAnnotationClassNode());
if (annotations.isEmpty()) {
continue;
Expand Down Expand Up @@ -83,7 +95,7 @@ protected final void process(ClassNode classNode, List<AnnotationNode> annotatio
public static boolean hasNoArgsConstructor(ClassNode classNode) {
for (ConstructorNode constructorNode : classNode.getDeclaredConstructors()) {
Parameter[] parameters = constructorNode.getParameters();
if (parameters == null || parameters.length == 0) {
if (constructorNode.isPublic() && parameters == null || parameters.length == 0) {
return true;
}
}
Expand Down
Loading

0 comments on commit 2cd596d

Please sign in to comment.