[1/2] groovy git commit: remove some legacy rseource definitions in build

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

[1/2] groovy git commit: remove some legacy rseource definitions in build

paulk
Repository: groovy
Updated Branches:
  refs/heads/GROOVY_2_5_X 894de84ef -> d5ebfe455


remove some legacy rseource definitions in build


Project: http://git-wip-us.apache.org/repos/asf/groovy/repo
Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/801ab556
Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/801ab556
Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/801ab556

Branch: refs/heads/GROOVY_2_5_X
Commit: 801ab556e98e84b45c2cba30b46c4132a79c6fea
Parents: 894de84
Author: paulk <[hidden email]>
Authored: Tue Sep 12 23:19:17 2017 +1000
Committer: paulk <[hidden email]>
Committed: Thu Sep 14 00:15:24 2017 +1000

----------------------------------------------------------------------
 build.gradle | 11 ++---------
 1 file changed, 2 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/groovy/blob/801ab556/build.gradle
----------------------------------------------------------------------
diff --git a/build.gradle b/build.gradle
index db7b332..467871c 100644
--- a/build.gradle
+++ b/build.gradle
@@ -280,17 +280,10 @@ sourceSets {
             }
         }
         resources {
-            srcDirs = ['src/main', 'src/tools', 'src/resources']
+            srcDirs = ['src/main', 'src/resources']
             include 'META-INF/services/*',
                     'META-INF/groovy-release-info.properties',
-                    'groovy/grape/*.xml',
-                    'groovy/ui/*.properties',
-                    'groovy/ui/**/*.png',
-                    'groovy/inspect/swingui/AstBrowserProperties.groovy',
-                    'org/codehaus/groovy/tools/shell/**/*.properties',
-                    'org/codehaus/groovy/tools/shell/**/*.xml',
-                    'org/codehaus/groovy/tools/groovydoc/gstringTemplates/**/*.*',
-                    'org/codehaus/groovy/tools/groovy.ico'
+                    'groovy/grape/*.xml'
         }
     }
     test {

Reply | Threaded
Open this post in threaded view
|

[2/2] groovy git commit: GROOVY-8300: @AutoFinal (asciidoc doco)

paulk
GROOVY-8300: @AutoFinal (asciidoc doco)

(cherry picked from commit 9ea35d6)


Project: http://git-wip-us.apache.org/repos/asf/groovy/repo
Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/d5ebfe45
Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/d5ebfe45
Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/d5ebfe45

Branch: refs/heads/GROOVY_2_5_X
Commit: d5ebfe45550fe18b86e6fb31cea7d81de704eb71
Parents: 801ab55
Author: paulk <[hidden email]>
Authored: Wed Sep 13 20:35:27 2017 +0800
Committer: paulk <[hidden email]>
Committed: Thu Sep 14 00:15:50 2017 +1000

----------------------------------------------------------------------
 src/spec/doc/core-metaprogramming.adoc          | 37 ++++++++++++++++
 .../CompilerDirectivesASTTransformsTest.groovy  | 46 ++++++++++++++++++++
 2 files changed, 83 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/groovy/blob/d5ebfe45/src/spec/doc/core-metaprogramming.adoc
----------------------------------------------------------------------
diff --git a/src/spec/doc/core-metaprogramming.adoc b/src/spec/doc/core-metaprogramming.adoc
index f2ffdc4..e18784a 100644
--- a/src/spec/doc/core-metaprogramming.adoc
+++ b/src/spec/doc/core-metaprogramming.adoc
@@ -2357,6 +2357,43 @@ The `@PackageScope` annotation is seldom used as part of normal Groovy conventio
 for factory methods that should be visible internally within a package or for methods or constructors provided
 for testing purposes, or when integrating with third-party libraries which require such visibility conventions.
 
+[[xform-AutoFinal]]
+===== `@groovy.transform.AutoFinal`
+
+The `@AutoFinal` annotation instructs the compiler to automatically insert the final modifier
+in numerous places within the annotated node. If applied on a method (or constructor), the parameters
+for that method (or constructor) will be marked as final. If applied on a class definition, the same
+treatment will occur for all declared methods and constructors within that class.
+
+It is often considered bad practice to reassign parameters of a method or constructor with its body.
+By adding the final modifier to all parameter declarations you can avoid this practice entirely.
+Some programmers feel that adding final everywhere increases the amount of boilerplate code and makes the
+method signatures somewhat noisy. An alternative might instead be to use a code review process or apply
+a http://codenarc.org[codenarc] http://codenarc.sourceforge.net/codenarc-rules-convention.html#ParameterReassignment[rule]
+to give warnings if that practice is observed but these alternatives might lead to delayed feedback during
+quality checking rather than within the IDE or during compilation. The `@AutoFinal` annotation aims to
+maximise compiler/IDE feedback while retaining succinct code with minimum boilerplate noise.
+
+The following example illustrates applying the annotation at the class level:
+
+[source,groovy]
+----
+include::{projectdir}/src/spec/test/CompilerDirectivesASTTransformsTest.groovy[tags=autofinal_class,indent=0]
+----
+
+In this example, the two parameters for the constructor and the single parameter for
+both the `fullname` and `greeting` methods will be final. Attempts to modify those parameters within the
+constructor or method bodies will be flagged by the compiler.
+
+The following example illustrates applying the annotation at the method level:
+
+[source,groovy]
+----
+include::{projectdir}/src/spec/test/CompilerDirectivesASTTransformsTest.groovy[tags=autofinal_method,indent=0]
+----
+
+Here, the `add` method will have final parameters but the `mult` method will remain unchanged.
+
 [[xform-AnnotationCollector]]
 ===== `@groovy.transform.AnnotationCollector`
 

http://git-wip-us.apache.org/repos/asf/groovy/blob/d5ebfe45/src/spec/test/CompilerDirectivesASTTransformsTest.groovy
----------------------------------------------------------------------
diff --git a/src/spec/test/CompilerDirectivesASTTransformsTest.groovy b/src/spec/test/CompilerDirectivesASTTransformsTest.groovy
index 29ccd9f..8e72851 100644
--- a/src/spec/test/CompilerDirectivesASTTransformsTest.groovy
+++ b/src/spec/test/CompilerDirectivesASTTransformsTest.groovy
@@ -96,6 +96,52 @@ new MyScript().run()
 '''
     }
 
+    void testAutoFinalClass() {
+        assertScript '''
+// tag::autofinal_class[]
+import groovy.transform.AutoFinal
+
+@AutoFinal
+class Person {
+    private String first, last
+
+    Person(String first, String last) {
+        this.first = first
+        this.last = last
+    }
+    
+    String fullName(String separator) {
+        "$first$separator$last"
+    }
+    
+    String greeting(String salutation) {
+        "$salutation, $first"
+    }
+}
+// end::autofinal_class[]
+def john = new Person('John', 'Smith')
+assert john.fullName(' ') == 'John Smith'
+assert john.greeting('Hello') == 'Hello, John'
+'''
+    }
+
+    void testAutoFinalMethod() {
+        assertScript '''
+import groovy.transform.AutoFinal
+// tag::autofinal_method[]
+class Calc {
+    @AutoFinal
+    int add(int a, int b) { a + b }
+
+    int mult(int a, int b) { a * b }
+}
+// end::autofinal_method[]
+def calc = new Calc()
+assert calc.add(3, 6) == 9
+assert calc.mult(3, 6) == 18
+'''
+    }
+
     void testPackageScope() {
         assertScript '''import java.lang.reflect.Modifier
 // tag::packagescope_property[]