buildr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From toulm...@apache.org
Subject buildr git commit: BUILDR-724: Use scalamain to call scala projects
Date Tue, 01 Nov 2016 07:29:11 GMT
Repository: buildr
Updated Branches:
  refs/heads/master 5bcd625f1 -> ed77d8311


BUILDR-724: Use scalamain to call scala projects


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

Branch: refs/heads/master
Commit: ed77d83111fc2c6a179df97fbe22e3516820bf2b
Parents: 5bcd625
Author: Antoine Toulme <antoine@lunar-ocean.com>
Authored: Tue Nov 1 00:29:04 2016 -0700
Committer: Antoine Toulme <antoine@lunar-ocean.com>
Committed: Tue Nov 1 00:29:04 2016 -0700

----------------------------------------------------------------------
 CHANGELOG                                       |   1 +
 lib/buildr/scala/bdd.rb                         |   6 +-
 lib/buildr/scala/compiler.rb                    |   7 ++-
 .../scala/org/apache/buildr/Specs2Runner.java   |  37 ------------
 .../apache/buildr/SpecsSingletonRunner.class    | Bin 1891 -> 0 bytes
 .../org/apache/buildr/SpecsSingletonRunner.java |  57 -------------------
 .../scala/org/apache/buildr/ZincRunner.class    | Bin 1162 -> 0 bytes
 .../scala/org/apache/buildr/ZincRunner.java     |  37 ------------
 8 files changed, 9 insertions(+), 136 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/buildr/blob/ed77d831/CHANGELOG
----------------------------------------------------------------------
diff --git a/CHANGELOG b/CHANGELOG
index 909ec04..c539f03 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -4,6 +4,7 @@
 * Change: Move hoe to the development dependencies
 * Fixed:  BUILDR-728 Snapshots metadata incorrectly created
 * Fixed:  BUILDR-718 Deprecate SVN repository - remove links to SVN
+* Change: BUILDR-724 Use scalamain to call scala projects
 
 1.5.0 (2016-09-23)
 * Change: Update RJB to 1.5.4

http://git-wip-us.apache.org/repos/asf/buildr/blob/ed77d831/lib/buildr/scala/bdd.rb
----------------------------------------------------------------------
diff --git a/lib/buildr/scala/bdd.rb b/lib/buildr/scala/bdd.rb
index e72d65f..ad13663 100644
--- a/lib/buildr/scala/bdd.rb
+++ b/lib/buildr/scala/bdd.rb
@@ -92,7 +92,7 @@ module Buildr::Scala #:nodoc:
         unless @dependencies
           super
 
-          # Add utility classes (e.g. SpecsSingletonRunner) and other dependencies
+          # Add utility classes and other dependencies
           options = {
             :scopes => [nil, "compile", "runtime", "provided", "optional"],
             :optional => true
@@ -144,10 +144,10 @@ module Buildr::Scala #:nodoc:
                       :classpath => dependencies,
                       :name => false }
 
-      runner = 'org.apache.buildr.Specs2Runner'
+      runner = 'org.specs2.runner.ClassRunner'
       specs.inject [] do |passed, spec|
         begin
-          Java::Commands.java(runner, spec, cmd_options)
+          Java::Commands.java('io.tmio.scalamain.Main', runner, 'run', spec, cmd_options)
         rescue => e
           passed
         else

http://git-wip-us.apache.org/repos/asf/buildr/blob/ed77d831/lib/buildr/scala/compiler.rb
----------------------------------------------------------------------
diff --git a/lib/buildr/scala/compiler.rb b/lib/buildr/scala/compiler.rb
index feb127c..c295c4e 100644
--- a/lib/buildr/scala/compiler.rb
+++ b/lib/buildr/scala/compiler.rb
@@ -90,6 +90,7 @@ module Buildr::Scala
     DEFAULT_ZINC_VERSION  = '0.3.12'
     DEFAULT_SBT_VERSION   = '0.13.12'
     DEFAULT_JLINE_VERSION = '2.14.2'
+    DEFAULT_SCALAMAIN_VERSION = '1.0.0'
 
     class << self
       def scala_home
@@ -164,11 +165,13 @@ module Buildr::Scala
       zinc_version  = Buildr.settings.build['zinc.version']  || DEFAULT_ZINC_VERSION
       sbt_version   = Buildr.settings.build['sbt.version']   || DEFAULT_SBT_VERSION
       jline_version = Buildr.settings.build['jline.version'] || DEFAULT_JLINE_VERSION
+      scalamain_version = Buildr.settings.build['scalamain.version'] || DEFAULT_SCALAMAIN_VERSION
       ns.zinc!          "com.typesafe.zinc:zinc:jar:>=#{zinc_version}"
       ns.sbt_interface! "com.typesafe.sbt:sbt-interface:jar:>=#{sbt_version}"
       ns.incremental!   "com.typesafe.sbt:incremental-compiler:jar:>=#{sbt_version}"
       ns.compiler_interface_sources! "com.typesafe.sbt:compiler-interface:jar:sources:>=#{sbt_version}"
       ns.jline!        "jline:jline:jar:>=#{jline_version}"
+      ns.scalamain!    "io.tmio:scalamain:jar:>=#{scalamain_version}"
     end
 
     Javac = Buildr::Compiler::Javac
@@ -279,9 +282,9 @@ module Buildr::Scala
       cmd_args += files_from_sources(sources)
 
       unless Buildr.application.options.dryrun
-        trace((['org.apache.buildr.ZincRunner'] + cmd_args).join(' '))
+        trace((['io.tmio.scalamain.Main', 'com.typesafe.zinc.Main', 'main'] + cmd_args).join('
'))
         begin
-          Java::Commands.java 'org.apache.buildr.ZincRunner', *(cmd_args + [{ :classpath
=> Scalac.dependencies + [ File.join(File.dirname(__FILE__)) ]}])
+          Java::Commands.java 'io.tmio.scalamain.Main', *(['com.typesafe.zinc.Main', 'main']
+ cmd_args + [{ :classpath => Scalac.dependencies + [ File.join(File.dirname(__FILE__))
]}])
         rescue => e
           fail "Zinc compiler crashed:\n#{e.inspect}\n#{e.backtrace.join("\n")}"
         end

http://git-wip-us.apache.org/repos/asf/buildr/blob/ed77d831/lib/buildr/scala/org/apache/buildr/Specs2Runner.java
----------------------------------------------------------------------
diff --git a/lib/buildr/scala/org/apache/buildr/Specs2Runner.java b/lib/buildr/scala/org/apache/buildr/Specs2Runner.java
deleted file mode 100644
index 55c52b1..0000000
--- a/lib/buildr/scala/org/apache/buildr/Specs2Runner.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/* Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with this
- * work for additional information regarding copyright ownership.  The ASF
- * licenses this file to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
- * License for the specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.buildr;
-
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
-
-public class Specs2Runner {
-
-  public static void main(String[] args) {
-      try {
-          ClassLoader loader = Thread.currentThread().getContextClassLoader();
-          Class clazz = loader.loadClass("org.specs2.runner.ClassRunner$");
-          Field singleton = clazz.getField("MODULE$");
-          Object instance = singleton.get(null);
-          Method main = clazz.getMethod("run", String[].class);
-          main.invoke(instance, new Object[] { args });
-      } catch (Exception e) {
-          throw new RuntimeException(e);
-      }
-  }
-
-}

http://git-wip-us.apache.org/repos/asf/buildr/blob/ed77d831/lib/buildr/scala/org/apache/buildr/SpecsSingletonRunner.class
----------------------------------------------------------------------
diff --git a/lib/buildr/scala/org/apache/buildr/SpecsSingletonRunner.class b/lib/buildr/scala/org/apache/buildr/SpecsSingletonRunner.class
deleted file mode 100644
index 7a27b57..0000000
Binary files a/lib/buildr/scala/org/apache/buildr/SpecsSingletonRunner.class and /dev/null
differ

http://git-wip-us.apache.org/repos/asf/buildr/blob/ed77d831/lib/buildr/scala/org/apache/buildr/SpecsSingletonRunner.java
----------------------------------------------------------------------
diff --git a/lib/buildr/scala/org/apache/buildr/SpecsSingletonRunner.java b/lib/buildr/scala/org/apache/buildr/SpecsSingletonRunner.java
deleted file mode 100644
index 611c46b..0000000
--- a/lib/buildr/scala/org/apache/buildr/SpecsSingletonRunner.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/* Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with this
- * work for additional information regarding copyright ownership.  The ASF
- * licenses this file to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
- * License for the specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.buildr;
-
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
-import java.net.URL;
-import java.net.URLClassLoader;
-import java.io.File;
-
-/**
- * @author Daniel Spiewak
- */
-public class SpecsSingletonRunner {
-  // Incompatible with JVM 1.4 target
-  // @throws(classOf[Throwable])
-  public static void main(String[] args) {
-      boolean colors = (args.length > 1 && args[1].equals("-c"));
-      String spec = colors ? args[2] : args[1];
-
-      run(args[0], colors, spec);
-  }
-
-  // Incompatible with JVM 1.4 target
-  // @throws(classOf[Throwable])
-  static void run(String path, boolean colors, String spec) {
-      try {
-          File parent = new File(path);
-          URL specURL = new File(parent, spec.replace('.', '/') + ".class").toURL();
-          URLClassLoader loader = new URLClassLoader(new URL[] { specURL }, Thread.currentThread().getContextClassLoader());
-
-          Class clazz = loader.loadClass(spec);
-          Object instance = clazz.getField("MODULE$").get(null);
-
-          Method main = clazz.getMethod("main", String[].class);
-
-          String[] args = colors ? new String[] { "-c" } : new String[] {};
-          main.invoke(instance, new Object[] { args });
-      } catch (Exception e) {
-          throw new RuntimeException(e);
-      }
-  }
-}

http://git-wip-us.apache.org/repos/asf/buildr/blob/ed77d831/lib/buildr/scala/org/apache/buildr/ZincRunner.class
----------------------------------------------------------------------
diff --git a/lib/buildr/scala/org/apache/buildr/ZincRunner.class b/lib/buildr/scala/org/apache/buildr/ZincRunner.class
deleted file mode 100644
index a60c7eb..0000000
Binary files a/lib/buildr/scala/org/apache/buildr/ZincRunner.class and /dev/null differ

http://git-wip-us.apache.org/repos/asf/buildr/blob/ed77d831/lib/buildr/scala/org/apache/buildr/ZincRunner.java
----------------------------------------------------------------------
diff --git a/lib/buildr/scala/org/apache/buildr/ZincRunner.java b/lib/buildr/scala/org/apache/buildr/ZincRunner.java
deleted file mode 100644
index e8a6407..0000000
--- a/lib/buildr/scala/org/apache/buildr/ZincRunner.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/* Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with this
- * work for additional information regarding copyright ownership.  The ASF
- * licenses this file to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
- * License for the specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.buildr;
-
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
-
-public class ZincRunner {
-
-  public static void main(String[] args) {
-      try {
-          ClassLoader loader = Thread.currentThread().getContextClassLoader();
-          Class clazz = loader.loadClass("com.typesafe.zinc.Main$");
-          Field singleton = clazz.getField("MODULE$");
-          Object instance = singleton.get(null);
-          Method main = clazz.getMethod("main", String[].class);
-          main.invoke(instance, new Object[] { args });
-      } catch (Exception e) {
-          throw new RuntimeException(e);
-      }
-  }
-
-}


Mime
View raw message