#2843 How to build to jar file on the terminal?

CretinHo Wed 16 Jun 2021

Assuming I have only one source file, test.fan, with no pod generated, no build script, nothing other than this source file.

This example here assumed I already have the pod, isn't it?

https://fantom.org/doc/examples/java-buildjardist

My test.fan is simple. The pod name, I think, is test, isn't it?

The class name is test, too. So type name is test, isn't it?

The main method of course is main.

So I have dist.mainMethod like this:

dist.mainMethod = "test::test.main"

But regardless of how many times I tried with different possible values I could think of, what I get is always this:

JarDist ERR: mainMethod not found: test::test.main BUILD FAILED [9ms]!

So what did I do wrong? Or this script assumed I already have the test.pod?

I think it's not the case, because I did put test.pod in the same directory, it's still fail with the same error!

CretinHo Thu 17 Jun 2021

I understand. It does expect the pod to be already available, not in the current directory but in $FAN_HOME/lib/fan

This script worked well:

using build

class Build : BuildScript {

@Target { help = "build test pod as a single JAR dist" }

Void distWisp()
{
  dist := JarDist(this)
  dist.outFile = `./test.jar`.toFile.normalize
  dist.podNames = Str["test", "build", "compiler"]
  dist.mainMethod = "test::test.main"
  dist.run
}

}

Login or Signup to reply.