Exemple #1
0
 /** @see #exec(Project, JavaExecable, Action) */
 public static <T extends JavaExecable> T execWithoutGradle(T input, Action<JavaExecSpec> settings)
     throws Throwable {
   FileCollection classpath = JavaExecableImp.fromLocalClassloader();
   return JavaExecableImp.execInternal(
       input,
       classpath,
       settings,
       execSpec -> JavaExecWinFriendly.javaExecWithoutGradle(execSpec));
 }
Exemple #2
0
 /**
  * @param project the project on which we'll call {@link Project#javaexec(Action)}.
  * @param input the JavaExecable which we'll take as input and call run() on.
  * @param settings any extra settings you'd like to set on the JavaExec (e.g. heap)
  * @return the JavaExecable after it has had run() called.
  */
 public static <T extends JavaExecable> T exec(
     Project project, T input, Action<JavaExecSpec> settings) throws Throwable {
   // copy the classpath from the project's buildscript (and its parents)
   List<FileCollection> classpaths =
       TreeStream.toParent(ProjectPlugin.treeDef(), project)
           .map(p -> p.getBuildscript().getConfigurations().getByName(BUILDSCRIPT_CLASSPATH))
           .collect(Collectors.toList());
   // add the gradleApi, workaround from
   // https://discuss.gradle.org/t/gradle-doesnt-add-the-same-dependencies-to-classpath-when-applying-plugins/9759/6?u=ned_twigg
   classpaths.add(
       project.getConfigurations().detachedConfiguration(project.getDependencies().gradleApi()));
   // add stuff from the local classloader too, to fix testkit's classpath
   classpaths.add(JavaExecableImp.fromLocalClassloader());
   // run it
   FileCollection classpath = new UnionFileCollection(classpaths);
   return JavaExecableImp.execInternal(
       input, classpath, settings, execSpec -> JavaExecWinFriendly.javaExec(project, execSpec));
 }