LoginSignup
2
1

More than 5 years have passed since last update.

GroovyのmainメソッドをGroovyスクリプトから呼ぶ

Last updated at Posted at 2016-11-17

TL;DR

script.groovy
@Grab("必要なものをごにょごにょ")

import package_name.class_name

package_name.class_name.main(args)

よく考えれば至極当然な話だった。思いつかなくて悔しい。

例:main側

SomeClass.groovy
package some

class SomeClass {
  public static void main(String[] args) {
    /** 処理 */
  }

  static AnyType otherMethod() {
    /** 処理 */
  }
}

例:呼び出しスクリプト

script.groovy
@Grab("必要なものをごにょごにょ")

import some.SomeClass

some.SomeClass.main(args)

mainメソッドをフルのネームスペースで呼び出すのがポイント(だと思う)。

参考

2
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1