org.gradle.api.Project.getPlugins()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(7.6k)|赞(0)|评价(0)|浏览(185)

本文整理了Java中org.gradle.api.Project.getPlugins()方法的一些代码示例,展示了Project.getPlugins()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Project.getPlugins()方法的具体详情如下:
包路径:org.gradle.api.Project
类名称:Project
方法名:getPlugins

Project.getPlugins介绍

暂无

代码示例

代码示例来源:origin: uber/okbuck

public static OkBuckGradlePlugin getPlugin(Project project) {
 return project.getRootProject().getPlugins().getPlugin(OkBuckGradlePlugin.class);
}

代码示例来源:origin: uber/okbuck

public boolean hasApplication() {
 return getProject().getPlugins().hasPlugin(ApplicationPlugin.class);
}

代码示例来源:origin: uber/okbuck

public JvmTarget(
  Project project, String name, String aptConfigurationName, String testAptConfigurationName) {
 super(project, name);
 this.aptConfigurationName = aptConfigurationName;
 this.testAptConfigurationName = testAptConfigurationName;
 sourceSets = getProject().getConvention().getPlugin(JavaPluginConvention.class).getSourceSets();
 isKotlin =
   project.getPlugins().stream().anyMatch(plugin -> plugin instanceof KotlinBasePluginWrapper);
 Optional<Task> compileTask =
   project.getTasks().stream().filter(it -> it instanceof AbstractCompile).findFirst();
 if (compileTask.isPresent()) {
  fakeCompile = (AbstractCompile) compileTask.get();
 } else {
  fakeCompile = null;
 }
}

代码示例来源:origin: uber/okbuck

if (getProject().getPlugins().hasPlugin(KotlinManager.KOTLIN_ALLOPEN_MODULE)) {
 AllOpenKotlinGradleSubplugin subplugin = getAllOpenKotlinGradleSubplugin();

代码示例来源:origin: hibernate/hibernate-orm

public void apply(Project project) {
  project.getPlugins().apply( "java" );
  final HibernateExtension hibernateExtension = new HibernateExtension( project );
  project.getLogger().debug( "Adding Hibernate extensions to the build [{}]", project.getName() );
  project.getExtensions().add( "hibernate", hibernateExtension );
  project.afterEvaluate(
      new Action<Project>() {
        @Override
        public void execute(Project project) {
          if ( hibernateExtension.enhance != null ) {
            applyEnhancement( project, hibernateExtension );
          }
        }
      }
  );
}

代码示例来源:origin: uber/okbuck

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;
 }
}

代码示例来源:origin: alipay/sofa-boot

private void registerPluginActions(Project project, Configuration bootArchives) {
  SinglePublishedArtifact singlePublishedArtifact = new SinglePublishedArtifact(
      bootArchives.getArtifacts());
  List<PluginApplicationAction> actions = Arrays.asList(
      new JavaPluginAction(singlePublishedArtifact),
      new WarPluginAction(singlePublishedArtifact),
      new MavenPluginAction(bootArchives.getUploadTaskName()),
      new SofaDependencyManagementPluginAction(), new ApplicationPluginAction(),
      new KotlinPluginAction());
  for (PluginApplicationAction action : actions) {
    Class<? extends Plugin<? extends Project>> pluginClass = action
        .getPluginClass();
    if (pluginClass != null) {
      project.getPlugins().withType(pluginClass,
          (plugin) -> action.execute(project));
    }
  }
}

代码示例来源:origin: uber/okbuck

generateR2 = project.getPlugins().hasPlugin("com.jakewharton.butterknife");
isKotlinAndroid = project.getPlugins().hasPlugin(KotlinAndroidPluginWrapper.class);
isKapt = project.getPlugins().hasPlugin(KOTLIN_KAPT_PLUGIN);
hasKotlinAndroidExtensions = project.getPlugins().hasPlugin(KOTLIN_ANDROID_EXTENSIONS_MODULE);

代码示例来源:origin: diffplug/spotless

@Override
public void apply(Project project) {
  // make sure there's a `clean` task
  project.getPlugins().apply(BasePlugin.class);
  // setup the extension
  spotlessExtension = project.getExtensions().create(EXTENSION, SpotlessExtension.class, project);
  // after the project has been evaluated, configure the check and format tasks per source set
  project.afterEvaluate(this::createTasks);
}

代码示例来源:origin: diffplug/spotless

/** Creates a Project which has had the SpotlessExtension setup. */
private static Project createProject(Consumer<SpotlessExtension> test) throws Exception {
  Project project = ProjectBuilder.builder().withProjectDir(new File("").getAbsoluteFile()).build();
  // create the spotless plugin
  SpotlessPlugin plugin = project.getPlugins().apply(SpotlessPlugin.class);
  // setup the plugin
  test.accept(plugin.getExtension());
  plugin.createTasks(project);
  // return the configured plugin
  return project;
}

代码示例来源:origin: diffplug/spotless

if (target == null) {
  JavaPluginConvention convention = getProject().getConvention().getPlugin(JavaPluginConvention.class);
  if (convention == null || !getProject().getPlugins().hasPlugin(GroovyBasePlugin.class)) {
    throw new GradleException("You must apply the groovy plugin before the spotless plugin if you are using the groovy extension.");

代码示例来源:origin: purplejs/purplejs

private void addPlugins()
{
  this.project.getPlugins().apply( JavaPlugin.class );
  this.project.getPlugins().apply( ApplicationPlugin.class );
}

代码示例来源:origin: org.shipkit/shipkit

@Override
  public void apply(Project project) {
    project.getPlugins().apply(GitHubContributorsPlugin.class);
    project.getPlugins().apply(GitHubPomContributorsPlugin.class);
  }
}

代码示例来源:origin: org.shipkit/shipkit

@Override
  public void apply(Project project) {
    project.getPlugins().apply(GitHubContributorsPlugin.class);
    project.getPlugins().apply(PomContributorsPlugin.class);
  }
}

代码示例来源:origin: org.shipkit/shipkit

@Override
  public void apply(Project project) {
    project.getPlugins().apply(LocalSnapshotPlugin.class);
    project.getPlugins().apply("maven");

    Task snapshotTask = project.getTasks().getByName(LocalSnapshotPlugin.SNAPSHOT_TASK);
    snapshotTask.dependsOn("install");
  }
}

代码示例来源:origin: linkedin/pygradle

@Override
public void apply(Project target) {
  this.project = target;
  target.getPlugins().apply(PythonPlugin.class);
  settings = project.getExtensions().getByType(PythonExtension.class);
  applyTo(target);
}

代码示例来源:origin: org.shipkit/shipkit

@Override
public void apply(Project project) {
  ProjectUtil.requireRootProject(project, this.getClass(), "This is needed so that we don't invoke git commands multiple times, per each submodule.");
  identifyTask = TaskMaker.task(project, IDENTIFY_GIT_ORIGIN_TASK, IdentifyGitOriginRepoTask.class, new Action<IdentifyGitOriginRepoTask>() {
    public void execute(IdentifyGitOriginRepoTask t) {
      t.setDescription("Identifies current git origin repo.");
    }
  });
  //Due to gnarly dependencies between plugins and tasks, we really need to apply this plugin after we declared the task
  //Trust me, it's all good :-)
  project.getPlugins().apply(ShipkitConfigurationPlugin.class);
}

代码示例来源:origin: linkedin/pygradle

@Override
public void applyTo(Project project) {
  project.getPlugins().apply(PythonPexDistributionPlugin.class);
  ExtensionUtils.maybeCreateCliExtension(project);
  GenerateCompletionsTask completionsTask = project.getTasks().create(TASK_GENERATE_COMPLETIONS, GenerateCompletionsTask.class);
  completionsTask.dependsOn(project.getTasks().getByName(StandardTextValues.TASK_INSTALL_PROJECT.getValue()));
  project.getTasks().getByName(PythonPexDistributionPlugin.TASK_BUILD_PEX).dependsOn(project.getTasks().getByName(TASK_GENERATE_COMPLETIONS));
}

代码示例来源:origin: joinfaces/joinfaces

@Test
void apply_beforeJava() {
  this.project.getPlugins().apply(ClasspathScanPlugin.class);
  this.project.getPlugins().apply(JavaPlugin.class);
  checkForGeneratedTasks();
}

代码示例来源:origin: joinfaces/joinfaces

@Override
public void apply(Project project) {
  this.project = project;
  project.getPlugins().withType(JavaPlugin.class, javaPlugin ->
      project.getConvention()
          .getPlugin(JavaPluginConvention.class)
          .getSourceSets()
          .all(this::configureClasspathScan)
  );
}

相关文章