GOSUC at command line giving issue

163 views
Skip to first unread message

Sreeram Ediga

unread,
Feb 15, 2018, 12:12:55 PM2/15/18
to gosu-lang
Hello,

I have a simple file that I am unable to get compiled at command line using GOSUC utility.
I know that it's best to do using IntelliJ plugin, but I am doing this for a POC that we want to try out in our company.

Can someone help on this, please?

My source file is under C:\gosu-1.14.6\Test
File name is HelloWorld.gs
File contents are --
        package hello;

        public class HelloWorld
        {
      public function sayHello() : String
      {
   return "Hello World"
      }
         }

Now, when I do these, I get the errors --

C:\gosu-1.14.6\Test>gosuc -d . *.gs
HelloWorld.gs:[1,9] error: The package name "hello" does not correspond with the directory "". [line:1 col:9] in
line 1: package hello;
line 2:
HelloWorld.gs:[3,14] error: The class name hello.HelloWorld does not correspond with the file HelloWorld. [line:3 col:14] in
line 2:
line 3: public class HelloWorld
line 4: {

gosuc completed with 0 warnings and 2 errors.

C:\gosu-1.14.6\Test>gosuc -d .\hello *.gs
HelloWorld.gs:[1,9] error: The package name "hello" does not correspond with the directory "". [line:1 col:9] in
line 1: package hello;
line 2:
HelloWorld.gs:[3,14] error: The class name hello.HelloWorld does not correspond with the file HelloWorld. [line:3 col:14] in
line 2:
line 3: public class HelloWorld
line 4: {

gosuc completed with 0 warnings and 2 errors.

C:\gosu-1.14.6\Test>gosuc -d C:\gosu-1.14.6\Test *.gs
HelloWorld.gs:[1,9] error: The package name "hello" does not correspond with the directory "". [line:1 col:9] in
line 1: package hello;
line 2:
HelloWorld.gs:[3,14] error: The class name hello.HelloWorld does not correspond with the file HelloWorld. [line:3 col:14] in
line 2:
line 3: public class HelloWorld
line 4: {

gosuc completed with 0 warnings and 2 errors.

C:\gosu-1.14.6\Test>gosuc -d C:\gosu-1.14.6\Test\hello  *.gs
HelloWorld.gs:[1,9] error: The package name "hello" does not correspond with the directory "". [line:1 col:9] in
line 1: package hello;
line 2:
HelloWorld.gs:[3,14] error: The class name hello.HelloWorld does not correspond with the file HelloWorld. [line:3 col:14] in
line 2:
line 3: public class HelloWorld
line 4: {

gosuc completed with 0 warnings and 2 errors.

 

Kyle Moore

unread,
Feb 15, 2018, 12:20:53 PM2/15/18
to gosu-lang
Hello Sreeram.

Input files need to be explicitly listed.

Using your source file, the following works for me:

/tmp/test$ tree
.
├── hello
  └── HelloWorld.gs
└── out

2 directories, 1 file
/tmp/test$ gosuc hello/HelloWorld.gs -d out/

gosuc completed
with 0 warnings and 0 errors.
/tmp/test$ tree
.
├── hello
  └── HelloWorld.gs
└── out
   
└── hello
       
├── HelloWorld.class
       
└── HelloWorld.gs

3 directories, 3 files

Sreeram Ediga

unread,
Feb 15, 2018, 12:42:35 PM2/15/18
to gosu-lang
Thank you so much, Kyle.
It worked like a charm :)

One follow-up question - how to compile all the source files present across sub-directories, under "src" folder, and place the generated .class files in corresponding sub-directories of "out"?
So, I have --

src
 -- A.gs
 -- first
      -- B.gs
 -- second
      -- C.gs

What I want is 

out
 -- A.class
 -- first
      -- B.class
 -- second
      -- C.class

Kyle Moore

unread,
Feb 15, 2018, 12:55:01 PM2/15/18
to gosu-lang
You'll need to include the -sourcepath argument to declare a source root, i.e. a folder which contains the root package.

Please try it this way:

gosuc -sourcepath src/ src/A.gs src/first/B.gs src/second/C.gs -d out/

Using your example:
/tmp/test$ tree
.
├── out
└── src
   
├── A.gs
   
├── first
   
  └── B.gs
   
└── second
       
└── C.gs

4 directories, 3 files
/tmp/test$ gosuc -sourcepath src/ src/A.gs src/first/B.gs src/second/C.gs -d out/


gosuc completed
with 0 warnings and 0 errors.
/tmp/test$ tree
.
├── out
  ├── A.class
  ├── A.gs
  ├── first
    ├── B.class
    └── B.gs
  └── second
      ├── C.class
      └── C.gs
└── src
   
├── A.gs
   
├── first
   
  └── B.gs
   
└── second
       
└── C.gs

6 directories, 9 files

You can view the command-line arguments by just typing `gosuc` with no arguments.

Finally, argument parsing is done by a shaded version of the excellent jcommander library, version 1.48. Argument files are also supported. You can read more about it at http://jcommander.org/.

Sreeram Ediga

unread,
Feb 15, 2018, 5:59:41 PM2/15/18
to gosu-lang
Thanks, Kyle.
Though it's repetitive, I can make it work.

One final question - if my gosu program is using a Java API (let's say apache-commons.jar or slf4j.jar), how do I make the gosuc to look into the JAR file?
Like in the case of javac, we use Classpath. Is there something similar?

Sreeram Ediga

unread,
Feb 15, 2018, 6:23:02 PM2/15/18
to gosu-lang
In continuation of my below question, should I first generate JAVA files from Gosu, and then use javac for compiling with help of CLASSPATH?
If so, is there a tool that generates Java files from Gosu classes?

Kyle Moore

unread,
Feb 15, 2018, 7:25:00 PM2/15/18
to gosu-lang
Though it's repetitive, I can make it work.

The gosuc executable was meant to be similar to javac. Consider using an arg file. Tooling for Maven and Gradle are available as well.


Like in the case of javac, we use Classpath. Is there something similar?

Again, please run gosuc with no arguments. You will see that the `-cp` or `-classpath` argument is available.

Sreeram Ediga

unread,
Feb 16, 2018, 12:17:18 PM2/16/18
to gosu-lang
Thanks, Kyle.

Sorry, I missed the "cp"option though I reviewed the help.
FYI - It worked.

And, finally, to close this topic, I have a project setup in IntelliJ with Gosu plugin from Guidewire.
Everything works fine. But, I am not able to find the generated .java or .class files for the Gosu classes that have been developed.
I even checked in the deployment server (Tomcat in our company), just to see if the .class files are present. I could see generated .class files for entities, PCFs etc, but not for the regular .gs classes that we had written.

Is there any option or facility using which I can catch hold of them?

Murali Garapati

unread,
Jun 25, 2020, 3:33:02 PM6/25/20
to gosu-lang
Hi Sreeram,

I have been looking for gosuc utility. Could you please tell me how I can get such utility.


Appreciate your help.


Thank you
Murali
Reply all
Reply to author
Forward
0 new messages