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

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

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

Project.apply介绍

暂无

代码示例

代码示例来源:origin: MinecraftForge/ForgeGradle

public void applyExternalPlugin(String plugin)
{
  project.apply(ImmutableMap.of("plugin", plugin));
}

代码示例来源:origin: gradle.plugin.ninja.miserable/blossom

private void applyPlugin(String plugin) {
  this.project.apply(ImmutableMap.of("plugin", plugin));
}

代码示例来源:origin: gradle.plugin.com.github.opengl-8080/assertjGen-gradle-plugin

public void applyPlugin(String name) {
  Map<String, String> map = new HashMap<>();
  map.put("plugin", name);
  this.project.apply(map);
}

代码示例来源:origin: gradle.plugin.com.intershop.gradle.plugin.azure/azurePlugin

@Override
public void apply(Project project)
{
  Map plugins = new HashMap();
  plugins.put("plugin", "groovy");
  project.apply(plugins);
  AzureExtension azure = project.getExtensions().create(AZURE_EXTENSION, AzureExtension.class, project);
  prepareConfigurations(project);
  prepareSourceSet(project);
  prepareTasks(project, azure);
  // register the default deployment
  addDeployment(project, azure, "azuredeploy", "azuredeploy.json", "azuredeploy.parameters.json",
          "azuredeploy.parameters.json");
}

代码示例来源:origin: MinecraftForge/ForgeGradle

public static Project buildProject(File buildFile, Project parent)
{
  ProjectBuilder builder = ProjectBuilder.builder();
  if (buildFile != null)
  {
    builder = builder.withProjectDir(buildFile.getParentFile()).withName(buildFile.getParentFile().getName());
  }
  else
  {
    builder = builder.withProjectDir(new File("."));
  }
  if (parent != null)
  {
    builder = builder.withParent(parent);
  }
  Project project = builder.build();
  if (buildFile != null)
  {
    project.apply(ImmutableMap.of("from", buildFile.getAbsolutePath()));
  }
  return project;
}

代码示例来源:origin: gradle.plugin.org.hibernate.build.gradle/hibernate-matrix-testing

public MatrixDotGradleProfile(File matrixDotGradleFile, Project project) {
  super( matrixDotGradleFile.getParentFile(), project );
  jdbcDependencies = prepareConfiguration( getName() );
  final ConventionImpl convention = new ConventionImpl( jdbcDependencies, project );
  project.getConvention().getPlugins().put( MATRIX_NODE_CONVENTION_KEY, convention );
  try {
    project.apply( Collections.singletonMap( "from", matrixDotGradleFile ) );
  }
  finally {
    project.getConvention().getPlugins().remove( MATRIX_NODE_CONVENTION_KEY );
  }
}

代码示例来源:origin: gradle.plugin.org.hibernate.build/database-profile-plugin

@SuppressWarnings("WeakerAccess")
public MatrixDotGradleProfile(File matrixDotGradleFile, Project project) {
  super( matrixDotGradleFile.getParentFile(), project );
  jdbcDependencies = prepareConfiguration( getName() );
  final ConventionImpl convention = new ConventionImpl( jdbcDependencies, project );
  project.getConvention().getPlugins().put( MATRIX_NODE_CONVENTION_KEY, convention );
  try {
    project.apply( Collections.singletonMap( "from", matrixDotGradleFile ) );
  }
  finally {
    project.getConvention().getPlugins().remove( MATRIX_NODE_CONVENTION_KEY );
  }
}

代码示例来源:origin: mockito/shipkit

private static void loadConfigFromFile(final Project rootProject, File shipkitFile, ShipkitConfiguration conf) {
  if (!shipkitFile.exists()) {
    // sets some defaults so that they can't be used to run any task (except for bootstrap ones)
    // but also configuration doesn't fail when running Shipkit for the first time
    // and configuration files are not created yet
    conf.getGitHub().setRepository("unspecified");
    conf.getGitHub().setReadOnlyAuthToken("unspecified");
    LOG.lifecycle("  Configuration file '{}' does not exist. '{}' task can be used to bootstrap Shipkit.\n" +
      "  Getting Started Guide: https://github.com/mockito/shipkit/blob/master/docs/getting-started.md", shipkitFile.getName(), InitPlugin.INIT_SHIPKIT_TASK);
  } else {
    // apply configuration properties from config file
    rootProject.apply(new Action<ObjectConfigurationAction>() {
      @Override
      public void execute(ObjectConfigurationAction action) {
        action.from(getShipkitFile(rootProject));
      }
    });
  }
}

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

private static void loadConfigFromFile(final Project rootProject, File shipkitFile, ShipkitConfiguration conf) {
  if (!shipkitFile.exists()) {
    // sets some defaults so that they can't be used to run any task (except for bootstrap ones)
    // but also configuration doesn't fail when running Shipkit for the first time
    // and configuration files are not created yet
    conf.getGitHub().setRepository("unspecified");
    conf.getGitHub().setReadOnlyAuthToken("unspecified");
    LOG.lifecycle("  Configuration file '{}' does not exist. '{}' task can be used to bootstrap Shipkit.\n" +
      "  Getting Started Guide: https://github.com/mockito/shipkit/blob/master/docs/getting-started.md", shipkitFile.getName(), InitPlugin.INIT_SHIPKIT_TASK);
  } else {
    // apply configuration properties from config file
    rootProject.apply(new Action<ObjectConfigurationAction>() {
      @Override
      public void execute(ObjectConfigurationAction action) {
        action.from(getShipkitFile(rootProject));
      }
    });
  }
}

代码示例来源:origin: gradle.plugin.com.glonk.gradle/gradle-eclipse-checkstyle

@Override
public void apply(Project project) {
 project.apply(dependencies(ECLIPSE_TASK));
 project.apply(dependencies(CHECKSTYLE_TASK));
 project.getExtensions().create(ECLIPSE_CHECKSTYLE, EclipseCheckstyleExtension.class);
 
 // Ensure that the project has the checkstyle nature / builder applied
 EclipseModel eclipseModel = project.getExtensions().getByType(EclipseModel.class);
 EclipseProject eclipseProject = eclipseModel.getProject();
 eclipseProject.natures(CHECKSTYLE_NATURE, GRADLE_NATURE);

 // Explicitly set the Java builder before Checkstyle so they don't get added
 // in an arbitrary order.
 eclipseProject.buildCommand(JAVA_BUILDER);
 eclipseProject.buildCommand(CHECKSTYLE_BUILDER);
 
 // Wire up our actions to the relevant eclipse tasks..
 Task task = project.getTasks().findByName(ECLIPSE_TASK);
 if (task != null) {
  task.doLast(EclipseCheckstyle.generateAction());
 }
 
 task = project.getTasks().findByName(CLEAN_ECLIPSE_TASK);
 if (task != null) {
  task.doLast(EclipseCheckstyle.cleanAction());
 }
}

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

private void loadConfigFromFile(Project rootProject, File configFile) {
  if (!configFile.exists()) {
    // sets some defaults so that they can't be used to run any task (except for bootstrap ones)
    // but also configuration doesn't fail when running Shipkit for the first time
    // and configuration files are not created yet
    configuration.getGitHub().setUrl("https://github.com");
    configuration.getGitHub().setApiUrl("https://api.github.com");
    configuration.getGitHub().setRepository("mockito/shipkit");
    configuration.getGitHub().setReadOnlyAuthToken("e7fe8fcfd6ffedac384c8c4c71b2a48e646ed1ab");
  } else {
    // apply configuration properties from config file
    rootProject.apply(new Action<ObjectConfigurationAction>() {
      @Override
      public void execute(ObjectConfigurationAction objectConfigurationAction) {
        objectConfigurationAction.from(CONFIG_FILE_RELATIVE_PATH);
      }
    });
  }
}

代码示例来源:origin: michel-kraemer/gradle-download-task

/**
 * Makes a Gradle project and creates a download task
 * @return the unconfigured download task
 */
protected Download makeProjectAndTask() {
  Project parent = ProjectBuilder.builder().withProjectDir(parentDir).build();
  Project project = ProjectBuilder.builder().withParent(parent).withProjectDir(projectDir).build();
  
  Map<String, Object> applyParams = new HashMap<String, Object>();
  applyParams.put("plugin", "de.undercouch.download");
  project.apply(applyParams);
  
  Map<String, Object> taskParams = new HashMap<String, Object>();
  taskParams.put("type", Download.class);
  Download t = (Download)project.task(taskParams, "downloadFile");
  return t;
}

代码示例来源:origin: MinecraftForge/ForgeGradle

@Before
public void setupProject()
{
  this.testProject = ProjectBuilder.builder().build();
  assertNotNull(this.testProject);
  this.testProject.apply(ImmutableMap.of("plugin", ForgePlugin.class));
  this.ext = this.testProject.getExtensions().findByType(ForgeExtension.class);   // unlike getByType(), does not throw exception
  assertNotNull(this.ext);
  this.ext.setSuppressVersionTest(true);
}

代码示例来源:origin: MinecraftForge/ForgeGradle

@Before
public void setupProject()
{
  this.testProject = ProjectBuilder.builder().build();
  assertNotNull(this.testProject);
  this.testProject.apply(ImmutableMap.of("plugin", LiteloaderPlugin.class));
  this.ext = this.testProject.getExtensions().findByType(LiteloaderExtension.class);   // unlike getByType(), does not throw exception
  assertNotNull(this.ext);
  this.ext.setSuppressVersionTest(true);
}

代码示例来源:origin: gradle.plugin.edu.wpi.first/gradle-cpp-vscode

subproject.apply(config -> {
 config.plugin(GradleVsCode.class);
});

代码示例来源:origin: MinecraftForge/ForgeGradle

@Before
public void setupProject()
{
  this.testProject = ProjectBuilder.builder().build();
  assertNotNull(this.testProject);
  this.testProject.apply(ImmutableMap.of("plugin", ClientTweaker.class));
  this.ext = this.testProject.getExtensions().findByType(TweakerExtension.class);   // unlike getByType(), does not throw exception
  assertNotNull(this.ext);
  this.ext.setSuppressVersionTest(true);
  
  this.ext.setTweakClass("some.thing.other"); // to ignore any issues regarding this.
}
private static final String VERSION_17 = "1.7.10";

代码示例来源:origin: gradle.plugin.org.amdatu.blueprint/org.amdatu.blueprint.gradle

@Override
public void apply(Object receiver) {
  if (receiver instanceof Settings) {
    Settings settings = ((Settings) receiver);
    settings.getGradle().projectsEvaluated(action -> {
      settings.getGradle().getRootProject().apply(a -> a.plugin(AmdatuBlueprintPlugin.class));
    });
  } else if (receiver instanceof Project) {
    Project project = (Project) receiver;
    Workspace bndWorkspace = (Workspace) project.getProperties().get("bndWorkspace");
    if (bndWorkspace == null) {
      throw new GradleException("Bnd workspace not available!");
    }
    project.subprojects(subProject -> subProject
        .fileTree(subProject.getProjectDir(), files -> files.include("*.bndrun"))
        .forEach(bndrun -> addDockerTasks(bndWorkspace, subProject, bndrun)));
    createRunAllTask(project, "docker", DockerTask.class);
    createRunAllTask(project, "dockerPush", DockerPushTask.class);
  }
}

代码示例来源:origin: gradle.plugin.com.github.jishida.gradle/gradle-shell-script-plugin

static Msys2CacheInfo getCacheInfo(final Project project) {
    final Msys2Spec msys2 = getMsys2Extension(project);
    final Project cacheProject = msys2 == null ? project.getRootProject() : msys2.getCacheProject();
    if (getMsys2Extension(cacheProject) == null) {
      Map<String, Object> options = new MapBuilder<String, Object>(HashMap.class)
          .put("plugin", ShellScriptPlugin.class)
          .build();
      cacheProject.apply(options);
      getShellScriptExtension(cacheProject).getMsys2().setCacheProject(cacheProject);
    }
    return cacheProject == project ? null : getShellScriptExtension(cacheProject).configure().getMsys2().getCache();
  }
}

代码示例来源:origin: gradle.plugin.org.openstreetmap.josm/gradle-josm-plugin

project.apply(conf -> conf.plugin(JavaPlugin.class));

相关文章