Run jar with parameters in gradle

后端 未结 2 968
半阙折子戏
半阙折子戏 2021-02-07 04:54

I want to run a jar file with parameters located at C:/Users/nwuser/FitNesse/fitnesse-standalone.jar in my gradle script. I know how to do it without parameters:



        
相关标签:
2条回答
  • 2021-02-07 05:00

    If you're just trying to run a FitNesse test suite with Gradle, you can add the FitNesse jar to your dependencies:

    repositories {
      mavenCentral()
    }
    
    dependencies {
      compile 'org.fitnesse:fitnesse:20161106'
    }
    

    and define a JavaExec task like so:

    task fitnesse(type: JavaExec) {
      classpath = sourceSets.main.runtimeClasspath
    
      main = 'fitnesseMain.FitNesseMain'
    
      args '-c', 'FrontPage?suite&format=text'
    }
    

    And then run:

    $ gradle fitnesse
    ...
    Executing command: FrontPage?suite&format=text
    --------
    0 Tests,        0 Failures      0.091 seconds.
    
    0 讨论(0)
  • 2021-02-07 05:02

    args is an array, so simply supply your arguments as such:

    task runJar(dependsOn:jar) << {
      javaexec { 
        main="-jar";
        args = [
                "C:/Users/nwuser/FitNesse/fitnesse-standalone.jar",
                "-c",
                "FrontPage?suite&format=text"
               ]
      } 
    }
    
    0 讨论(0)
提交回复
热议问题