Skip to content
Browse files

migration from maven to gradle

  • Loading branch information...
1 parent d70d1b1 commit 9827699f771ca8df7083699f8e52eae90bb6ddef Andre Steingress committed Jan 14, 2011
View
2 .gitignore
@@ -1,6 +1,8 @@
.idea
.DS_Store
+.gradle
out
+build
target
settings.xml
gcontracts.iml
View
3 META-INF/services/org.codehaus.groovy.transform.ASTTransformation
@@ -1,2 +1 @@
-org.gcontracts.ast.ContractValidationASTTransformation
-org.gcontracts.ast.ClosureAnnotationErasingASTTransformation
+org.gcontracts.ast.GContractsASTTransformation
View
130 build.gradle
@@ -0,0 +1,130 @@
+buildscript {
+ repositories {
+ mavenCentral()
+ }
+ dependencies {
+ classpath 'de.huxhorn.gradle:de.huxhorn.gradle.pgp-plugin:0.0.3'
+ }
+}
+
+apply plugin: 'groovy'
+apply plugin: 'maven'
+apply plugin: de.huxhorn.gradle.pgp.PgpPlugin
+
+group = "org.gcontracts"
+version = "1.1.3"
+
+// libs
+junit = "junit:junit:3.8.1"
+
+description = "GContracts provides closure annotations to support design by contract (tm) for Groovy"
+
+targetCompatibility = "1.5"
+sourceCompatibility = "1.5"
+
+// specifies all Maven repositories for resolving external depedencies
+repositories {
+ mavenCentral()
+}
+
+compileGroovy.options.fork = false
+compileTestGroovy.options.fork = false
+
+// external dependencies
+dependencies {
+ groovy group: 'org.codehaus.groovy', name: 'groovy', version: '1.7.6'
+ testCompile junit
+}
+
+test {
+ // exclude basic test case classes
+ excludes = ['org/gcontracts/tests/basic/**']
+}
+
+// custom tasks for creating source/javadoc jars
+task sourcesJar(type: Jar, dependsOn:classes) {
+ classifier = 'sources'
+ from sourceSets.main.allSource
+}
+
+task javadocJar(type: Jar, dependsOn:javadoc) {
+ classifier = 'javadoc'
+ from javadoc.destinationDir
+}
+
+// add javadoc/source jar the artifacts
+artifacts {
+ archives sourcesJar
+ archives javadocJar
+}
+
+pgp {
+ secretKeyRingFile = new File("${System.properties['user.home']}/.gnupg/secring.gpg")
+}
+
+uploadArchives {
+ repositories.mavenDeployer {
+ configuration = configurations.archives
+
+ repository(url: "http://oss.sonatype.org/service/local/staging/deploy/maven2/") {
+ authentication(userName: nexusUsername, password: nexusPassword)
+ }
+
+ pom.project {
+ name 'GContracts - Contract-Oriented Programming for Groovy'
+ packaging 'jar'
+ description 'GContracts provides annotations to implement interface contracts aka design by contract in Groovy classes.'
+ url 'http://github.com/andresteingress/gcontracts'
+ inceptionYear '2010'
+
+ scm {
+ url 'scm:git:file:///Users/andre/Development/gcontracts'
+ connection 'scm:git:file:///Users/andre/Development/gcontracts'
+ }
+
+ licenses {
+ license {
+ name 'BSD License'
+ comments """
+ /**
+ Copyright (c) 2010, gcontracts@me.com
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
+ following conditions are met:
+
+ 1.) Redistributions of source code must retain the above copyright notice, this list of conditions and the following
+ disclaimer.
+ 2.) Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following
+ disclaimer in the documentation and/or other materials provided with the distribution.
+ 3.) Neither the name of Andre Steingress nor the names of its contributors may be used to endorse or
+ promote products derived from this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ **/
+ """
+ distribution 'repo'
+ }
+ }
+
+ developers {
+ developer {
+ id 'andre'
+ name 'Andre Steingress'
+ email 'me@andresteingress.com'
+ url 'http://www.andresteingress.com'
+ roles{
+ role 'Developer'
+ }
+ timezone '+1'
+ }
+ }
+ }
+ }
+ }
View
58 src/main/java/org/gcontracts/ast/ClosureAnnotationErasingASTTransformation.java
@@ -1,58 +0,0 @@
-/**
- * Copyright (c) 2010, gcontracts@me.com
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
- * following conditions are met:
- *
- * 1.) Redistributions of source code must retain the above copyright notice, this list of conditions and the following
- * disclaimer.
- * 2.) Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials provided with the distribution.
- * 3.) Neither the name of Andre Steingress nor the names of its contributors may be used to endorse or
- * promote products derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
- * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-package org.gcontracts.ast;
-
-import org.codehaus.groovy.ast.ASTNode;
-import org.codehaus.groovy.ast.ClassNode;
-import org.codehaus.groovy.ast.ModuleNode;
-import org.codehaus.groovy.control.CompilePhase;
-import org.codehaus.groovy.control.SourceUnit;
-import org.codehaus.groovy.control.io.ReaderSource;
-import org.codehaus.groovy.transform.GroovyASTTransformation;
-import org.gcontracts.ast.visitor.ContractsErasingVisitor;
-
-/**
- * <p>
- * Custom AST transformation that erases all closure annotation parameters.
- * </p>
- *
- * @see org.gcontracts.ast.BaseASTTransformation
- * @see org.codehaus.groovy.transform.ASTTransformation
- *
- * @author andre.steingress@gmail.com
- */
-@GroovyASTTransformation(phase = CompilePhase.SEMANTIC_ANALYSIS)
-public class ClosureAnnotationErasingASTTransformation extends BaseASTTransformation {
-
- public void visit(ASTNode[] nodes, SourceUnit unit) {
- if (nodes == null || nodes.length == 0 || unit == null) return;
-
- final ModuleNode moduleNode = (ModuleNode)nodes[0];
-
- ReaderSource source = getReaderSource(unit);
-
- for (final ClassNode classNode : moduleNode.getClasses()) {
- new ContractsErasingVisitor(unit, source).visitClass(classNode);
- }
- }
-}
View
8 .../ContractValidationASTTransformation.java → ...acts/ast/GContractsASTTransformation.java
@@ -28,6 +28,7 @@
import org.codehaus.groovy.control.io.ReaderSource;
import org.codehaus.groovy.transform.GroovyASTTransformation;
import org.codehaus.groovy.transform.powerassert.AssertionRewriter;
+import org.gcontracts.ast.visitor.ContractsErasingVisitor;
import org.gcontracts.ast.visitor.ContractsVisitor;
import org.gcontracts.ast.visitor.DynamicSetterInjectionVisitor;
@@ -46,21 +47,20 @@
* @author andre.steingress@gmail.com
*/
@GroovyASTTransformation(phase = CompilePhase.SEMANTIC_ANALYSIS)
-public class ContractValidationASTTransformation extends BaseASTTransformation {
+public class GContractsASTTransformation extends BaseASTTransformation {
/**
* {@link org.codehaus.groovy.transform.ASTTransformation#visit(org.codehaus.groovy.ast.ASTNode[], org.codehaus.groovy.control.SourceUnit)}
*/
public void visit(ASTNode[] nodes, SourceUnit unit) {
- if (nodes == null || nodes.length == 0 || unit == null) return;
-
- final ModuleNode moduleNode = (ModuleNode)nodes[0];
+ final ModuleNode moduleNode = unit.getAST();
ReaderSource source = getReaderSource(unit);
for (final ClassNode classNode : moduleNode.getClasses()) {
new ContractsVisitor(unit, source).visitClass(classNode);
new DynamicSetterInjectionVisitor(unit, source).visitClass(classNode);
+ new ContractsErasingVisitor(unit, source).visitClass(classNode);
}
}
}
View
2 src/main/java/org/gcontracts/ast/visitor/ContractsErasingVisitor.java
@@ -55,6 +55,8 @@ public ContractsErasingVisitor(final SourceUnit sourceUnit, final ReaderSource s
@Override
public void visitClass(ClassNode type) {
+ System.out.println("Erasing contracts for " + type.getName());
+
List<AnnotationNode> annotations = type.getAnnotations();
for (AnnotationNode annotation: annotations) {
if (annotation.getClassNode().getName().equals(Invariant.class.getName())) {
View
2 src/main/java/org/gcontracts/ast/visitor/ContractsVisitor.java
@@ -66,6 +66,8 @@ public void visitClass(ClassNode type) {
if (!CandidateChecks.isContractsCandidate(type)) return;
+ System.out.println("Adding contracts for " + type.getName());
+
addConfigurationVariable(type);
addClassInvariant(type);
View
1 src/main/resources/services/org.codehaus.groovy.transform.ASTTransformation
@@ -0,0 +1 @@
+org.gcontracts.ast.GContractsASTTransformation
View
6 src/test/groovy/org/gcontracts/tests/basic/BaseTestClass.groovy
@@ -1,8 +1,7 @@
package org.gcontracts.tests.basic
import org.codehaus.groovy.control.CompilePhase
-import org.gcontracts.ast.ClosureAnnotationErasingASTTransformation
-import org.gcontracts.ast.ContractValidationASTTransformation
+import org.gcontracts.ast.GContractsASTTransformation
import groovy.text.GStringTemplateEngine
/**
@@ -19,8 +18,7 @@ class BaseTestClass extends GroovyTestCase {
templateEngine = new GStringTemplateEngine()
loader = new ASTTransformationTestsGroovyClassLoader(getClass().getClassLoader(), [
- new ContractValidationASTTransformation(),
- new ClosureAnnotationErasingASTTransformation()
+ new GContractsASTTransformation()
], CompilePhase.SEMANTIC_ANALYSIS)
}
View
3 src/test/resources/services/org.codehaus.groovy.transform.ASTTransformation
@@ -1,2 +1 @@
-org.gcontracts.ast.ContractValidationASTTransformation
-org.gcontracts.ast.ClosureAnnotationErasingASTTransformation
+org.gcontracts.ast.GContractsASTTransformation

0 comments on commit 9827699

Please sign in to comment.
Something went wrong with that request. Please try again.