incubator-s4-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Shailendra Mishra <shailend...@gmail.com>
Subject Re: git commit: fixed gradle warnings + added gradle options - added "s4r" task for creating an s4r archive, instead of using gradle - added "appClass" parameter for directly specifying the application entry point, rather than guessing it by parsing
Date Mon, 11 Jun 2012 13:52:19 GMT
Hi Mattieu:

What is the easiest way of adding local library to the "class path" ?
I just added commons-math through the dependency mechanism in
packages, which was easy because commons-math is available through the
maven repository. I would like to add jquantlib jars which is on my
local hard drive, I can think of a no. of ways to do it, but what
would be the best. - Shailendra

On Mon, Jun 11, 2012 at 6:46 AM,  <mmorel@apache.org> wrote:
> Updated Branches:
>  refs/heads/S4-22 c34742d87 -> ab7f02065
>
>
> fixed gradle warnings + added gradle options
> - added "s4r" task for creating an s4r archive, instead of using gradle
> - added "appClass" parameter for directly specifying the application
> entry point, rather
> than guessing it by parsing the source files
> - added "gradleOpts" parameter for specifying gradle options
>
>
> Project: http://git-wip-us.apache.org/repos/asf/incubator-s4/repo
> Commit: http://git-wip-us.apache.org/repos/asf/incubator-s4/commit/ab7f0206
> Tree: http://git-wip-us.apache.org/repos/asf/incubator-s4/tree/ab7f0206
> Diff: http://git-wip-us.apache.org/repos/asf/incubator-s4/diff/ab7f0206
>
> Branch: refs/heads/S4-22
> Commit: ab7f020655e83adb0a895c937a6b4331f960a877
> Parents: c34742d
> Author: Matthieu Morel <mmorel@apache.org>
> Authored: Mon Jun 11 12:45:31 2012 +0200
> Committer: Matthieu Morel <mmorel@apache.org>
> Committed: Mon Jun 11 12:45:31 2012 +0200
>
> ----------------------------------------------------------------------
>  build.gradle                                       |   18 ++--
>  s4                                                 |    5
+-
>  .../src/main/java/org/apache/s4/core/Main.java     |    3 +-
>  .../main/java/org/apache/s4/core/RemoteStream.java |    2 +-
>  .../main/java/org/apache/s4/tools/CreateApp.java   |    9 ++-
>  .../java/org/apache/s4/tools/DefineCluster.java    |    6 --
>  .../src/main/java/org/apache/s4/tools/Deploy.java  |   41 +++++-----
>  .../org/apache/s4/tools/FileExistsValidator.java   |   18 ++++
>  .../src/main/java/org/apache/s4/tools/Package.java |   44 +++++++++++
>  .../main/java/org/apache/s4/tools/S4ArgsBase.java  |   20 +++++
>  .../src/main/java/org/apache/s4/tools/Tools.java   |    9 ++-
>  .../main/java/org/apache/s4/tools/ZKServer.java    |    1 +
>  .../src/main/resources/templates/build.gradle      |   61 ++++++++-------
>  .../src/main/resources/templates/settings.gradle   |    1 +
>  test-apps/s4-counter/build.gradle                  |   11 ++-
>  test-apps/s4-showtime/build.gradle                 |   11 ++-
>  test-apps/simple-deployable-app-1/build.gradle     |   11 ++-
>  test-apps/simple-deployable-app-2/build.gradle     |   11 ++-
>  18 files changed, 194 insertions(+), 88 deletions(-)
> ----------------------------------------------------------------------
>
>
> http://git-wip-us.apache.org/repos/asf/incubator-s4/blob/ab7f0206/build.gradle
> ----------------------------------------------------------------------
> diff --git a/build.gradle b/build.gradle
> index a27b68b..4639a8a 100644
> --- a/build.gradle
> +++ b/build.gradle
> @@ -21,8 +21,8 @@
>
>  description = 'Apache S4'
>  defaultTasks 'assemble'
> -archivesBaseName = 's4'
> -distRootFolder = "$archivesBaseName-${-> version}"
> +project.ext["archivesBaseName"] = 's4'
> +project.ext["distRootFolder"] = "$archivesBaseName-${-> version}"
>
>  allprojects {
>
> @@ -34,7 +34,7 @@ allprojects {
>     repositories {
>         mavenLocal()
>         mavenCentral()
> -        mavenRepo name: "gson", urls: "http://google-gson.googlecode.com/svn/mavenrepo"
> +        mavenRepo name: "gson", url: "http://google-gson.googlecode.com/svn/mavenrepo"
>
>         /* Add lib dir as a repo. Some jar files that are not available
>          in a public repo are distributed in the lib dir. */
> @@ -43,7 +43,7 @@ allprojects {
>  }
>
>  /* All project libraries must be defined here. */
> -libraries = [
> +project.ext["libraries"] = [
>     json:               'org.json:json:20090211',
>     guava:              'com.google.guava:guava:10.0.1',
>     gson:               'com.google.code.gson:gson:1.6',
> @@ -84,13 +84,13 @@ subprojects {
>     apply plugin: 'java'
>     apply plugin: 'eclipse'
>     apply plugin: 'maven'
> -    apply plugin: 'code-quality'
> +//    apply plugin: 'checkstyle'
>
>     /* Set Java version. */
>     sourceCompatibility = 1.6
>     targetCompatibility = 1.6
>
> -    checkstyleConfigFileName = "$rootDir/config/checkstyle/s4-checkstyle.xml"
> +    project.ext["checkstyleConfigFileName"] = "$rootDir/config/checkstyle/s4-checkstyle.xml"
>
>     configurations.all {
>         exclude group: 'com.sun.jdmk', module: 'jmxtools'
> @@ -142,9 +142,9 @@ subprojects {
>     )
>  }
>
> -dependsOnChildren()
> +evaluationDependsOnChildren()
>
> -platformProjects = [project(':s4-base'), project(':s4-core'), project(':s4-comm'), project(':s4-tools')]
> +project.ext["platformProjects"] = [project(':s4-base'), project(':s4-core'), project(':s4-comm'),
project(':s4-tools')]
>
>  configurations {
>     platformLibs
> @@ -168,7 +168,7 @@ dependencies {
>  //    }
>  //}
>
> -binDistImage = copySpec {
> +project.ext["binDistImage"] = copySpec {
>     platformProjects.collect {proj ->
>         into ("platform/lib") {
>             from proj.sourceSets.main.resources
>
> http://git-wip-us.apache.org/repos/asf/incubator-s4/blob/ab7f0206/s4
> ----------------------------------------------------------------------
> diff --git a/s4 b/s4
> index 61517a1..3d3e0b4 100755
> --- a/s4
> +++ b/s4
> @@ -2,11 +2,12 @@
>
>  # NOTE: "./gradlew s4-tools:installApp" will prepare/update the tools subproject and
related startup scripts
>
> -GRADLE=`pwd`/gradlew
> -
>  S4_DIR="$( cd -P "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
>  S4_SCRIPT_PATH="$S4_DIR/s4"
>
> +# JVM options for starting nodes and for other s4 tools can be configured here
> +# export JAVA_OPTS=-Xmx1G
> +
>  subprojects/s4-tools/build/install/s4-tools/bin/s4-tools -s4ScriptPath=$S4_SCRIPT_PATH
$@
>
>  # EXAMPLES
>
> http://git-wip-us.apache.org/repos/asf/incubator-s4/blob/ab7f0206/subprojects/s4-core/src/main/java/org/apache/s4/core/Main.java
> ----------------------------------------------------------------------
> diff --git a/subprojects/s4-core/src/main/java/org/apache/s4/core/Main.java b/subprojects/s4-core/src/main/java/org/apache/s4/core/Main.java
> index 663caed..139ad35 100644
> --- a/subprojects/s4-core/src/main/java/org/apache/s4/core/Main.java
> +++ b/subprojects/s4-core/src/main/java/org/apache/s4/core/Main.java
> @@ -100,7 +100,8 @@ public class Main {
>                         Arrays.toString(mainArgs.extraNamedParameters.toArray(new
String[] {})));
>                 Map<String, String> namedParameters = new HashMap<String,
String>();
>                 for (String namedParam : mainArgs.extraNamedParameters) {
> -                    namedParameters.put(namedParam.split("[:]")[0].trim(),
namedParam.split("[:]")[1].trim());
> +                    namedParameters.put(namedParam.split("[:]")[0].trim(),
> +                            namedParam.substring(namedParam.indexOf(':')
+ 1).trim());
>                 }
>                 modules.add(new ParametersInjectionModule(namedParameters));
>             }
>
> http://git-wip-us.apache.org/repos/asf/incubator-s4/blob/ab7f0206/subprojects/s4-core/src/main/java/org/apache/s4/core/RemoteStream.java
> ----------------------------------------------------------------------
> diff --git a/subprojects/s4-core/src/main/java/org/apache/s4/core/RemoteStream.java b/subprojects/s4-core/src/main/java/org/apache/s4/core/RemoteStream.java
> index 0833a07..330fd83 100644
> --- a/subprojects/s4-core/src/main/java/org/apache/s4/core/RemoteStream.java
> +++ b/subprojects/s4-core/src/main/java/org/apache/s4/core/RemoteStream.java
> @@ -10,7 +10,7 @@ import org.slf4j.Logger;
>  import org.slf4j.LoggerFactory;
>
>  /**
> - * Stream that dispatches events to a remote cluster
> + * Stream that dispatches events to interested apps in remote clusters
>  *
>  */
>  public class RemoteStream implements Streamable<Event> {
>
> http://git-wip-us.apache.org/repos/asf/incubator-s4/blob/ab7f0206/subprojects/s4-tools/src/main/java/org/apache/s4/tools/CreateApp.java
> ----------------------------------------------------------------------
> diff --git a/subprojects/s4-tools/src/main/java/org/apache/s4/tools/CreateApp.java b/subprojects/s4-tools/src/main/java/org/apache/s4/tools/CreateApp.java
> index 8f870be..beaee41 100644
> --- a/subprojects/s4-tools/src/main/java/org/apache/s4/tools/CreateApp.java
> +++ b/subprojects/s4-tools/src/main/java/org/apache/s4/tools/CreateApp.java
> @@ -44,9 +44,16 @@ public class CreateApp extends S4ArgsBase {
>             Files.copy(gradlewTempFile, new File(appArgs.getAppDir() + "/gradlew"));
>             new File(appArgs.getAppDir() + "/gradlew").setExecutable(true);
>
> -            // copy build file
> +            // copy build file contents
>             Files.copy(Resources.newInputStreamSupplier(Resources.getResource("templates/build.gradle")),
new File(
>                     appArgs.getAppDir() + "/build.gradle"));
> +
> +            // update app settings
> +            String settingsFileContents = Resources.toString(Resources.getResource("templates/settings.gradle"),
> +                    Charsets.UTF_8);
> +            settingsFileContents = settingsFileContents.replaceFirst("rootProject.name=<project-name>",
> +                    "rootProject.name=\"" + appArgs.appName.get(0) + "\"");
> +            Files.write(settingsFileContents, new File(appArgs.getAppDir() + "/settings.gradle"),
Charsets.UTF_8);
>             // copy hello app files
>             Files.copy(Resources.newInputStreamSupplier(Resources.getResource("templates/HelloPE.java.txt")),
new File(
>                     appArgs.getAppDir() + "/src/main/java/hello/HelloPE.java"));
>
> http://git-wip-us.apache.org/repos/asf/incubator-s4/blob/ab7f0206/subprojects/s4-tools/src/main/java/org/apache/s4/tools/DefineCluster.java
> ----------------------------------------------------------------------
> diff --git a/subprojects/s4-tools/src/main/java/org/apache/s4/tools/DefineCluster.java
b/subprojects/s4-tools/src/main/java/org/apache/s4/tools/DefineCluster.java
> index f4b269b..646ae92 100644
> --- a/subprojects/s4-tools/src/main/java/org/apache/s4/tools/DefineCluster.java
> +++ b/subprojects/s4-tools/src/main/java/org/apache/s4/tools/DefineCluster.java
> @@ -1,7 +1,5 @@
>  package org.apache.s4.tools;
>
> -import org.apache.log4j.BasicConfigurator;
> -import org.apache.log4j.Level;
>  import org.apache.s4.comm.tools.TaskSetup;
>  import org.slf4j.Logger;
>  import org.slf4j.LoggerFactory;
> @@ -14,10 +12,6 @@ public class DefineCluster {
>     static Logger logger = LoggerFactory.getLogger(DefineCluster.class);
>
>     public static void main(String[] args) {
> -        // configure log4j for Zookeeper
> -        BasicConfigurator.configure();
> -        org.apache.log4j.Logger.getLogger("org.apache.zookeeper").setLevel(Level.ERROR);
> -        org.apache.log4j.Logger.getLogger("org.I0Itec").setLevel(Level.ERROR);
>
>         ZKServerArgs clusterArgs = new ZKServerArgs();
>         Tools.parseArgs(clusterArgs, args);
>
> http://git-wip-us.apache.org/repos/asf/incubator-s4/blob/ab7f0206/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 de8843a..9471910 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
> @@ -8,22 +8,19 @@ import java.util.List;
>  import junit.framework.Assert;
>
>  import org.I0Itec.zkclient.ZkClient;
> -import org.apache.log4j.BasicConfigurator;
> -import org.apache.log4j.Level;
> -import org.apache.log4j.Logger;
>  import org.apache.s4.comm.topology.ZNRecord;
>  import org.apache.s4.comm.topology.ZNRecordSerializer;
>  import org.apache.s4.deploy.DistributedDeploymentManager;
>  import org.apache.zookeeper.CreateMode;
>  import org.gradle.tooling.BuildLauncher;
>  import org.gradle.tooling.GradleConnector;
> +import org.gradle.tooling.ProgressListener;
>  import org.gradle.tooling.ProjectConnection;
>  import org.slf4j.LoggerFactory;
>
> -import sun.net.ProgressListener;
> -
>  import com.beust.jcommander.Parameter;
>  import com.beust.jcommander.Parameters;
> +import com.beust.jcommander.converters.FileConverter;
>  import com.google.common.io.ByteStreams;
>  import com.google.common.io.Files;
>
> @@ -40,10 +37,6 @@ public class Deploy extends S4ArgsBase {
>         DeployAppArgs deployArgs = new DeployAppArgs();
>
>         Tools.parseArgs(deployArgs, args);
> -        // configure log4j for Zookeeper
> -        BasicConfigurator.configure();
> -        Logger.getLogger("org.apache.zookeeper").setLevel(Level.ERROR);
> -        Logger.getLogger("org.I0Itec").setLevel(Level.ERROR);
>
>         try {
>             ZkClient zkClient = new ZkClient(deployArgs.zkConnectionString, deployArgs.timeout);
> @@ -61,8 +54,13 @@ public class Deploy extends S4ArgsBase {
>                         "Using specified S4R [{}], the S4R archive will not
be built from source (and corresponding parameters are ignored)",
>                         s4rPath);
>             } else {
> -                ExecGradle.exec(deployArgs.gradleBuildFilePath, "installS4R",
> -                        new String[] { "appsDir=" + tmpAppsDir.getAbsolutePath(),
"appName=" + deployArgs.appName });
> +                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[] {}));
>                 s4rPath = tmpAppsDir.getAbsolutePath() + "/" + deployArgs.appName
+ ".s4r";
>             }
>             Assert.assertTrue(ByteStreams.copy(Files.newInputStreamSupplier(new
File(s4rPath)),
> @@ -86,32 +84,35 @@ 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 = "path to gradle
build file for the S4 application", required = false)
> -        String gradleBuildFilePath;
> +        @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 s4r file", required =
false)
> +        @Parameter(names = "-s4r", description = "Path to s4r file", required =
false)
>         String s4rPath;
>
> -        @Parameter(names = "-appName", description = "name of S4 application", required
= true)
> +        @Parameter(names = { "-a", "-appClass" }, description = "Full class name
of the application class (extending App or AdapterApp)", required = false)
> +        String appClass = "";
> +
> +        @Parameter(names = "-appName", description = "Name of S4 application. This
will be the name of the s4r file as well", required = true)
>         String appName;
>
> -        @Parameter(names = { "-c", "-cluster" }, description = "logical name of
the S4 cluster", required = true)
> +        @Parameter(names = { "-c", "-cluster" }, description = "Logical name of
the S4 cluster", required = true)
>         String clusterName;
>
> -        @Parameter(names = "-zk", description = "zookeeper connection string")
> +        @Parameter(names = "-zk", description = "ZooKeeper connection string")
>         String zkConnectionString = "localhost:2181";
>
> -        @Parameter(names = "-timeout", description = "connection timeout to Zookeeper,
in ms")
> +        @Parameter(names = "-timeout", description = "Connection timeout to Zookeeper,
in ms")
>         int timeout = 10000;
>
>     }
>
>     static class ExecGradle {
>
> -        public static void exec(String buildFilePath, String taskName, String[]
params) throws Exception {
> +        public static void exec(File buildFile, String taskName, String[] params)
throws Exception {
>
>             ProjectConnection connection = GradleConnector.newConnector()
> -                    .forProjectDirectory(new File(buildFilePath).getParentFile()).connect();
> +                    .forProjectDirectory(buildFile.getParentFile()).connect();
>
>             try {
>                 BuildLauncher build = connection.newBuild();
>
> http://git-wip-us.apache.org/repos/asf/incubator-s4/blob/ab7f0206/subprojects/s4-tools/src/main/java/org/apache/s4/tools/FileExistsValidator.java
> ----------------------------------------------------------------------
> diff --git a/subprojects/s4-tools/src/main/java/org/apache/s4/tools/FileExistsValidator.java
b/subprojects/s4-tools/src/main/java/org/apache/s4/tools/FileExistsValidator.java
> new file mode 100644
> index 0000000..9e21600
> --- /dev/null
> +++ b/subprojects/s4-tools/src/main/java/org/apache/s4/tools/FileExistsValidator.java
> @@ -0,0 +1,18 @@
> +package org.apache.s4.tools;
> +
> +import java.io.File;
> +
> +import com.beust.jcommander.IParameterValidator;
> +import com.beust.jcommander.ParameterException;
> +
> +public class FileExistsValidator implements IParameterValidator {
> +
> +    @Override
> +    public void validate(String name, String value) throws ParameterException {
> +        if (!new File(value).exists()) {
> +            throw new ParameterException("File with path [" + value + "] specified
in [" + name + "] does not exist");
> +        }
> +
> +    }
> +
> +}
>
> http://git-wip-us.apache.org/repos/asf/incubator-s4/blob/ab7f0206/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
> new file mode 100644
> index 0000000..d737d40
> --- /dev/null
> +++ b/subprojects/s4-tools/src/main/java/org/apache/s4/tools/Package.java
> @@ -0,0 +1,44 @@
> +package org.apache.s4.tools;
> +
> +import java.io.File;
> +import java.util.ArrayList;
> +import java.util.List;
> +
> +import org.apache.s4.tools.Deploy.ExecGradle;
> +import org.slf4j.LoggerFactory;
> +
> +import com.beust.jcommander.Parameter;
> +import com.beust.jcommander.Parameters;
> +import com.beust.jcommander.converters.FileConverter;
> +
> +public class Package extends S4ArgsBase {
> +
> +    public static void main(String[] args) {
> +        try {
> +            final PackageArgs packageArgs = new PackageArgs();
> +            Tools.parseArgs(packageArgs, args);
> +
> +            List<String> params = new ArrayList<String>();
> +            // prepare gradle -P parameters, including passed gradle opts
> +            params.add("appClass=" + packageArgs.appClass);
> +            params.add("appName=" + packageArgs.appName.get(0));
> +            ExecGradle.exec(packageArgs.gradleBuildFile, "installS4R", params.toArray(new
String[] {}));
> +        } catch (Exception e) {
> +            LoggerFactory.getLogger(Package.class).error("Cannot deploy app",
e);
> +        }
> +    }
> +
> +    @Parameters(commandNames = "package", separators = "=", commandDescription = "Create
s4r")
> +    static class PackageArgs extends S4ArgsBase {
> +
> +        @Parameter(description = "name of the application", required = true, arity
= 1)
> +        List<String> appName;
> +
> +        @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)
> +        String appClass = "";
> +
> +    }
> +}
>
> http://git-wip-us.apache.org/repos/asf/incubator-s4/blob/ab7f0206/subprojects/s4-tools/src/main/java/org/apache/s4/tools/S4ArgsBase.java
> ----------------------------------------------------------------------
> diff --git a/subprojects/s4-tools/src/main/java/org/apache/s4/tools/S4ArgsBase.java b/subprojects/s4-tools/src/main/java/org/apache/s4/tools/S4ArgsBase.java
> index 477fdaa..213001d 100644
> --- a/subprojects/s4-tools/src/main/java/org/apache/s4/tools/S4ArgsBase.java
> +++ b/subprojects/s4-tools/src/main/java/org/apache/s4/tools/S4ArgsBase.java
> @@ -1,5 +1,9 @@
>  package org.apache.s4.tools;
>
> +import java.util.ArrayList;
> +import java.util.List;
> +
> +import com.beust.jcommander.IStringConverter;
>  import com.beust.jcommander.Parameter;
>
>  public abstract class S4ArgsBase {
> @@ -10,4 +14,20 @@ public abstract class S4ArgsBase {
>     @Parameter(names = "-s4ScriptPath", description = "path of the S4 script", hidden
= true, required = true)
>     String s4ScriptPath;
>
> +    @Parameter(names = "-gradleOpts", variableArity = true, description = "gradle
system properties (as in GRADLE_OPTS environment properties) passed to gradle scripts", required
= false, converter = GradleOptsConverter.class)
> +    List<String> gradleOpts = new ArrayList<String>();
> +
> +    // This removes automatically the -D of each gradle opt jvm parameter, if present
> +    public class GradleOptsConverter implements IStringConverter<String> {
> +
> +        @Override
> +        public String convert(String value) {
> +            if (value.startsWith("-D")) {
> +                return value.substring("-D".length());
> +            } else {
> +                return value;
> +            }
> +        }
> +
> +    }
>  }
>
> http://git-wip-us.apache.org/repos/asf/incubator-s4/blob/ab7f0206/subprojects/s4-tools/src/main/java/org/apache/s4/tools/Tools.java
> ----------------------------------------------------------------------
> diff --git a/subprojects/s4-tools/src/main/java/org/apache/s4/tools/Tools.java b/subprojects/s4-tools/src/main/java/org/apache/s4/tools/Tools.java
> index 7f2a844..733c7ad 100644
> --- a/subprojects/s4-tools/src/main/java/org/apache/s4/tools/Tools.java
> +++ b/subprojects/s4-tools/src/main/java/org/apache/s4/tools/Tools.java
> @@ -5,6 +5,8 @@ import java.util.ArrayList;
>  import java.util.Arrays;
>  import java.util.List;
>
> +import org.apache.log4j.BasicConfigurator;
> +import org.apache.log4j.Level;
>  import org.apache.s4.core.Main;
>  import org.slf4j.Logger;
>  import org.slf4j.LoggerFactory;
> @@ -20,7 +22,7 @@ public class Tools {
>
>     enum Task {
>         deploy(Deploy.class), node(Main.class), zkServer(ZKServer.class), newCluster(DefineCluster.class),
adapter(null), newApp(
> -                CreateApp.class);
> +                CreateApp.class), s4r(Package.class);
>
>         Class<?> target;
>
> @@ -42,6 +44,11 @@ public class Tools {
>
>     public static void main(String[] args) {
>
> +        // configure log4j for Zookeeper
> +        BasicConfigurator.configure();
> +        org.apache.log4j.Logger.getLogger("org.apache.zookeeper").setLevel(Level.ERROR);
> +        org.apache.log4j.Logger.getLogger("org.I0Itec").setLevel(Level.ERROR);
> +
>         if (!(args.length > 1)) {
>             List<String> taskNames = getTaskNames();
>             System.err.println("please specify a task name and proper arguments.
Available tasks are: "
>
> http://git-wip-us.apache.org/repos/asf/incubator-s4/blob/ab7f0206/subprojects/s4-tools/src/main/java/org/apache/s4/tools/ZKServer.java
> ----------------------------------------------------------------------
> diff --git a/subprojects/s4-tools/src/main/java/org/apache/s4/tools/ZKServer.java b/subprojects/s4-tools/src/main/java/org/apache/s4/tools/ZKServer.java
> index ae0b011..0842f07 100644
> --- a/subprojects/s4-tools/src/main/java/org/apache/s4/tools/ZKServer.java
> +++ b/subprojects/s4-tools/src/main/java/org/apache/s4/tools/ZKServer.java
> @@ -17,6 +17,7 @@ public class ZKServer {
>     static Logger logger = LoggerFactory.getLogger(ZKServer.class);
>
>     public static void main(String[] args) {
> +
>         ZKServerArgs zkArgs = new ZKServerArgs();
>         Tools.parseArgs(zkArgs, args);
>         try {
>
> http://git-wip-us.apache.org/repos/asf/incubator-s4/blob/ab7f0206/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 f60c3f3..a1e50e3 100644
> --- a/subprojects/s4-tools/src/main/resources/templates/build.gradle
> +++ b/subprojects/s4-tools/src/main/resources/templates/build.gradle
> @@ -15,15 +15,13 @@
>  *
>  */
>
> -/* Set the destination where we want to install the apps. */
> +project.ext["s4AppInstallDir"] = hasProperty('appsDir') ? "$appsDir" : "/tmp/appsDir"
>
> -s4AppInstallDir = hasProperty('appsDir') ? "$appsDir" : "/tmp/appsDir"
> -
> -s4Version = '0.5.0-SNAPSHOT'
> +project.ext["s4Version"] = '0.5.0-SNAPSHOT'
>  description = 'Apache S4 App'
>  //defaultTasks 'installS4R'
> -archivesBaseName = "$project.name"
> -distRootFolder = "$archivesBaseName-${-> version}"
> +project.ext["archivesBaseName"] = "$project.name"
> +project.ext["distRootFolder"] = "$archivesBaseName-${-> version}"
>
>
>  // Append the suffix 'SNAPSHOT' when the build is not for release.
> @@ -44,7 +42,7 @@ targetCompatibility = 1.6
>  repositories {
>     mavenLocal()
>     mavenCentral()
> -    mavenRepo name: "gson", urls: "http://google-gson.googlecode.com/svn/mavenrepo"
> +    mavenRepo name: "gson", url: "http://google-gson.googlecode.com/svn/mavenrepo"
>
>     /* Add lib dir as a repo. Some jar files that are not available
>      in a public repo are distributed in the lib dir. */
> @@ -52,7 +50,7 @@ repositories {
>  }
>
>  /* All project libraries must be defined here. */
> -libraries = [
> +project.ext["libraries"] = [
>             // for instance, adding twitter4j 2.2.5 will be:
>             //twitter4j_core:     'org.twitter4j:twitter4j-core:2.2.5'
>             // http://mvnrepository.com/ is a good source
> @@ -92,34 +90,42 @@ manifest.mainAttributes(
>        'S4-Version': s4Version
>        )
>
> -appDependencies = ( configurations.compile )
> +project.ext["appDependencies"] = ( configurations.compile )
>
>  /* 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 schenma files as needed (not critical) see: http://forums.gradle.org/gradle/topics/using_gradle_to_fat_jar_a_spring_project
>  task s4r(type: Jar) {
> +
> +   if (rootProject.hasProperty("appName")) {
> +       archiveName= "$appName"+".s4r"
> +   }
>    dependsOn jar
>    from { appDependencies.collect { it.isDirectory() ? it : zipTree(it) } }
>    from { configurations.archives.allArtifacts.files.collect { zipTree(it) } }
>    manifest = project.manifest
> -   extension = '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)
> -           }
> -       }
> -   }
> +
> +   // 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."
> -       exit(1)
> +       System.exit(1)
>    }
>  }
>
> @@ -132,7 +138,7 @@ s4r << {
>  }
>
>  task cp << {
> -    description='dumps the classpath for running a class from this project, into a
\'classpath.txt\' file in the current directory'
> +    description='Dumps the classpath for running a class from this project, into a
\'classpath.txt\' file in the current directory'
>     new File("classpath.txt").write(sourceSets.main.runtimeClasspath.asPath)
>  }
>
> @@ -148,15 +154,16 @@ task installS4R (type: Copy) {
>  */
>  def getAppClassname(file) {
>    def classname = "UNKNOWN"
> -   lines= file.readLines()
> +   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
>
> http://git-wip-us.apache.org/repos/asf/incubator-s4/blob/ab7f0206/subprojects/s4-tools/src/main/resources/templates/settings.gradle
> ----------------------------------------------------------------------
> diff --git a/subprojects/s4-tools/src/main/resources/templates/settings.gradle b/subprojects/s4-tools/src/main/resources/templates/settings.gradle
> new file mode 100644
> index 0000000..e0a06c9
> --- /dev/null
> +++ b/subprojects/s4-tools/src/main/resources/templates/settings.gradle
> @@ -0,0 +1 @@
> +rootProject.name=<project-name>
> \ No newline at end of file
>
> http://git-wip-us.apache.org/repos/asf/incubator-s4/blob/ab7f0206/test-apps/s4-counter/build.gradle
> ----------------------------------------------------------------------
> diff --git a/test-apps/s4-counter/build.gradle b/test-apps/s4-counter/build.gradle
> index 87512df..d71f75f 100644
> --- a/test-apps/s4-counter/build.gradle
> +++ b/test-apps/s4-counter/build.gradle
> @@ -34,9 +34,9 @@
>  /* Set the destination where we want to install the apps. */
>  //s4AppInstallDir = "/tmp/s4Apps" // TODO: decide how to standarize dirs, use env var?
>
> -s4AppInstallDir = hasProperty('appsDir') ? "$appsDir" : "/tmp/appsDir"
> +project.ext["s4AppInstallDir"] = hasProperty('appsDir') ? "$appsDir" : "/tmp/appsDir"
>
> -s4Version = '0.5.0-SNAPSHOT'
> +project.ext["s4Version"] = '0.5.0-SNAPSHOT'
>  description = 'Apache S4 App'
>  //defaultTasks 'installS4R'
>  archivesBaseName = "$project.name"
> @@ -60,7 +60,7 @@ targetCompatibility = 1.6
>
>
>  /* All project libraries must be defined here. */
> -libraries = [
> +project.ext["libraries"] = [
>            json:               'org.json:json:20090211',
>            guava:              'com.google.guava:guava:10.0.1',
>            gson:               'com.google.code.gson:gson:1.6',
> @@ -131,7 +131,7 @@ manifest.mainAttributes(
>        'S4-Version': s4Version
>        )
>
> -appDependencies = ( configurations.compile )
> +project.ext["appDependencies"] = ( configurations.compile )
>
>  /* 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 schenma files as needed (not critical) see: http://forums.gradle.org/gradle/topics/using_gradle_to_fat_jar_a_spring_project
> @@ -193,7 +193,8 @@ task wrapper(type: Wrapper) { gradleVersion = '1.0-milestone-3' }
>  */
>  def getAppClassname(file) {
>    def classname = "UNKNOWN"
> -   lines= file.readLines()
> +   def lines= file.readLines()
> +   def packageName=""
>    for(line in lines) {
>
>        def pn = line =~ /.*package\s+([\w\.]+)\s*;.*/
>
> http://git-wip-us.apache.org/repos/asf/incubator-s4/blob/ab7f0206/test-apps/s4-showtime/build.gradle
> ----------------------------------------------------------------------
> diff --git a/test-apps/s4-showtime/build.gradle b/test-apps/s4-showtime/build.gradle
> index 72ff887..3bfe72f 100644
> --- a/test-apps/s4-showtime/build.gradle
> +++ b/test-apps/s4-showtime/build.gradle
> @@ -34,9 +34,9 @@
>  /* Set the destination where we want to install the apps. */
>  //s4AppInstallDir = "/tmp/s4Apps" // TODO: decide how to standarize dirs, use env var?
>
> -s4AppInstallDir = hasProperty('appsDir') ? "$appsDir" : "/tmp/appsDir"
> +project.ext["s4AppInstallDir"] = hasProperty('appsDir') ? "$appsDir" : "/tmp/appsDir"
>
> -s4Version = '0.5.0-SNAPSHOT'
> +project.ext["s4Version"] = '0.5.0-SNAPSHOT'
>  description = 'Apache S4 App'
>  //defaultTasks 'installS4R'
>  archivesBaseName = "$project.name"
> @@ -60,7 +60,7 @@ targetCompatibility = 1.6
>
>
>  /* All project libraries must be defined here. */
> -libraries = [
> +project.ext["libraries"] = [
>            json:               'org.json:json:20090211',
>            guava:              'com.google.guava:guava:10.0.1',
>            gson:               'com.google.code.gson:gson:1.6',
> @@ -131,7 +131,7 @@ manifest.mainAttributes(
>        'S4-Version': s4Version
>        )
>
> -appDependencies = ( configurations.compile )
> +project.ext["appDependencies"] = ( configurations.compile )
>
>  /* 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 schenma files as needed (not critical) see: http://forums.gradle.org/gradle/topics/using_gradle_to_fat_jar_a_spring_project
> @@ -191,7 +191,8 @@ task installS4R (type: Copy) {
>  */
>  def getAppClassname(file) {
>    def classname = "UNKNOWN"
> -   lines= file.readLines()
> +   def lines= file.readLines()
> +   def packageName=""
>    for(line in lines) {
>
>        def pn = line =~ /.*package\s+([\w\.]+)\s*;.*/
>
> http://git-wip-us.apache.org/repos/asf/incubator-s4/blob/ab7f0206/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 87512df..ad4dca5 100644
> --- a/test-apps/simple-deployable-app-1/build.gradle
> +++ b/test-apps/simple-deployable-app-1/build.gradle
> @@ -34,9 +34,9 @@
>  /* Set the destination where we want to install the apps. */
>  //s4AppInstallDir = "/tmp/s4Apps" // TODO: decide how to standarize dirs, use env var?
>
> -s4AppInstallDir = hasProperty('appsDir') ? "$appsDir" : "/tmp/appsDir"
> +project.ext["s4AppInstallDir"] = hasProperty('appsDir') ? "$appsDir" : "/tmp/appsDir"
>
> -s4Version = '0.5.0-SNAPSHOT'
> +project.ext["s4Version"] = '0.5.0-SNAPSHOT'
>  description = 'Apache S4 App'
>  //defaultTasks 'installS4R'
>  archivesBaseName = "$project.name"
> @@ -60,7 +60,7 @@ targetCompatibility = 1.6
>
>
>  /* All project libraries must be defined here. */
> -libraries = [
> +project.ext["libraries"] = [
>            json:               'org.json:json:20090211',
>            guava:              'com.google.guava:guava:10.0.1',
>            gson:               'com.google.code.gson:gson:1.6',
> @@ -131,7 +131,7 @@ manifest.mainAttributes(
>        'S4-Version': s4Version
>        )
>
> -appDependencies = ( configurations.compile )
> +project.ext["appDependencies"] = ( configurations.compile )
>
>  /* 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 schenma files as needed (not critical) see: http://forums.gradle.org/gradle/topics/using_gradle_to_fat_jar_a_spring_project
> @@ -193,7 +193,8 @@ task wrapper(type: Wrapper) { gradleVersion = '1.0-milestone-3' }
>  */
>  def getAppClassname(file) {
>    def classname = "UNKNOWN"
> -   lines= file.readLines()
> +   def lines= file.readLines()
> +   def packageName = ""
>    for(line in lines) {
>
>        def pn = line =~ /.*package\s+([\w\.]+)\s*;.*/
>
> http://git-wip-us.apache.org/repos/asf/incubator-s4/blob/ab7f0206/test-apps/simple-deployable-app-2/build.gradle
> ----------------------------------------------------------------------
> diff --git a/test-apps/simple-deployable-app-2/build.gradle b/test-apps/simple-deployable-app-2/build.gradle
> index 87512df..ad4dca5 100644
> --- a/test-apps/simple-deployable-app-2/build.gradle
> +++ b/test-apps/simple-deployable-app-2/build.gradle
> @@ -34,9 +34,9 @@
>  /* Set the destination where we want to install the apps. */
>  //s4AppInstallDir = "/tmp/s4Apps" // TODO: decide how to standarize dirs, use env var?
>
> -s4AppInstallDir = hasProperty('appsDir') ? "$appsDir" : "/tmp/appsDir"
> +project.ext["s4AppInstallDir"] = hasProperty('appsDir') ? "$appsDir" : "/tmp/appsDir"
>
> -s4Version = '0.5.0-SNAPSHOT'
> +project.ext["s4Version"] = '0.5.0-SNAPSHOT'
>  description = 'Apache S4 App'
>  //defaultTasks 'installS4R'
>  archivesBaseName = "$project.name"
> @@ -60,7 +60,7 @@ targetCompatibility = 1.6
>
>
>  /* All project libraries must be defined here. */
> -libraries = [
> +project.ext["libraries"] = [
>            json:               'org.json:json:20090211',
>            guava:              'com.google.guava:guava:10.0.1',
>            gson:               'com.google.code.gson:gson:1.6',
> @@ -131,7 +131,7 @@ manifest.mainAttributes(
>        'S4-Version': s4Version
>        )
>
> -appDependencies = ( configurations.compile )
> +project.ext["appDependencies"] = ( configurations.compile )
>
>  /* 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 schenma files as needed (not critical) see: http://forums.gradle.org/gradle/topics/using_gradle_to_fat_jar_a_spring_project
> @@ -193,7 +193,8 @@ task wrapper(type: Wrapper) { gradleVersion = '1.0-milestone-3' }
>  */
>  def getAppClassname(file) {
>    def classname = "UNKNOWN"
> -   lines= file.readLines()
> +   def lines= file.readLines()
> +   def packageName = ""
>    for(line in lines) {
>
>        def pn = line =~ /.*package\s+([\w\.]+)\s*;.*/
>

Mime
View raw message