Java 类org.gradle.api.plugins.JavaPlugin 实例源码

项目:Reer    文件:OsgiPlugin.java   
public void apply(final Project project) {
    project.getPluginManager().apply(JavaBasePlugin.class);

    final OsgiPluginConvention osgiConvention = new OsgiPluginConvention((ProjectInternal) project);
    project.getConvention().getPlugins().put("osgi", osgiConvention);

    project.getPlugins().withType(JavaPlugin.class, new Action<JavaPlugin>() {
        @Override
        public void execute(JavaPlugin javaPlugin) {
            OsgiManifest osgiManifest = osgiConvention.osgiManifest();
            osgiManifest.setClassesDir(project.getConvention().getPlugin(JavaPluginConvention.class).getSourceSets().getByName("main").getOutput().getClassesDir());
            osgiManifest.setClasspath(project.getConfigurations().getByName("runtime"));
            Jar jarTask = (Jar) project.getTasks().getByName("jar");
            jarTask.setManifest(osgiManifest);
        }
    });
}
项目:Reer    文件:JacocoPlugin.java   
/**
 * Adds report tasks for specific default test tasks.
 *
 * @param extension the extension describing the test task names
 */
private void addDefaultReportTasks(final JacocoPluginExtension extension) {
    project.getPlugins().withType(JavaPlugin.class, new Action<JavaPlugin>() {
        @Override
        public void execute(JavaPlugin javaPlugin) {
            project.getTasks().withType(Test.class, new Action<Test>() {
                @Override
                public void execute(Test task) {
                    if (task.getName().equals(JavaPlugin.TEST_TASK_NAME)) {
                        addDefaultReportTask(extension, task);
                    }
                }
            });
        }
    });
}
项目:Reer    文件:EclipseWtpPlugin.java   
private void configureEclipseProject(final Project project) {
    Action<Object> action = new Action<Object>() {
        @Override
        public void execute(Object ignored) {
            project.getTasks().withType(GenerateEclipseProject.class, new Action<GenerateEclipseProject>() {
                @Override
                public void execute(GenerateEclipseProject task) {
                    task.getProjectModel().buildCommand("org.eclipse.wst.common.project.facet.core.builder");
                    task.getProjectModel().buildCommand("org.eclipse.wst.validation.validationbuilder");
                    task.getProjectModel().natures("org.eclipse.wst.common.project.facet.core.nature");
                    task.getProjectModel().natures("org.eclipse.wst.common.modulecore.ModuleCoreNature");
                    task.getProjectModel().natures("org.eclipse.jem.workbench.JavaEMFNature");
                }

            });
        }

    };
    project.getPlugins().withType(JavaPlugin.class, action);
    project.getPlugins().withType(EarPlugin.class, action);
}
项目:gradle-capsule-plugin    文件:Plugin.java   
@Override public void apply(Project project) {
  project.getPluginManager().apply(JavaPlugin.class);

  project.getConfigurations().create("capsule").defaultDependencies(dependencySet -> {
    dependencySet.add(project.getDependencies().create("co.paralleluniverse:capsule:1.0.3"));
  });

  project.getTasks().withType(Capsule.class).all(task -> task.executesInside(project));

  Capsule capsuleTask = project.getTasks().create("capsule", Capsule.class);
  capsuleTask.setGroup(BUILD_GROUP);
  capsuleTask.setDescription("Assembles a jar archive containing Capsule, caplets, and necessary jars to run an application.");

  Task assembleTask = project.getTasks().findByName("assemble");
  assembleTask.dependsOn(capsuleTask);

  Task jarTask = project.getTasks().findByName("jar");
  capsuleTask.dependsOn(jarTask);
}
项目:gradle-java-modules    文件:JigsawPlugin.java   
private void configureCompileTestJavaTask(final Project project) {
    final JavaCompile compileTestJava = (JavaCompile) project.getTasks()
            .findByName(JavaPlugin.COMPILE_TEST_JAVA_TASK_NAME);
    final SourceSet test = ((SourceSetContainer) project.getProperties().get("sourceSets")).getByName("test");
    final JavaModule module = (JavaModule) project.getExtensions().getByName(EXTENSION_NAME);
    compileTestJava.getInputs().property("moduleName", module.geName());
    compileTestJava.doFirst(new Action<Task>() {
        @Override
        public void execute(Task task) {
            List<String> args = new ArrayList<>();
            args.add("--module-path");
            args.add(compileTestJava.getClasspath().getAsPath());
            args.add("--add-modules");
            args.add("junit");
            args.add("--add-reads");
            args.add(module.geName() + "=junit");
            args.add("--patch-module");
            args.add(module.geName() + "=" + test.getJava().getSourceDirectories().getAsPath());
            compileTestJava.getOptions().setCompilerArgs(args);
            compileTestJava.setClasspath(project.files());
        }
    });
}
项目:gradle-java-modules    文件:JigsawPlugin.java   
private void configureTestTask(final Project project) {
    final Test testTask = (Test) project.getTasks().findByName(JavaPlugin.TEST_TASK_NAME);
    final SourceSet test = ((SourceSetContainer) project.getProperties().get("sourceSets")).getByName("test");
    final JavaModule module = (JavaModule) project.getExtensions().getByName(EXTENSION_NAME);
    testTask.getInputs().property("moduleName", module.geName());
    testTask.doFirst(new Action<Task>() {
        @Override
        public void execute(Task task) {
            List<String> args = new ArrayList<>();
            args.add("--module-path");
            args.add(testTask.getClasspath().getAsPath());
            args.add("--add-modules");
            args.add("ALL-MODULE-PATH");
            args.add("--add-reads");
            args.add(module.geName() + "=junit");
            args.add("--patch-module");
            args.add(module.geName() + "=" + test.getJava().getOutputDir());
            testTask.setJvmArgs(args);
            testTask.setClasspath(project.files());
        }
    });
}
项目:crnk-framework    文件:PublishTypescriptTaskTest.java   
@Test
public void checkTaskProperties() throws IOException {
    System.setProperty(Context.INITIAL_CONTEXT_FACTORY, DummyInitialContextFactory.class.getName());

    testProjectDir.newFolder("src", "main", "java");

    File outputDir = testProjectDir.getRoot();

    Project project = ProjectBuilder.builder().withName("crnk-gen-typescript-test").withProjectDir(outputDir).build();
    project.setVersion("0.0.1");
    project.getPluginManager().apply(JavaPlugin.class);
    project.getPluginManager().apply(TSGeneratorPlugin.class);

    TSGeneratorExtension extension = project.getExtensions().getByType(TSGeneratorExtension.class);
    extension.getRuntime().setConfiguration(null);

    TSGeneratorPlugin plugin = project.getPlugins().getPlugin(TSGeneratorPlugin.class);
    plugin.init(project);

    PublishTypescriptStubsTask task = (PublishTypescriptStubsTask) project.getTasks().getByName("publishTypescript");
    Assert.assertEquals("publish", task.getGroup());
    Assert.assertNotNull(task.getDescription());
    Assert.assertFalse(task.getInputs().getFiles().isEmpty());
    Assert.assertFalse(task.getOutputs().getFiles().isEmpty());
}
项目:crnk-framework    文件:RuntimeClassoaderFactoryTest.java   
@Before
public void setup() throws IOException {
    // Deltaspike sometimes really wants to have a retarded JNDI context
    System.setProperty(Context.INITIAL_CONTEXT_FACTORY, DummyInitialContextFactory.class.getName());

    testProjectDir.newFolder("src", "main", "java");

    File outputDir = testProjectDir.getRoot();

    Project project = ProjectBuilder.builder().withName("crnk-gen-typescript-test").withProjectDir(outputDir).build();
    project.setVersion("0.0.1");

    project.getPluginManager().apply("com.moowork.node");
    project.getPluginManager().apply(JavaPlugin.class);
    project.getPluginManager().apply(TSGeneratorPlugin.class);

    TSGeneratorExtension config = project.getExtensions().getByType(TSGeneratorExtension.class);
    config.getRuntime().setConfiguration("test");

    factory = new RuntimeClassLoaderFactory(project);
    ClassLoader parentClassLoader = getClass().getClassLoader();
    classLoader = factory.createClassLoader(parentClassLoader);
    sharedClassLoader = (RuntimeClassLoaderFactory.SharedClassLoader) classLoader.getParent();

}
项目:curiostack    文件:CuriostackPlugin.java   
private static void addStandardJavaTestDependencies(Project project) {
  Configuration testConfiguration =
      project.getPlugins().hasPlugin(JavaLibraryPlugin.class)
          ? project
              .getConfigurations()
              .getByName(JavaPlugin.TEST_IMPLEMENTATION_CONFIGURATION_NAME)
          : project.getConfigurations().getByName(JavaPlugin.TEST_COMPILE_CONFIGURATION_NAME);
  DependencyHandler dependencies = project.getDependencies();

  dependencies.add(JavaPlugin.COMPILE_ONLY_CONFIGURATION_NAME, "com.google.code.findbugs:jsr305");
  dependencies.add(testConfiguration.getName(), "org.curioswitch.curiostack:curio-testing-framework");
  dependencies.add(testConfiguration.getName(), "org.assertj:assertj-core");
  dependencies.add(testConfiguration.getName(), "org.awaitility:awaitility");
  dependencies.add(testConfiguration.getName(), "junit:junit");
  dependencies.add(testConfiguration.getName(), "org.mockito:mockito-core");
  dependencies.add(testConfiguration.getName(), "info.solidsoft.mockito:mockito-java8");
}
项目:gradle-plugins    文件:WarAttachClassesPlugin.java   
@Override
public void apply(Project project) {
    project.getPlugins().apply(WarPlugin.class);

    WarAttachClassesConvention attachClassesConvention = new WarAttachClassesConvention();

    War war = (War) project.getTasks().getByName(WarPlugin.WAR_TASK_NAME);
    war.getConvention().getPlugins().put("attachClasses", attachClassesConvention);

    project.afterEvaluate(p -> {
        if (attachClassesConvention.isAttachClasses()) {
            Jar jar = (Jar) project.getTasks().getByName(JavaPlugin.JAR_TASK_NAME);
            jar.setClassifier(attachClassesConvention.getClassesClassifier());

            project.getArtifacts().add(Dependency.ARCHIVES_CONFIGURATION, jar);
        }
    });
}
项目:gradle-project-config    文件:MavenConfigPlugin.java   
/**
 * Initialize the Maven configuration
 *
 * @param mavenConfig Maven configuration to initialize
 * @param projectContext Project context
 * @param configurations Configuration container
 */
@Defaults
public void initializeMavenConfig(MavenConfig mavenConfig, ProjectContext projectContext,
        ConfigurationContainer configurations) {
    mavenConfig.getPublications().create(SourceSet.MAIN_SOURCE_SET_NAME, p -> {
        p.setArtifactId(projectContext.getName());
        p.setArchivesConfiguration(Dependency.ARCHIVES_CONFIGURATION);
        p.setAddProjectArtifacts(false);
        p.setCompileConfigurations(Collections.singletonList(JavaPlugin.COMPILE_CONFIGURATION_NAME));
        p.setRuntimeConfigurations(Collections.singletonList(JavaPlugin.RUNTIME_CONFIGURATION_NAME));
    });

    if (configurations.findByName("testArchives") != null) {
        mavenConfig.getPublications().create(SourceSet.TEST_SOURCE_SET_NAME, p -> {
            p.setArtifactId(projectContext.getName() + "-" + SourceSet.TEST_SOURCE_SET_NAME);
            p.setArchivesConfiguration(Names.formatName("", Dependency.ARCHIVES_CONFIGURATION,
                    SourceSet.TEST_SOURCE_SET_NAME));
            p.setAddProjectArtifacts(true);
            p.setCompileConfigurations(
                    Collections.singletonList(JavaPlugin.TEST_COMPILE_CONFIGURATION_NAME));
            p.setRuntimeConfigurations(
                    Collections.singletonList(JavaPlugin.TEST_RUNTIME_CONFIGURATION_NAME));
        });
    }
}
项目:gradle-project-config    文件:MavenConfigPlugin.java   
/**
 * Initialize the Maven configuration
 *
 * @param mavenConfig Maven configuration to initialize
 * @param projectContext Project context
 */
@Defaults
public void initializeMavenConfig(MavenConfig mavenConfig, ProjectContext projectContext) {
    mavenConfig.getPublications().create(SourceSet.MAIN_SOURCE_SET_NAME, p -> {
        p.setArtifactId(projectContext.getName());
        p.setArchivesConfiguration(Dependency.ARCHIVES_CONFIGURATION);
        p.setAddProjectArtifacts(false);
        p.setCompileConfigurations(Collections.singletonList(JavaPlugin.COMPILE_CONFIGURATION_NAME));
        p.setRuntimeConfigurations(Collections.singletonList(JavaPlugin.RUNTIME_CONFIGURATION_NAME));
    });

    mavenConfig.getPublications().create(SourceSet.TEST_SOURCE_SET_NAME, p -> {
        p.setArtifactId(projectContext.getName() + "-" + SourceSet.TEST_SOURCE_SET_NAME);
        p.setArchivesConfiguration(
                Names.formatName("", Dependency.ARCHIVES_CONFIGURATION, SourceSet.TEST_SOURCE_SET_NAME));
        p.setAddProjectArtifacts(true);
        p.setCompileConfigurations(Collections.singletonList(JavaPlugin.TEST_COMPILE_CONFIGURATION_NAME));
        p.setRuntimeConfigurations(Collections.singletonList(JavaPlugin.TEST_RUNTIME_CONFIGURATION_NAME));
    });
}
项目:app-gradle-plugin    文件:AppEngineStandardExtensionTest.java   
private Project setUpTestProject(String buildFileName) throws IOException {
  Path buildFile = testProjectDir.getRoot().toPath().resolve("build.gradle");
  InputStream buildFileContent =
      getClass()
          .getClassLoader()
          .getResourceAsStream(
              "projects/AppEnginePluginTest/Extension/" + buildFileName + ".gradle");
  Files.copy(buildFileContent, buildFile);

  Path webInf = testProjectDir.getRoot().toPath().resolve("src/main/webapp/WEB-INF");
  Files.createDirectories(webInf);
  File appengineWebXml = Files.createFile(webInf.resolve("appengine-web.xml")).toFile();
  Files.write(appengineWebXml.toPath(), "<appengine-web-app/>".getBytes(Charsets.UTF_8));

  Project p = ProjectBuilder.builder().withProjectDir(testProjectDir.getRoot()).build();
  p.getPluginManager().apply(JavaPlugin.class);
  p.getPluginManager().apply(WarPlugin.class);
  p.getPluginManager().apply(AppEngineStandardPlugin.class);
  ((ProjectInternal) p).evaluate();

  return p;
}
项目:app-gradle-plugin    文件:SourceContextPluginTest.java   
@Test
public void testDefaultConfiguration() throws IOException {
  File appengineWebXml =
      new File(testProjectDir.getRoot(), "src/main/webapp/WEB-INF/appengine-web.xml");
  appengineWebXml.getParentFile().mkdirs();
  appengineWebXml.createNewFile();
  Files.write(appengineWebXml.toPath(), "<web-app/>".getBytes());

  Project project = ProjectBuilder.builder().withProjectDir(testProjectDir.getRoot()).build();
  project.getPluginManager().apply(JavaPlugin.class);
  project.getPluginManager().apply(WarPlugin.class);
  project.getPluginManager().apply(AppEngineStandardPlugin.class);
  project.getPluginManager().apply(SourceContextPlugin.class);
  ((ProjectInternal) project).evaluate();

  ExtensionAware ext =
      (ExtensionAware) project.getExtensions().getByName(AppEngineCorePlugin.APPENGINE_EXTENSION);
  GenRepoInfoFileExtension genRepoInfoExt =
      new ExtensionUtil(ext).get(SourceContextPlugin.SOURCE_CONTEXT_EXTENSION);
  Assert.assertEquals(
      new File(project.getBuildDir(), "sourceContext"), genRepoInfoExt.getOutputDirectory());
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:RepackagePluginFeatures.java   
private void addRepackageTask(Project project) {
    RepackageTask task = project.getTasks().create(REPACKAGE_TASK_NAME,
            RepackageTask.class);
    task.setDescription("Repackage existing JAR and WAR "
            + "archives so that they can be executed from the command "
            + "line using 'java -jar'");
    task.setGroup(BasePlugin.BUILD_GROUP);
    Configuration runtimeConfiguration = project.getConfigurations()
            .getByName(JavaPlugin.RUNTIME_CONFIGURATION_NAME);
    TaskDependency runtimeProjectDependencyJarTasks = runtimeConfiguration
            .getTaskDependencyFromProjectDependency(true, JavaPlugin.JAR_TASK_NAME);
    task.dependsOn(
            project.getConfigurations().getByName(Dependency.ARCHIVES_CONFIGURATION)
                    .getAllArtifacts().getBuildDependencies(),
            runtimeProjectDependencyJarTasks);
    registerOutput(project, task);
    ensureTaskRunsOnAssembly(project, task);
    ensureMainClassHasBeenFound(project, task);
}
项目:wildfly-swarm    文件:PackagePlugin.java   
/**
 * Returns the most suitable Archive-Task for wrapping in the swarm jar - in the following order:
 *
 * 1. Custom-JAR-Task defined in SwarmExtension 'archiveTask'
 * 2. WAR-Task
 * 3. JAR-Task
 */
private Jar getArchiveTask(Project project) {

    TaskCollection<Jar> existingArchiveTasks = project.getTasks().withType(Jar.class);
    Jar customArchiveTask = project.getExtensions().getByType(SwarmExtension.class).getArchiveTask();

    if (customArchiveTask != null) {
        return existingArchiveTasks.getByName(customArchiveTask.getName());

    } else if (existingArchiveTasks.findByName(WarPlugin.WAR_TASK_NAME) != null) {
        return existingArchiveTasks.getByName(WarPlugin.WAR_TASK_NAME);

    } else if (existingArchiveTasks.findByName(JavaPlugin.JAR_TASK_NAME) != null) {
        return existingArchiveTasks.getByName(JavaPlugin.JAR_TASK_NAME);
    }

    return null;
}
项目:parsec    文件:ParsecGradlePlugin.java   
@Override
public void apply(Project project) {
    ParsecPluginExtension pluginExtension = project.getExtensions().create("parsec", ParsecPluginExtension.class);
    PathUtils pathUtils = new PathUtils(project, pluginExtension);
    TaskContainer tasks = project.getTasks();

    // Create tasks (when applied as a plugin)
    ParsecInitTask initTask = tasks.create("parsec-init", ParsecInitTask.class);
    ParsecGenerateTask generateTask = tasks.create("parsec-generate", ParsecGenerateTask.class);

    // Make generate trigger init.
    generateTask.dependsOn(initTask);

    project.getPlugins().withType(JavaPlugin.class, plugin -> {
        SourceSet sourceSet = ((SourceSetContainer) project.getProperties().get("sourceSets")).getByName("main");

        // Add ${buildDir}/generated-sources/java to sources
        sourceSet.getJava().srcDir(pathUtils.getGeneratedSourcesPath());

        // Add ${buildDir}/generated-resources/parsec to resources
        sourceSet.getResources().srcDir(pathUtils.getGeneratedResourcesPath());

        // Make compileJava trigger generate
        tasks.getByName(JavaPlugin.COMPILE_JAVA_TASK_NAME).dependsOn(generateTask);
    });
}
项目:spring-boot-concourse    文件:RepackagePluginFeatures.java   
private void addRepackageTask(Project project) {
    RepackageTask task = project.getTasks().create(REPACKAGE_TASK_NAME,
            RepackageTask.class);
    task.setDescription("Repackage existing JAR and WAR "
            + "archives so that they can be executed from the command "
            + "line using 'java -jar'");
    task.setGroup(BasePlugin.BUILD_GROUP);
    Configuration runtimeConfiguration = project.getConfigurations()
            .getByName(JavaPlugin.RUNTIME_CONFIGURATION_NAME);
    TaskDependency runtimeProjectDependencyJarTasks = runtimeConfiguration
            .getTaskDependencyFromProjectDependency(true, JavaPlugin.JAR_TASK_NAME);
    task.dependsOn(
            project.getConfigurations().getByName(Dependency.ARCHIVES_CONFIGURATION)
                    .getAllArtifacts().getBuildDependencies(),
            runtimeProjectDependencyJarTasks);
    registerOutput(project, task);
    ensureTaskRunsOnAssembly(project, task);
    ensureMainClassHasBeenFound(project, task);
}
项目:gradle-plugins    文件:WarAttachClassesPlugin.java   
@Override
public void apply(Project project) {
    project.getPlugins().apply(WarPlugin.class);

    WarAttachClassesConvention attachClassesConvention = new WarAttachClassesConvention();

    War war = (War) project.getTasks().getByName(WarPlugin.WAR_TASK_NAME);
    war.getConvention().getPlugins().put("attachClasses", attachClassesConvention);

    project.afterEvaluate(p -> {
        if (attachClassesConvention.isAttachClasses()) {
            Jar jar = (Jar) project.getTasks().getByName(JavaPlugin.JAR_TASK_NAME);
            jar.setClassifier(attachClassesConvention.getClassesClassifier());

            project.getArtifacts().add(Dependency.ARCHIVES_CONFIGURATION, jar);
        }
    });
}
项目:contestparser    文件:RepackagePluginFeatures.java   
private void addRepackageTask(Project project) {
    RepackageTask task = project.getTasks().create(REPACKAGE_TASK_NAME,
            RepackageTask.class);
    task.setDescription("Repackage existing JAR and WAR "
            + "archives so that they can be executed from the command "
            + "line using 'java -jar'");
    task.setGroup(BasePlugin.BUILD_GROUP);
    Configuration runtimeConfiguration = project.getConfigurations()
            .getByName(JavaPlugin.RUNTIME_CONFIGURATION_NAME);
    TaskDependency runtimeProjectDependencyJarTasks = runtimeConfiguration
            .getTaskDependencyFromProjectDependency(true, JavaPlugin.JAR_TASK_NAME);
    task.dependsOn(
            project.getConfigurations().getByName(Dependency.ARCHIVES_CONFIGURATION)
                    .getAllArtifacts().getBuildDependencies(),
            runtimeProjectDependencyJarTasks);
    registerOutput(project, task);
    ensureTaskRunsOnAssembly(project, task);
    ensureMainClassHasBeenFound(project, task);
}
项目:jsweet-gradle-plugin    文件:JSweetPlugin.java   
@Override
public void apply(final Project project) {
    Logger logger = project.getLogger();
    logger.info("applying jsweet plugin");

    if (!project.getPlugins().hasPlugin(JavaPlugin.class) && !project.getPlugins().hasPlugin(WarPlugin.class)) {
        logger.error("No java or war plugin detected. Enable java or war plugin.");
        throw new IllegalStateException("No java or war plugin detected. Enable java or war plugin.");
    }

    JSweetPluginExtension extension = project.getExtensions().create("jsweet", JSweetPluginExtension.class);

    JavaPluginConvention javaPluginConvention = project.getConvention().getPlugin(JavaPluginConvention.class);
    SourceSetContainer sourceSets = javaPluginConvention.getSourceSets();
    SourceSet mainSources = sourceSets.getByName(SourceSet.MAIN_SOURCE_SET_NAME);

    JSweetTranspileTask task = project.getTasks().create("jsweet", JSweetTranspileTask.class);
    task.setGroup("generate");
    task.dependsOn(JavaPlugin.COMPILE_JAVA_TASK_NAME);
    task.setConfiguration(extension);
    task.setSources(mainSources.getAllJava());
    task.setClasspath(mainSources.getCompileClasspath());

    JSweetCleanTask cleanTask = project.getTasks().create("jsweetClean", JSweetCleanTask.class);
    cleanTask.setConfiguration(extension);
}
项目:putnami-gradle-plugin    文件:CodeServerBuilder.java   
private Collection<File> listProjectDepsSrcDirs(Project project) {
    ConfigurationContainer configs = project.getConfigurations();
    Configuration compileConf = configs.getByName(JavaPlugin.COMPILE_CLASSPATH_CONFIGURATION_NAME);
    DependencySet depSet = compileConf.getAllDependencies();

    List<File> result = Lists.newArrayList();
    for (Dependency dep : depSet) {
        if (dep instanceof ProjectDependency) {
            Project projectDependency = ((ProjectDependency) dep).getDependencyProject();
            if (projectDependency.getPlugins().hasPlugin(PwtLibPlugin.class)) {
                JavaPluginConvention javaConvention = projectDependency.getConvention().getPlugin(JavaPluginConvention.class);
                SourceSet mainSourceSet = javaConvention.getSourceSets().getByName(SourceSet.MAIN_SOURCE_SET_NAME);

                result.addAll(mainSourceSet.getAllSource().getSrcDirs());
            }
        }
    }
    return result;
}
项目:goomph    文件:NativeDepsPlugin.java   
@Override
protected void applyOnce(Project project) {
    String swtGroup = getGroup(project);

    // add the p2 repo and its dependencies
    AsMavenPlugin asMavenPlugin = ProjectPlugin.getPlugin(project, AsMavenPlugin.class);
    asMavenPlugin.extension().group(swtGroup, group -> {
        group.repo(getRepo(project));
        DEPS.forEach(group::iu);
    });

    // add all of SWT's dependencies 
    ProjectPlugin.getPlugin(project, JavaPlugin.class);
    for (String dep : DEPS) {
        project.getDependencies().add("compile", swtGroup + ":" + dep + ":+");
    }
    project.getDependencies().add("compile", swtGroup + ":" + SWT + "." + SwtPlatform.getRunning() + ":+");
}
项目:nw-gradle    文件:NWEjbPlugin.java   
@Override
public void apply(final Project project) {
  project.getPlugins().apply(JavaPlugin.class);
  project.getPlugins().apply(NWEarPlugin.class);
  //    super.apply(project);
  //NWEar earTask = super.getEarTask();
  NWEar earTask = (NWEar)project.getTasks().findByName("nwear");
  DependenciesUtil.configureProvidedConfigurations(project);
  configureJarTaskDependency(project, earTask);
  configureDependencyJarFileSources(project, earTask);
  configureJarMetaInfCopy(project);


  //Tells SAPManifest to include the dependencies section. Needed for ejb ears, but not web.
  //this is configuration time when they apply the plugin, so the user may still override it in build.gradle
  //after applying the plugin
  //System.out.println("earTask.getSapManifest():"+earTask.getSapManifest());
  earTask.getSapManifest().setIncludeDependencies(true);
}
项目:nw-gradle    文件:DependenciesUtil.java   
/**
 * Setup the the 'providedCompile' and 'providedRuntime' configurations, just like War.
 * TODO See if we can recursively get all the dependent projects and apply it to them too.
 * But it would have to be a future action.
 */
public static void configureProvidedConfigurations(final Project project) {
  ConfigurationContainer configurationContainer = project.getConfigurations();
  Configuration provideCompileConfiguration = configurationContainer.findByName(WarPlugin.PROVIDED_COMPILE_CONFIGURATION_NAME);
  if (provideCompileConfiguration==null) {
    provideCompileConfiguration = configurationContainer.create(WarPlugin.PROVIDED_COMPILE_CONFIGURATION_NAME)
                                  .setVisible(false)
                                  .setDescription("Additional compile classpath for libraries that should not be part of the archive.");
    configurationContainer.getByName(JavaPlugin.COMPILE_CONFIGURATION_NAME).extendsFrom(provideCompileConfiguration);
  }
  Configuration provideRuntimeConfiguration = configurationContainer.findByName(WarPlugin.PROVIDED_RUNTIME_CONFIGURATION_NAME);
  if (provideRuntimeConfiguration==null) {
    provideRuntimeConfiguration = configurationContainer.create(WarPlugin.PROVIDED_RUNTIME_CONFIGURATION_NAME)
                                  .setVisible(false)
                                  .extendsFrom(provideCompileConfiguration)
                                  .setDescription("Additional runtime classpath for libraries that should not be part of the archive.");
    configurationContainer.getByName(JavaPlugin.RUNTIME_CONFIGURATION_NAME).extendsFrom(provideRuntimeConfiguration);
  }
}
项目:gradle-wsimport-plugin    文件:WsimportPlugin.java   
/**
 * @see org.gradle.api.Plugin#apply(java.lang.Object)
 */
@Override
public void apply(Project project) {
    project.getPlugins().apply(ComponentModelBasePlugin.class);
    project.getPlugins().apply(JavaPlugin.class);

    project.getConfigurations().create("jaxws", c -> {
        c.setDescription("The JAX-WS libraries used.");
        c.setVisible(false);
        c.setTransitive(true);
        c.extendsFrom(project.getConfigurations().getByName("compileClasspath"));
    });

    project.getConfigurations().create("xjc", c -> {
        c.setDescription("The plugin libraries used for xjc.");
        c.setVisible(false);
        c.setTransitive(true);
    });

    project.getDependencies().add("jaxws", "com.sun.xml.ws:jaxws-tools:2.2.10");
}
项目:okbuck    文件:ProjectUtil.java   
public static ProjectType getType(Project project) {
    PluginContainer plugins = project.getPlugins();
    if (plugins.hasPlugin(AppPlugin.class)) {
        return ProjectType.ANDROID_APP;
    } else if (plugins.hasPlugin(LibraryPlugin.class)) {
        return ProjectType.ANDROID_LIB;
    } else if (plugins.hasPlugin(GroovyPlugin.class)) {
        return ProjectType.GROOVY_LIB;
    } else if (plugins.hasPlugin(KotlinPluginWrapper.class)) {
        return ProjectType.KOTLIN_LIB;
    } else if (plugins.hasPlugin(ScalaPlugin.class)) {
        return ProjectType.SCALA_LIB;
    } else if (plugins.hasPlugin(JavaPlugin.class)) {
        return ProjectType.JAVA_LIB;
    } else {
        return ProjectType.UNKNOWN;
    }
}
项目:okbuck    文件:ProjectUtil.java   
public static ProjectType getType(Project project) {
    PluginContainer plugins = project.getPlugins();
    if (plugins.hasPlugin(AppPlugin.class)) {
        return ProjectType.ANDROID_APP;
    } else if (plugins.hasPlugin(LibraryPlugin.class)) {
        return ProjectType.ANDROID_LIB;
    } else if (plugins.hasPlugin(GroovyPlugin.class)) {
        return ProjectType.GROOVY_LIB;
    } else if (plugins.hasPlugin(KotlinPluginWrapper.class)) {
        return ProjectType.KOTLIN_LIB;
    } else if (plugins.hasPlugin(ScalaPlugin.class)) {
        return ProjectType.SCALA_LIB;
    } else if (plugins.hasPlugin(JavaPlugin.class)) {
        return ProjectType.JAVA_LIB;
    } else {
        return ProjectType.UNKNOWN;
    }
}
项目:checkstyle-addons    文件:TaskCreator.java   
public void establishSonarQubeSourceSet()
{
    final JavaPluginConvention javaConvention = project.getConvention().getPlugin(JavaPluginConvention.class);
    final SourceSetContainer sourceSets = javaConvention.getSourceSets();
    final ConfigurationContainer configs = project.getConfigurations();

    final SourceSet testSourceSet = sourceSets.getByName(SourceSet.TEST_SOURCE_SET_NAME);
    final SourceSet sqSourceSet = sourceSets.create(BuildUtil.SONARQUBE_SOURCE_SET_NAME);

    configs.getByName(testSourceSet.getImplementationConfigurationName()).extendsFrom(
        configs.getByName(sqSourceSet.getImplementationConfigurationName()));
    configs.getByName(testSourceSet.getRuntimeOnlyConfigurationName()).extendsFrom(
        configs.getByName(sqSourceSet.getRuntimeOnlyConfigurationName()));

    final TaskContainer tasks = project.getTasks();
    tasks.getByName(JavaPlugin.COMPILE_TEST_JAVA_TASK_NAME).dependsOn(
        tasks.getByName(sqSourceSet.getClassesTaskName()));

    final FileCollection sqOutputs = sqSourceSet.getOutput().getClassesDirs().plus(
        project.files(sqSourceSet.getOutput().getResourcesDir()));
    testSourceSet.setCompileClasspath(testSourceSet.getCompileClasspath().plus(sqOutputs));
    testSourceSet.setRuntimeClasspath(testSourceSet.getRuntimeClasspath().plus(sqOutputs));
}
项目:checkstyle-addons    文件:TaskCreator.java   
/**
 * Assign some standard tasks and tasks created by third-party plugins to their task groups according to the
 * order of things for Checkstyle Addons.
 */
public void adjustTaskGroupAssignments()
{
    final TaskContainer tasks = project.getTasks();
    tasks.getByName(BasePlugin.ASSEMBLE_TASK_NAME).setGroup(ARTIFACTS_GROUP_NAME);
    tasks.getByName(JavaPlugin.JAR_TASK_NAME).setGroup(ARTIFACTS_GROUP_NAME);

    final SourceSet sqSourceSet = buildUtil.getSourceSet(BuildUtil.SONARQUBE_SOURCE_SET_NAME);
    tasks.getByName(JavaPlugin.COMPILE_JAVA_TASK_NAME).setGroup(BasePlugin.BUILD_GROUP);
    tasks.getByName(sqSourceSet.getCompileJavaTaskName()).setGroup(BasePlugin.BUILD_GROUP);
    tasks.getByName(JavaPlugin.COMPILE_TEST_JAVA_TASK_NAME).setGroup(BasePlugin.BUILD_GROUP);

    for (final FindBugs fbTask : tasks.withType(FindBugs.class)) {
        fbTask.setGroup(LifecycleBasePlugin.VERIFICATION_GROUP);
    }
    for (final Checkstyle csTask : tasks.withType(Checkstyle.class)) {
        csTask.setGroup(LifecycleBasePlugin.VERIFICATION_GROUP);
    }
    for (final Copy task : tasks.withType(Copy.class)) {
        if (task.getName().startsWith("process") && task.getName().endsWith("Resources")) {
            task.setGroup(LifecycleBasePlugin.BUILD_GROUP);
        }
    }
}
项目:checkstyle-addons    文件:DependencyConfigs.java   
private String getDefaultCheckstyleVersion()
{
    String result = null;
    final Configuration apiConfig = project.getConfigurations().getByName(JavaPlugin.API_CONFIGURATION_NAME);
    for (final Dependency dependency : apiConfig.getAllDependencies()) {
        if (DependencyConfig.CHECKSTYLE_GROUPID.equals(dependency.getGroup()) && "checkstyle".equals(
            dependency.getName())) {
            result = dependency.getVersion();
            break;
        }
    }
    if (result == null) {
        throw new GradleException("Checkstyle dependency not found in build script");
    }
    return result;
}
项目:Reer    文件:EarPlugin.java   
private void configureWithNoJavaPluginApplied(final Project project, final EarPluginConvention earPluginConvention) {
    project.getTasks().withType(Ear.class, new Action<Ear>() {
        public void execute(final Ear task) {
            task.from(new Callable<FileCollection>() {
                public FileCollection call() throws Exception {
                    if (project.getPlugins().hasPlugin(JavaPlugin.class)) {
                        return null;
                    } else {
                        return project.fileTree(earPluginConvention.getAppDirName());
                    }
                }
            });
        }
    });
}
项目:Reer    文件:EarPlugin.java   
private void configureWithJavaPluginApplied(final Project project, final EarPluginConvention earPluginConvention, PluginContainer plugins) {
    plugins.withType(JavaPlugin.class, new Action<JavaPlugin>() {
        public void execute(JavaPlugin javaPlugin) {
            final JavaPluginConvention javaPluginConvention = project.getConvention().findPlugin(JavaPluginConvention.class);

            SourceSet sourceSet = javaPluginConvention.getSourceSets().getByName(SourceSet.MAIN_SOURCE_SET_NAME);
            sourceSet.getResources().srcDir(new Callable() {
                public Object call() throws Exception {
                    return earPluginConvention.getAppDirName();
                }
            });
            project.getTasks().withType(Ear.class, new Action<Ear>() {
                public void execute(final Ear task) {
                    task.dependsOn(new Callable<FileCollection>() {
                        public FileCollection call() throws Exception {
                            return javaPluginConvention.getSourceSets().getByName(SourceSet.MAIN_SOURCE_SET_NAME)
                                    .getRuntimeClasspath();
                        }
                    });
                    task.from(new Callable<FileCollection>() {
                        public FileCollection call() throws Exception {
                            return javaPluginConvention.getSourceSets().getByName(SourceSet.MAIN_SOURCE_SET_NAME).getOutput();
                        }
                    });
                }
            });
        }
    });
}
项目:Reer    文件:JavaGradlePluginPlugin.java   
public void apply(Project project) {
    project.getPluginManager().apply(JavaPlugin.class);
    applyDependencies(project);
    GradlePluginDevelopmentExtension extension = createExtension(project);
    configureJarTask(project, extension);
    configureTestKit(project, extension);
    configurePublishing(project);
    configureDescriptorGeneration(project, extension);
    validatePluginDeclarations(project, extension);
    configureTaskPropertiesValidation(project);
}
项目:Reer    文件:WtpComponentFactory.java   
private List<WbDependentModule> getEntriesFromConfigurations(Project project, Set<Configuration> plusConfigurations, Set<Configuration> minusConfigurations, EclipseWtpComponent wtp, String deployPath) {
    List<WbDependentModule> entries = Lists.newArrayList();
    entries.addAll(getEntriesFromProjectDependencies(project, plusConfigurations, minusConfigurations, deployPath));
    // All dependencies should be declared as Eclipse classpath entries by default. However if the project is not a Java
    // project, then as a fallback the dependencies are added to the component descriptor. This is useful for EAR
    // projects which typically are not Java projects.
    if (!project.getPlugins().hasPlugin(JavaPlugin.class)) {
        entries.addAll(getEntriesFromLibraries(plusConfigurations, minusConfigurations, wtp, deployPath));
    }
    return entries;
}
项目:Reer    文件:IdeaPlugin.java   
private DomainObjectCollection<JavaPlugin> configureForJavaPlugin(final Project project) {
    return project.getPlugins().withType(JavaPlugin.class, new Action<JavaPlugin>() {
        @Override
        public void execute(JavaPlugin javaPlugin) {
            configureIdeaModuleForJava(project);
        }
    });
}
项目:gradle-clojure    文件:ClojurePlugin.java   
@Override
public void apply(Project project) {
  project.getPlugins().apply(ClojureBasePlugin.class);
  project.getPlugins().apply(JavaPlugin.class);

  JavaPluginConvention javaConvention = project.getConvention().getPlugin(JavaPluginConvention.class);
  configureTest(project, javaConvention);
  configureDev(project, javaConvention);
}
项目:gradle-java-modules    文件:JigsawPlugin.java   
@Override
public void apply(Project project) {
    LOGGER.debug("Applying JigsawPlugin to " + project.getName());
    project.getPlugins().apply(JavaPlugin.class);
    project.getExtensions().create(EXTENSION_NAME, JavaModule.class);

    configureJavaTasks(project);
}
项目:gradle-java-modules    文件:JigsawPlugin.java   
private void configureCompileJavaTask(final Project project) {
    final JavaCompile compileJava = (JavaCompile) project.getTasks().findByName(JavaPlugin.COMPILE_JAVA_TASK_NAME);
    compileJava.doFirst(new Action<Task>() {
        @Override
        public void execute(Task task) {
            List<String> args = new ArrayList<>();
            args.add("--module-path");
            args.add(compileJava.getClasspath().getAsPath());
            compileJava.getOptions().setCompilerArgs(args);
            compileJava.setClasspath(project.files());
        }
    });
}
项目:jsass-gradle-plugin    文件:JSassJavaPlugin.java   
@Override
public void apply(Project project) {
    jSassBasePlugin = project.getPlugins().apply(JSassBasePlugin.class);

    project.getPlugins().apply(JavaPlugin.class);

    project.getConvention().getPlugin(JavaPluginConvention.class).getSourceSets().all(sourceSet -> {
        String taskName = sourceSet.getTaskName("compile", "Sass");

        Set<File> srcDirs = sourceSet.getResources().getSrcDirs();

        int i = 1;
        for (File srcDir : srcDirs) {
            SassCompile sassCompile = project.getTasks().create(i == 1 ? taskName : taskName + i, SassCompile.class);
            i++;

            sassCompile.setGroup(BasePlugin.BUILD_GROUP);
            sassCompile.setDescription("Compile sass and scss files for the " + sourceSet.getName() + " source set");

            sassCompile.setSourceDir(srcDir);

            Copy processResources = (Copy) project.getTasks().getByName(sourceSet.getProcessResourcesTaskName());

            sassCompile.getConventionMapping().map("destinationDir", () -> {
                        if (jSassBasePlugin.getExtension().isInplace()) {
                            return srcDir;
                        } else {
                            return processResources.getDestinationDir();
                        }
                    });

            processResources.dependsOn(sassCompile);
        }
    });
}