Giter VIP home page Giter VIP logo

Comments (4)

johnynek avatar johnynek commented on July 16, 2024

We would welcome a PR! This functionality is not as well tested as it could
be, as you see (we don't use any mixed targets at Stripe).

Thanks for reporting the issue.
On Thu, Nov 17, 2016 at 04:59 Guardian Sentinel [email protected]
wrote:

Hey Guys,

I've been trying to use scala_library to compile a mixture of both scala
and java files. It seems the java file compilation fails when there are
multiple java files. Up on looking at the error, it seems that the javac
command that we invoke is taking the list of files as a single string block
instead of taking it as a separate files. Below is the error that im
getting while invoking javac

javac: file not found: infra/BetterOutput.java infra/Changeset.java infra/CompilationException.java
Usage: javac
use -help for a list of possible options
Exception in thread "main" java.lang.RuntimeException: nope
at io.bazel.rulesscala.scalac.ScalaCInvoker.main(ScalaCInvoker.java:345)
Caused by: java.lang.RuntimeException: javac process failed!
at io.bazel.rulesscala.scalac.ScalaCInvoker.compileJavaSources(ScalaCInvoker.java:303)
at io.bazel.rulesscala.scalac.ScalaCInvoker.processRequest(ScalaCInvoker.java:238)
at io.bazel.rulesscala.scalac.ScalaCInvoker.main(ScalaCInvoker.java:341)
Target //infrastructure:infra-scala failed to build

Simplest fix was to append the file names directly to the command and that
seems to be working fine

diff --git a/src/java/io/bazel/rulesscala/scalac/ScalaCInvoker.java b/src/java/io/bazel/rulesscala/scalac/ScalaCInvoker.java
index 4c64c2c..4208123 100644
--- a/src/java/io/bazel/rulesscala/scalac/ScalaCInvoker.java
+++ b/src/java/io/bazel/rulesscala/scalac/ScalaCInvoker.java
@@ -281,19 +281,13 @@ public class ScalaCInvoker {
commandParts.add(ops.javacOpts);
}

  • StringBuilder files = new StringBuilder();
  • int cnt = 0;
  • for(String javaFile : ops.javaFiles) {
  •  if (cnt > 0) files.append(" ");
    
  •  files.append(javaFile);
    
  •  cnt += 1;
    

- }

 commandParts.add("-classpath");
 commandParts.add(ops.classpath + ":" + tmpPath.toString());
 commandParts.add("-d");
 commandParts.add(tmpPath.toString());
  • commandParts.add(files.toString());
  • for(String javaFile : ops.javaFiles) {
  •  commandParts.add(javaFile.toString());
    
  • }

Process iostat = new ProcessBuilder(commandParts)
.inheritIO()

Not sure if anyone has seen this behaviour when using multiple java source
files. My BUILD file is pretty simple,

package(default_visibility = ["//visibility:public"])

load("@io_bazel_rules_scala//scala:scala.bzl", "scala_library", "scala_binary", "scala_export_to_java")

scala_library(
name = "infra-scala",
srcs = glob([
".scala",
"
.java",
], exclude = ["TestError.java"]),
deps = [
"//third_party/jar:mvnrepo",
],
)


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
#112, or mute the thread
https://github.com/notifications/unsubscribe-auth/AAEJdqJTujq362JyS5Zvw5gDqor7XelEks5q_Gu-gaJpZM4K1Z95
.

from rules_scala.

sentinelleader avatar sentinelleader commented on July 16, 2024

Thanks, will sent a PR as soon as get my machine 👍, the tests didnt noticed this because our MixJavaScalaLib scala_library rule was had only 1 Java file. Adding multiple java files will throw the similar error :), will fix it in PR

from rules_scala.

johnynek avatar johnynek commented on July 16, 2024

👍

from rules_scala.

sentinelleader avatar sentinelleader commented on July 16, 2024

fix has been merged :)

from rules_scala.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.