You are viewing a plain text version of this content. The canonical link for it is here.
Posted to s4-commits@incubator.apache.org by mm...@apache.org on 2013/02/27 18:34:15 UTC

git commit: S4-66 Force application class to be defined when building s4r package

Updated Branches:
  refs/heads/S4-66 [created] 6b42486d8


S4-66 Force application class to be defined when building s4r package


Project: http://git-wip-us.apache.org/repos/asf/incubator-s4/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-s4/commit/6b42486d
Tree: http://git-wip-us.apache.org/repos/asf/incubator-s4/tree/6b42486d
Diff: http://git-wip-us.apache.org/repos/asf/incubator-s4/diff/6b42486d

Branch: refs/heads/S4-66
Commit: 6b42486d8ac1f96fda6ea738528f861f374e1569
Parents: 755ed6b
Author: Matthieu Morel <mm...@apache.org>
Authored: Wed Feb 27 15:39:01 2013 +0100
Committer: Matthieu Morel <mm...@apache.org>
Committed: Wed Feb 27 19:29:55 2013 +0100

----------------------------------------------------------------------
 subprojects/s4-benchmarks/s4-benchmarks.gradle     |    3 -
 .../apache/s4/deploy/TestAutomaticDeployment.java  |    4 +-
 .../s4/deploy/prodcon/TestProducerConsumer.java    |    4 +-
 .../src/main/java/org/apache/s4/tools/Deploy.java  |   29 --------
 .../src/main/java/org/apache/s4/tools/Package.java |    2 +-
 .../src/main/resources/templates/build.gradle      |   41 +----------
 test-apps/consumer-app/build.gradle                |   31 +-------
 test-apps/producer-app/build.gradle                |   31 +-------
 test-apps/simple-deployable-app-1/build.gradle     |   37 ++--------
 test-apps/twitter-adapter/build.gradle             |   57 ++-------------
 test-apps/twitter-counter/build.gradle             |   30 +-------
 11 files changed, 34 insertions(+), 235 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-s4/blob/6b42486d/subprojects/s4-benchmarks/s4-benchmarks.gradle
----------------------------------------------------------------------
diff --git a/subprojects/s4-benchmarks/s4-benchmarks.gradle b/subprojects/s4-benchmarks/s4-benchmarks.gradle
index 76ce1a0..9d99124 100644
--- a/subprojects/s4-benchmarks/s4-benchmarks.gradle
+++ b/subprojects/s4-benchmarks/s4-benchmarks.gradle
@@ -36,9 +36,6 @@ apply plugin: 'eclipse'
 apply plugin: 'idea'
 apply plugin:'application'
 
-/* The app classname is set automatically from the source files. */
-def appClassname = ''
-
 /* Set Java version. */
 sourceCompatibility = 1.6
 targetCompatibility = 1.6

http://git-wip-us.apache.org/repos/asf/incubator-s4/blob/6b42486d/subprojects/s4-core/src/test/java/org/apache/s4/deploy/TestAutomaticDeployment.java
----------------------------------------------------------------------
diff --git a/subprojects/s4-core/src/test/java/org/apache/s4/deploy/TestAutomaticDeployment.java b/subprojects/s4-core/src/test/java/org/apache/s4/deploy/TestAutomaticDeployment.java
index 8b5329b..3c901d7 100644
--- a/subprojects/s4-core/src/test/java/org/apache/s4/deploy/TestAutomaticDeployment.java
+++ b/subprojects/s4-core/src/test/java/org/apache/s4/deploy/TestAutomaticDeployment.java
@@ -71,8 +71,8 @@ public class TestAutomaticDeployment extends ZkBasedTest {
         File gradlewFile = CoreTestUtils.findGradlewInRootDir();
 
         CoreTestUtils.callGradleTask(new File(gradlewFile.getParentFile().getAbsolutePath()
-                + "/test-apps/simple-deployable-app-1/build.gradle"), "installS4R", new String[] { "appsDir="
-                + tmpAppsDir.getAbsolutePath() });
+                + "/test-apps/simple-deployable-app-1/build.gradle"), "installS4R", new String[] {
+                "appsDir=" + tmpAppsDir.getAbsolutePath(), "appClass=org.apache.s4.deploy.TestApp" });
 
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-s4/blob/6b42486d/subprojects/s4-core/src/test/java/org/apache/s4/deploy/prodcon/TestProducerConsumer.java
----------------------------------------------------------------------
diff --git a/subprojects/s4-core/src/test/java/org/apache/s4/deploy/prodcon/TestProducerConsumer.java b/subprojects/s4-core/src/test/java/org/apache/s4/deploy/prodcon/TestProducerConsumer.java
index 31c6a34..31a08cc 100644
--- a/subprojects/s4-core/src/test/java/org/apache/s4/deploy/prodcon/TestProducerConsumer.java
+++ b/subprojects/s4-core/src/test/java/org/apache/s4/deploy/prodcon/TestProducerConsumer.java
@@ -69,11 +69,11 @@ public class TestProducerConsumer {
 
         CoreTestUtils.callGradleTask(new File(gradlewFile.getParentFile().getAbsolutePath()
                 + "/test-apps/producer-app/build.gradle"), "installS4R",
-                new String[] { "appsDir=" + tmpAppsDir.getAbsolutePath() });
+                new String[] { "appsDir=" + tmpAppsDir.getAbsolutePath(), "appClass=s4app.ProducerApp" });
 
         CoreTestUtils.callGradleTask(new File(gradlewFile.getParentFile().getAbsolutePath()
                 + "/test-apps/consumer-app/build.gradle"), "installS4R",
-                new String[] { "appsDir=" + tmpAppsDir.getAbsolutePath() });
+                new String[] { "appsDir=" + tmpAppsDir.getAbsolutePath(), "appClass=s4app.ConsumerApp" });
     }
 
     @Before

http://git-wip-us.apache.org/repos/asf/incubator-s4/blob/6b42486d/subprojects/s4-tools/src/main/java/org/apache/s4/tools/Deploy.java
----------------------------------------------------------------------
diff --git a/subprojects/s4-tools/src/main/java/org/apache/s4/tools/Deploy.java b/subprojects/s4-tools/src/main/java/org/apache/s4/tools/Deploy.java
index 76a1d43..8c0c916 100644
--- a/subprojects/s4-tools/src/main/java/org/apache/s4/tools/Deploy.java
+++ b/subprojects/s4-tools/src/main/java/org/apache/s4/tools/Deploy.java
@@ -40,10 +40,8 @@ import org.slf4j.LoggerFactory;
 import com.beust.jcommander.IStringConverter;
 import com.beust.jcommander.Parameter;
 import com.beust.jcommander.Parameters;
-import com.beust.jcommander.converters.FileConverter;
 import com.beust.jcommander.internal.Maps;
 import com.google.common.base.Strings;
-import com.google.common.io.ByteStreams;
 import com.google.common.io.Files;
 
 public class Deploy extends S4ArgsBase {
@@ -82,30 +80,6 @@ public class Deploy extends S4ArgsBase {
                 logger.info(
                         "Using specified S4R [{}], the S4R archive will not be built from source (and corresponding parameters are ignored)",
                         s4rURI.toString());
-            } else if (deployArgs.gradleBuildFile != null) {
-
-                // 2. otherwise if there is a build file, we create the S4R archive from that
-
-                List<String> params = new ArrayList<String>();
-                // prepare gradle -P parameters, including passed gradle opts
-                params.addAll(deployArgs.gradleOpts);
-                params.add("appClass=" + deployArgs.appClass);
-                params.add("appsDir=" + tmpAppsDir.getAbsolutePath());
-                params.add("appName=" + deployArgs.appName);
-                ExecGradle.exec(deployArgs.gradleBuildFile, "installS4R", params.toArray(new String[] {}));
-                File tmpS4R = new File(tmpAppsDir.getAbsolutePath() + "/" + deployArgs.appName + ".s4r");
-                if (!Strings.isNullOrEmpty(deployArgs.generatedS4R)) {
-                    logger.info("Copying generated S4R to [{}]", deployArgs.generatedS4R);
-                    s4rURI = new URI(deployArgs.generatedS4R);
-                    if (!(ByteStreams.copy(Files.newInputStreamSupplier(tmpS4R),
-                            Files.newOutputStreamSupplier(new File(s4rURI))) > 0)) {
-                        logger.error("Cannot copy generated s4r from {} to {}", tmpS4R.getAbsolutePath(),
-                                s4rURI.toString());
-                        System.exit(1);
-                    }
-                } else {
-                    s4rURI = tmpS4R.toURI();
-                }
             } else {
                 if (!Strings.isNullOrEmpty(deployArgs.appClass)) {
                     // 3. otherwise if there is at least an app class specified (e.g. for running "s4 adapter"), we use
@@ -150,9 +124,6 @@ public class Deploy extends S4ArgsBase {
     @Parameters(commandNames = "s4 deploy", commandDescription = "Package and deploy application to S4 cluster", separators = "=")
     static class DeployAppArgs extends S4ArgsBase {
 
-        @Parameter(names = { "-b", "-buildFile" }, description = "Full path to gradle build file for the S4 application", required = false, converter = FileConverter.class, validateWith = FileExistsValidator.class)
-        File gradleBuildFile;
-
         @Parameter(names = "-s4r", description = "Path to existing s4r file", required = false)
         String s4rPath;
 

http://git-wip-us.apache.org/repos/asf/incubator-s4/blob/6b42486d/subprojects/s4-tools/src/main/java/org/apache/s4/tools/Package.java
----------------------------------------------------------------------
diff --git a/subprojects/s4-tools/src/main/java/org/apache/s4/tools/Package.java b/subprojects/s4-tools/src/main/java/org/apache/s4/tools/Package.java
index fe8761a..0a05ac7 100644
--- a/subprojects/s4-tools/src/main/java/org/apache/s4/tools/Package.java
+++ b/subprojects/s4-tools/src/main/java/org/apache/s4/tools/Package.java
@@ -58,7 +58,7 @@ public class Package extends S4ArgsBase {
         @Parameter(names = { "-b", "-buildFile" }, description = "Path to gradle build file for the S4 application", required = true, converter = FileConverter.class, validateWith = FileExistsValidator.class)
         File gradleBuildFile;
 
-        @Parameter(names = { "-a", "-appClass" }, description = "Full class name of the application class (extending App or AdapterApp)", required = false)
+        @Parameter(names = { "-a", "-appClass" }, description = "Full class name of the application class (extending App or AdapterApp)", required = true)
         String appClass = "";
 
     }

http://git-wip-us.apache.org/repos/asf/incubator-s4/blob/6b42486d/subprojects/s4-tools/src/main/resources/templates/build.gradle
----------------------------------------------------------------------
diff --git a/subprojects/s4-tools/src/main/resources/templates/build.gradle b/subprojects/s4-tools/src/main/resources/templates/build.gradle
index 6476309..3a59f05 100644
--- a/subprojects/s4-tools/src/main/resources/templates/build.gradle
+++ b/subprojects/s4-tools/src/main/resources/templates/build.gradle
@@ -18,6 +18,7 @@
 
 
 project.ext["s4AppInstallDir"] = hasProperty('appsDir') ? "$appsDir" : "/tmp/appsDir"
+project.ext["appClassName"] = hasProperty('appClass')? "$appClass": "UNDEFINED"
 
 project.ext["s4Version"] = '0.5.0-incubating'
 description = 'Apache S4 App'
@@ -25,7 +26,6 @@ description = 'Apache S4 App'
 project.ext["archivesBaseName"] = "$project.name"
 project.ext["distRootFolder"] = "$archivesBaseName-${-> version}"
 
-
 // Append the suffix 'SNAPSHOT' when the build is not for release.
 //version = new Version(major: 0, minor: 0, bugfix: 0, isRelease: false)
 group = 'org.apache.s4'
@@ -35,9 +35,6 @@ apply plugin: 'eclipse'
 apply plugin: 'idea'
 apply plugin:'application'
 
-/* The app classname is set automatically from the source files. */
-def appClassname = ''
-
 /* Set Java version. */
 sourceCompatibility = 1.6
 targetCompatibility = 1.6
@@ -80,16 +77,14 @@ dependencies {
 
 }
 
-/* Set the manifest attributes for the S4 archive here.
-*  TODO: separate custom properties from std ones and set custom properties at the top of the build script.
-*/
+// Set the manifest attributes for the S4 archive here. ('S4-App-Class':  gets set by the s4r task)
 manifest.mainAttributes(
        provider: 'gradle',
        'Implementation-Url': 'http://incubator.apache.org/projects/s4.html',
        'Implementation-Version': version,
        'Implementation-Vendor': 'Apache S4',
        'Implementation-Vendor-Id': 's4app',
-       'S4-App-Class': appClassname, // gets set by the s4r task.
+       'S4-App-Class':'',
        'S4-Version': s4Version
        )
 
@@ -109,44 +104,16 @@ task buildProjectJar() {
 	}
 }
 
-
-
 /* This task will extract all the class files and create a fat jar. We set the manifest and the extension to make it an S4 archive file. */
 // TODO: exclude schema files as needed (not critical) see: http://forums.gradle.org/gradle/topics/using_gradle_to_fat_jar_a_spring_project
 // TODO: exclude s4 platform jars
 task s4r(type: Jar) {
-	if (rootProject.hasProperty("appName")) {
-       archiveName= "$appName"+".s4r"
-   }
    dependsOn cleanCopyDependenciesToLib, copyDependenciesToLib, cleanBuildProjectJar, buildProjectJar
    from { project.libsDir }
    manifest = project.manifest
    extension = 's4r'
    exclude '*.s4r'
-
-   // check -PappClassName, need to refer to rootProject to check property, see http://issues.gradle.org/browse/GRADLE-1826
-    if (!rootProject.hasProperty('appClass') || !"$appClass") {
-        /* Set class name in manifest. Parse source files until we find a class that extends App.
-         * Get fully qualified Java class name and set attribute in Manifest.
-         */
-        sourceSets.main.allSource.files.each {  File file ->
-            if (appClassname =="" || appClassname == "UNKNOWN") {
-                // only execute the closure for this file if we haven't already found the app class name
-                appClassname = getAppClassname(file)
-                if(appClassname != "") {
-                    manifest.mainAttributes('S4-App-Class': appClassname)
-                }
-            }
-        }
-    } else {
-        manifest.mainAttributes('S4-App-Class': "$appClass")
-    }
-
-   if (appClassname == "UNKNOWN") {
-
-       println "Couldn't find App class in source files...aborting."
-       System.exit(1)
-   }
+   manifest.mainAttributes('S4-App-Class': appClassName)
 }
 
 

http://git-wip-us.apache.org/repos/asf/incubator-s4/blob/6b42486d/test-apps/consumer-app/build.gradle
----------------------------------------------------------------------
diff --git a/test-apps/consumer-app/build.gradle b/test-apps/consumer-app/build.gradle
index bc53b3a..eae3228 100644
--- a/test-apps/consumer-app/build.gradle
+++ b/test-apps/consumer-app/build.gradle
@@ -38,6 +38,7 @@
 //s4AppInstallDir = "/tmp/s4Apps" // TODO: decide how to standarize dirs, use env var?
 
 project.ext["s4AppInstallDir"] = hasProperty('appsDir') ? "$appsDir" : "/tmp/appsDir"
+project.ext["appClassName"] = hasProperty('appClass')? "$appClass": "UNDEFINED"
 
 project.ext["s4Version"] = '0.5.0-SNAPSHOT'
 description = 'Apache S4 App'
@@ -54,9 +55,6 @@ apply plugin: 'java'
 apply plugin: 'eclipse'
 apply plugin: 'idea'
 
-/* The app classname is set automatically from the source files. */
-def appClassname = ''
-
 /* Set Java version. */
 sourceCompatibility = 1.6
 targetCompatibility = 1.6
@@ -114,16 +112,14 @@ dependencies {
    testCompile( libraries.junit )
 }
 
-/* Set the manifest attributes for the S4 archive here.
-*  TODO: separate custom properties from std ones and set custom properties at the top of the build script.
-*/
+// Set the manifest attributes for the S4 archive here. ('S4-App-Class':  gets set by the s4r task)
 manifest.mainAttributes(
        provider: 'gradle',
        'Implementation-Url': 'http://incubator.apache.org/projects/s4.html',
        'Implementation-Version': version,
        'Implementation-Vendor': 'Apache S4',
        'Implementation-Vendor-Id': 's4app',
-       'S4-App-Class': appClassname, // gets set by the s4r task.
+       'S4-App-Class':'',
        'S4-Version': s4Version
        )
 
@@ -144,7 +140,6 @@ task buildProjectJar() {
 }
 
 
-
 /* This task will extract all the class files and create a fat jar. We set the manifest and the extension to make it an S4 archive file. */
 // TODO: exclude schema files as needed (not critical) see: http://forums.gradle.org/gradle/topics/using_gradle_to_fat_jar_a_spring_project
 // TODO: exclude s4 platform jars
@@ -154,25 +149,7 @@ task s4r(type: Jar) {
    manifest = project.manifest
    extension = 's4r'
    exclude '*.s4r'
-
-   /* Set class name in manifest. Parse source files until we find a class that extends App.
-    * Get fully qualified Java class name and set attribute in Manifest.
-    */
-   sourceSets.main.allSource.files.each {  File file ->
-       if (appClassname =="" || appClassname == "UNKNOWN") {
-           // only execute the closure for this file if we haven't already found the app class name
-           appClassname = getAppClassname(file)
-           if(appClassname != "") {
-               manifest.mainAttributes('S4-App-Class': appClassname)
-           }
-       }
-   }
-
-   if (appClassname == "UNKNOWN") {
-
-       println "Couldn't find App class in source files...aborting."
-       exit(1)
-   }
+   manifest.mainAttributes('S4-App-Class': appClassName)
 }
 
 /* List the artifacts that will br added to the s4 archive (and explode if needed). */

http://git-wip-us.apache.org/repos/asf/incubator-s4/blob/6b42486d/test-apps/producer-app/build.gradle
----------------------------------------------------------------------
diff --git a/test-apps/producer-app/build.gradle b/test-apps/producer-app/build.gradle
index bc53b3a..eae3228 100644
--- a/test-apps/producer-app/build.gradle
+++ b/test-apps/producer-app/build.gradle
@@ -38,6 +38,7 @@
 //s4AppInstallDir = "/tmp/s4Apps" // TODO: decide how to standarize dirs, use env var?
 
 project.ext["s4AppInstallDir"] = hasProperty('appsDir') ? "$appsDir" : "/tmp/appsDir"
+project.ext["appClassName"] = hasProperty('appClass')? "$appClass": "UNDEFINED"
 
 project.ext["s4Version"] = '0.5.0-SNAPSHOT'
 description = 'Apache S4 App'
@@ -54,9 +55,6 @@ apply plugin: 'java'
 apply plugin: 'eclipse'
 apply plugin: 'idea'
 
-/* The app classname is set automatically from the source files. */
-def appClassname = ''
-
 /* Set Java version. */
 sourceCompatibility = 1.6
 targetCompatibility = 1.6
@@ -114,16 +112,14 @@ dependencies {
    testCompile( libraries.junit )
 }
 
-/* Set the manifest attributes for the S4 archive here.
-*  TODO: separate custom properties from std ones and set custom properties at the top of the build script.
-*/
+// Set the manifest attributes for the S4 archive here. ('S4-App-Class':  gets set by the s4r task)
 manifest.mainAttributes(
        provider: 'gradle',
        'Implementation-Url': 'http://incubator.apache.org/projects/s4.html',
        'Implementation-Version': version,
        'Implementation-Vendor': 'Apache S4',
        'Implementation-Vendor-Id': 's4app',
-       'S4-App-Class': appClassname, // gets set by the s4r task.
+       'S4-App-Class':'',
        'S4-Version': s4Version
        )
 
@@ -144,7 +140,6 @@ task buildProjectJar() {
 }
 
 
-
 /* This task will extract all the class files and create a fat jar. We set the manifest and the extension to make it an S4 archive file. */
 // TODO: exclude schema files as needed (not critical) see: http://forums.gradle.org/gradle/topics/using_gradle_to_fat_jar_a_spring_project
 // TODO: exclude s4 platform jars
@@ -154,25 +149,7 @@ task s4r(type: Jar) {
    manifest = project.manifest
    extension = 's4r'
    exclude '*.s4r'
-
-   /* Set class name in manifest. Parse source files until we find a class that extends App.
-    * Get fully qualified Java class name and set attribute in Manifest.
-    */
-   sourceSets.main.allSource.files.each {  File file ->
-       if (appClassname =="" || appClassname == "UNKNOWN") {
-           // only execute the closure for this file if we haven't already found the app class name
-           appClassname = getAppClassname(file)
-           if(appClassname != "") {
-               manifest.mainAttributes('S4-App-Class': appClassname)
-           }
-       }
-   }
-
-   if (appClassname == "UNKNOWN") {
-
-       println "Couldn't find App class in source files...aborting."
-       exit(1)
-   }
+   manifest.mainAttributes('S4-App-Class': appClassName)
 }
 
 /* List the artifacts that will br added to the s4 archive (and explode if needed). */

http://git-wip-us.apache.org/repos/asf/incubator-s4/blob/6b42486d/test-apps/simple-deployable-app-1/build.gradle
----------------------------------------------------------------------
diff --git a/test-apps/simple-deployable-app-1/build.gradle b/test-apps/simple-deployable-app-1/build.gradle
index bc53b3a..f1763e8 100644
--- a/test-apps/simple-deployable-app-1/build.gradle
+++ b/test-apps/simple-deployable-app-1/build.gradle
@@ -38,6 +38,7 @@
 //s4AppInstallDir = "/tmp/s4Apps" // TODO: decide how to standarize dirs, use env var?
 
 project.ext["s4AppInstallDir"] = hasProperty('appsDir') ? "$appsDir" : "/tmp/appsDir"
+project.ext["appClassName"] = hasProperty('appClass')? "$appClass": "UNDEFINED"
 
 project.ext["s4Version"] = '0.5.0-SNAPSHOT'
 description = 'Apache S4 App'
@@ -46,6 +47,7 @@ archivesBaseName = "$project.name"
 distRootFolder = "$archivesBaseName-${-> version}"
 
 
+
 // Append the suffix 'SNAPSHOT' when the build is not for release.
 version = new Version(major: 0, minor: 0, bugfix: 0, isRelease: false)
 group = 'org.apache.s4'
@@ -54,9 +56,6 @@ apply plugin: 'java'
 apply plugin: 'eclipse'
 apply plugin: 'idea'
 
-/* The app classname is set automatically from the source files. */
-def appClassname = ''
-
 /* Set Java version. */
 sourceCompatibility = 1.6
 targetCompatibility = 1.6
@@ -114,16 +113,14 @@ dependencies {
    testCompile( libraries.junit )
 }
 
-/* Set the manifest attributes for the S4 archive here.
-*  TODO: separate custom properties from std ones and set custom properties at the top of the build script.
-*/
+// Set the manifest attributes for the S4 archive here. ('S4-App-Class':  gets set by the s4r task)
 manifest.mainAttributes(
        provider: 'gradle',
        'Implementation-Url': 'http://incubator.apache.org/projects/s4.html',
        'Implementation-Version': version,
        'Implementation-Vendor': 'Apache S4',
        'Implementation-Vendor-Id': 's4app',
-       'S4-App-Class': appClassname, // gets set by the s4r task.
+       'S4-App-Class':'',
        'S4-Version': s4Version
        )
 
@@ -143,8 +140,6 @@ task buildProjectJar() {
 	}
 }
 
-
-
 /* This task will extract all the class files and create a fat jar. We set the manifest and the extension to make it an S4 archive file. */
 // TODO: exclude schema files as needed (not critical) see: http://forums.gradle.org/gradle/topics/using_gradle_to_fat_jar_a_spring_project
 // TODO: exclude s4 platform jars
@@ -154,25 +149,9 @@ task s4r(type: Jar) {
    manifest = project.manifest
    extension = 's4r'
    exclude '*.s4r'
-
-   /* Set class name in manifest. Parse source files until we find a class that extends App.
-    * Get fully qualified Java class name and set attribute in Manifest.
-    */
-   sourceSets.main.allSource.files.each {  File file ->
-       if (appClassname =="" || appClassname == "UNKNOWN") {
-           // only execute the closure for this file if we haven't already found the app class name
-           appClassname = getAppClassname(file)
-           if(appClassname != "") {
-               manifest.mainAttributes('S4-App-Class': appClassname)
-           }
-       }
-   }
-
-   if (appClassname == "UNKNOWN") {
-
-       println "Couldn't find App class in source files...aborting."
-       exit(1)
-   }
+   
+   println ( hasProperty("appClass") ? "$appClass" : "UNDEFINED")
+   manifest.mainAttributes('S4-App-Class': appClassName)
 }
 
 /* List the artifacts that will br added to the s4 archive (and explode if needed). */
@@ -193,7 +172,7 @@ s4r << {
 task installS4R (type: Copy) {
    dependsOn s4r
    from s4r.archivePath
-   into s4AppInstallDir
+   into s4AppInstallDir 
 }
 
 

http://git-wip-us.apache.org/repos/asf/incubator-s4/blob/6b42486d/test-apps/twitter-adapter/build.gradle
----------------------------------------------------------------------
diff --git a/test-apps/twitter-adapter/build.gradle b/test-apps/twitter-adapter/build.gradle
index e7734d3..b8a11d0 100644
--- a/test-apps/twitter-adapter/build.gradle
+++ b/test-apps/twitter-adapter/build.gradle
@@ -38,6 +38,7 @@
 //s4AppInstallDir = "/tmp/s4Apps" // TODO: decide how to standarize dirs, use env var?
 
 project.ext["s4AppInstallDir"] = hasProperty('appsDir') ? "$appsDir" : "/tmp/appsDir"
+project.ext["appClassName"] = hasProperty('appClass')? "$appClass": "UNDEFINED"
 
 project.ext["s4Version"] = '0.5.0-incubating'
 description = 'Apache S4 App'
@@ -57,9 +58,6 @@ apply plugin:'application'
 
 mainClassName = "org.apache.s4.core.S4Node"
 
-/* The app classname is set automatically from the source files. */
-def appClassname = ''
-
 /* Set Java version. */
 sourceCompatibility = 1.6
 targetCompatibility = 1.6
@@ -101,16 +99,14 @@ dependencies {
 
 }
 
-/* Set the manifest attributes for the S4 archive here.
-*  TODO: separate custom properties from std ones and set custom properties at the top of the build script.
-*/
+// Set the manifest attributes for the S4 archive here. ('S4-App-Class':  gets set by the s4r task)
 manifest.mainAttributes(
        provider: 'gradle',
        'Implementation-Url': 'http://incubator.apache.org/projects/s4.html',
        'Implementation-Version': version,
        'Implementation-Vendor': 'Apache S4',
        'Implementation-Vendor-Id': 's4app',
-       'S4-App-Class': appClassname, // gets set by the s4r task.
+       'S4-App-Class':'',
        'S4-Version': s4Version
        )
 
@@ -130,8 +126,6 @@ task buildProjectJar() {
 	}
 }
 
-
-
 /* This task will extract all the class files and create a fat jar. We set the manifest and the extension to make it an S4 archive file. */
 // TODO: exclude schema files as needed (not critical) see: http://forums.gradle.org/gradle/topics/using_gradle_to_fat_jar_a_spring_project
 // TODO: exclude s4 platform jars
@@ -141,25 +135,7 @@ task s4r(type: Jar) {
    manifest = project.manifest
    extension = 's4r'
    exclude '*.s4r'
-
-   /* Set class name in manifest. Parse source files until we find a class that extends App.
-    * Get fully qualified Java class name and set attribute in Manifest.
-    */
-   sourceSets.main.allSource.files.each {  File file ->
-       if (appClassname =="" || appClassname == "UNKNOWN") {
-           // only execute the closure for this file if we haven't already found the app class name
-           appClassname = getAppClassname(file)
-           if(appClassname != "") {
-               manifest.mainAttributes('S4-App-Class': appClassname)
-           }
-       }
-   }
-
-   if (appClassname == "UNKNOWN") {
-
-       println "Couldn't find App class in source files...aborting."
-       exit(1)
-   }
+   manifest.mainAttributes('S4-App-Class': appClassName)
 }
 
 /* List the artifacts that will br added to the s4 archive (and explode if needed). */
@@ -181,6 +157,7 @@ task installS4R (type: Copy) {
    dependsOn s4r
    from s4r.archivePath
    into s4AppInstallDir
+   
 }
 
 /* Generates the gradlew scripts.
@@ -193,30 +170,6 @@ task cp << {
 }
 
 
-/* Parse source file to get the app classname so we can use it in the manifest.
-* TODO: Use a real Java parser. (This is not skippong comments for example.)
-*/
-def getAppClassname(file) {
-   def classname = "UNKNOWN"
-   def lines= file.readLines()
-   def packageName = ""
-   for(line in lines) {
-
-       def pn = line =~ /.*package\s+([\w\.]+)\s*;.*/
-       if(pn) {
-           packageName = pn[0][1] + "."
-       }
-
-       def an = line =~ /.*public\s+class\s+(\w+)\s+extends.+App.*\{/
-       if (an) {
-           classname = packageName + an[0][1]
-           println "Found app class name: " + classname
-           break
-       }
-
-   }
-   classname
-}
 
 class Version {
    int major

http://git-wip-us.apache.org/repos/asf/incubator-s4/blob/6b42486d/test-apps/twitter-counter/build.gradle
----------------------------------------------------------------------
diff --git a/test-apps/twitter-counter/build.gradle b/test-apps/twitter-counter/build.gradle
index e88e8d8..6149a13 100644
--- a/test-apps/twitter-counter/build.gradle
+++ b/test-apps/twitter-counter/build.gradle
@@ -38,6 +38,7 @@
 //s4AppInstallDir = "/tmp/s4Apps" // TODO: decide how to standarize dirs, use env var?
 
 project.ext["s4AppInstallDir"] = hasProperty('appsDir') ? "$appsDir" : "/tmp/appsDir"
+project.ext["appClassName"] = hasProperty('appClass')? "$appClass": "UNDEFINED"
 
 project.ext["s4Version"] = '0.5.0-incubating'
 description = 'Apache S4 App'
@@ -55,9 +56,6 @@ apply plugin: 'eclipse'
 apply plugin: 'idea'
 apply plugin:'application'
 
-/* The app classname is set automatically from the source files. */
-def appClassname = ''
-
 /* Set Java version. */
 sourceCompatibility = 1.6
 targetCompatibility = 1.6
@@ -97,16 +95,14 @@ dependencies {
 
 }
 
-/* Set the manifest attributes for the S4 archive here.
-*  TODO: separate custom properties from std ones and set custom properties at the top of the build script.
-*/
+// Set the manifest attributes for the S4 archive here. ('S4-App-Class':  gets set by the s4r task)
 manifest.mainAttributes(
        provider: 'gradle',
        'Implementation-Url': 'http://incubator.apache.org/projects/s4.html',
        'Implementation-Version': version,
        'Implementation-Vendor': 'Apache S4',
        'Implementation-Vendor-Id': 's4app',
-       'S4-App-Class': appClassname, // gets set by the s4r task.
+       'S4-App-Class':'',
        'S4-Version': s4Version
        )
 
@@ -137,25 +133,7 @@ task s4r(type: Jar) {
    manifest = project.manifest
    extension = 's4r'
    exclude '*.s4r'
-
-   /* Set class name in manifest. Parse source files until we find a class that extends App.
-    * Get fully qualified Java class name and set attribute in Manifest.
-    */
-   sourceSets.main.allSource.files.each {  File file ->
-       if (appClassname =="" || appClassname == "UNKNOWN") {
-           // only execute the closure for this file if we haven't already found the app class name
-           appClassname = getAppClassname(file)
-           if(appClassname != "") {
-               manifest.mainAttributes('S4-App-Class': appClassname)
-           }
-       }
-   }
-
-   if (appClassname == "UNKNOWN") {
-
-       println "Couldn't find App class in source files...aborting."
-       exit(1)
-   }
+   manifest.mainAttributes('S4-App-Class': appClassName)
 }