Ejemplo n.º 1
0
  private void addRunTask() {
    JavaExec run = project.getTasks().create(TASK_RUN_NAME, JavaExec.class);
    run.setDescription("Runs this project as a JVM application");
    run.setGroup(APPLICATION_GROUP);

    JavaPluginConvention javaPluginConvention =
        project.getConvention().getPlugin(JavaPluginConvention.class);
    run.setClasspath(
        javaPluginConvention
            .getSourceSets()
            .getByName(SourceSet.MAIN_SOURCE_SET_NAME)
            .getRuntimeClasspath());
    run.getConventionMapping()
        .map(
            "main",
            new Callable<Object>() {
              @Override
              public Object call() throws Exception {
                return pluginConvention.getMainClassName();
              }
            });
    run.getConventionMapping()
        .map(
            "jvmArgs",
            new Callable<Object>() {
              @Override
              public Object call() throws Exception {
                return pluginConvention.getApplicationDefaultJvmArgs();
              }
            });
  }
  protected void doExec(List<String> args) {
    super.setArgs(args);
    super.setClasspath(getClasspath());

    super.exec();
  }