guchenbo / simple-build-tool

Automatically exported from code.google.com/p/simple-build-tool
Other
0 stars 0 forks source link

SBT doesn't properly pass paths to javac #161

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem (please be specific)?
Run compile on a project with a java file with some utf8 characters.

What is the expected behavior? What do you see instead?
Expected: compile should run fine.
I get ({SOURCEPATH} is my full source path):
[info] == compile ==
[info]   Source analysis: 9 new/modified, 0 indirectly invalidated, 0 removed.
[info] Compiling main sources...
[error] javac: file not found: C:\{SOURCEPATH}\objekti\ToÄŤka.java
[error] Usage: javac <options> <source files>
[error] use -help for a list of possible options
[info] == compile ==
[error] Error running compile: javac returned nonzero exit code
[info] 
[info] Total time: 7 s, completed 08.04.2011. 18:49:50

What versions of the following are you using?

Java: jre 7 32bit
Scala: 2.9.0.RC1
sbt: 0.7.5
Operating system: Windows 7 Professional 64bit

Please provide any additional information below.
I'm guessing the issue is with SBT because compilation completes fine under 
IntelliJ IDEA without SBT. I have both compileOptions("-encoding", "utf8") and 
javaCompileOptions("-encoding", "utf8") but that didn't help.

I've tried searching about this issue, but without success.

Thanks.

Original issue reported on code.google.com by seriousworm on 8 Apr 2011 at 4:53

GoogleCodeExporter commented 9 years ago
I forgot to mention that the correct file name is "Točka.java". Also, the 
scala sources compile fine, and none of the Java sources compile at all 
(obviously).

Original comment by seriousworm on 8 Apr 2011 at 4:55

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
It would help if you could show how it works using command line javac, 
including all encoding-related settings, environment variables, and system 
properties you had to configure to make it work.  From what I can tell, 
'-encoding' only affects the contents of the source file and not the filename 
encoding.

Original comment by dmhar...@gmail.com on 4 May 2011 at 12:58

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
Sure: javac command line from cmd.exe (Windows 7 x64):
javac -encoding utf8 -classpath 
.;lib/lwjgl/lwjgl.jar;lib/lwjgl/lwjgl_test.jar;lib/lwjgl/lwjgl_util.jar;lib/lwjg
l/jinput.jar -sourcepath src/ src/{SOURCEPATH}/AMainClass.java

AMainClass.java references Točka2D(.java) so obviously javac compiles that too 
(and indeed, I verified and there it is, Točka2D.class in the source 
directory, since I compiled without specifying any directory for output 
classes). The compile proceeds with 0 errors.

I didn't have to configure anything, I just opened cmd.exe and called javac 
(the path has c:\program files (x86)\java\jdk7\bin in it). This is the Java 7 
SDK.

Original comment by seriousworm on 4 May 2011 at 8:26

GoogleCodeExporter commented 9 years ago
That doesn't specify Točka2D on the command line, though.  sbt is going to 
pass the name of the source file explicitly to javac.  This is what needs to 
work:

javac <options> Točka2D.java

for some <options>.

Original comment by dmhar...@gmail.com on 4 May 2011 at 9:33

GoogleCodeExporter commented 9 years ago
If I specify that line, it compiles successfully. However, if I change the 
filename to an invalid one with the same UTF-8 characters, the output is 
garbled:

javac (options) invalidPath\Točka2D.java
javac: file not found: invalidPath\ToŔka2D.java 

Not sure if that is relevant.

Original comment by seriousworm on 4 May 2011 at 9:57

GoogleCodeExporter commented 9 years ago
This works for me:

  override def javaCompileOptions = javaCompileOptions("-encoding", "utf8")

Original comment by dmhar...@gmail.com on 4 May 2011 at 10:53

GoogleCodeExporter commented 9 years ago
Actually I've already specified that, see my initial post above. My line is:

override def javaCompileOptions = super.javaCompileOptions ++ 
javaCompileOptions("-source", "1.6") ++ javaCompileOptions("-encoding", "utf8")

(unless that line is somehow invalid? But shouldn't sbt throw an error then?)

I've also tried running sbt from commandline (cmd.exe), the same one where 
invoking javac directly on the target file works. Same error.

Original comment by seriousworm on 5 May 2011 at 5:02

GoogleCodeExporter commented 9 years ago
Sorry, my point was that it isn't a bug in sbt but it is likely a configuration 
problem.  Perhaps you have not set -Dfile.encoding=utf8.  In any case, please 
use the mailing list for further discussion.

Original comment by dmhar...@gmail.com on 12 May 2011 at 3:09