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

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

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

Project.getArtifacts介绍

暂无

代码示例

代码示例来源:origin: com.android.tools.build/gradle-core

public static void publish(
    Project project,
    String publishConfigName,
    File file,
    String builtBy,
    String type) {
  project.getArtifacts().add(
      publishConfigName,
      file, new Closure(project /*doesnt matter*/) {
        public Object doCall(ConfigurablePublishArtifact artifact) {
          artifact.setType(type);
          artifact.builtBy(project.getTasks().getByName(builtBy));
          return null;
        }
      });
}

代码示例来源:origin: com.amazon.device.tools.build/gradle-core

@Override
public void execute(Task packageTask) {
  project.getArtifacts().add("default",
      new ApkPublishArtifact(projectBaseName,
          null,
          (FileSupplier) packageTask));
}

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

/**
   * Create a Python source distribution.
   */
  @Override
  public void applyTo(final Project project) {

    SourceDistTask sdistPackageTask = project.getTasks().create(TASK_PACKAGE_SDIST, SourceDistTask.class,
      task -> task.dependsOn(project.getTasks().getByName(StandardTextValues.TASK_INSTALL_PROJECT.getValue())));

    LinkedHashMap<String, Object> sdistArtifactInfo = new LinkedHashMap<>(5);
    sdistArtifactInfo.put("name", project.getName());
    sdistArtifactInfo.put("type", "tgz");
    sdistArtifactInfo.put("extension", "tar.gz");
    sdistArtifactInfo.put("file", sdistPackageTask.getSdistOutput());
    sdistArtifactInfo.put("builtBy", project.getTasks().getByName(TASK_PACKAGE_SDIST));

    project.getArtifacts().add(StandardTextValues.CONFIGURATION_DEFAULT.getValue(), sdistArtifactInfo);
  }
}

代码示例来源:origin: gradle.plugin.com.linkedin.pygradle/pygradle-plugin

/**
   * Create a Python source distribution.
   */
  @Override
  public void applyTo(final Project project) {

    SourceDistTask sdistPackageTask = project.getTasks().create(TASK_PACKAGE_SDIST, SourceDistTask.class,
      task -> task.dependsOn(project.getTasks().getByName(StandardTextValues.TASK_INSTALL_PROJECT.getValue())));

    LinkedHashMap<String, Object> sdistArtifactInfo = new LinkedHashMap<>(5);
    sdistArtifactInfo.put("name", project.getName());
    sdistArtifactInfo.put("type", "tgz");
    sdistArtifactInfo.put("extension", "tar.gz");
    sdistArtifactInfo.put("file", sdistPackageTask.getSdistOutput());
    sdistArtifactInfo.put("builtBy", project.getTasks().getByName(TASK_PACKAGE_SDIST));

    project.getArtifacts().add(StandardTextValues.CONFIGURATION_DEFAULT.getValue(), sdistArtifactInfo);
  }
}

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

@Override
public void applyTo(final Project project) {
  // XXX: This needs to be adjusted to work with a build matrix one day. Until
  // that is ready, we always assume pure Python 2.7 on Linux.
  String version = project.getVersion().toString().replace("-", "_");
  String name = project.getName().replace("-", "_");
  final File wheelArtifact = new File(project.getProjectDir(), "/dist/" + name + "-" + version + "-py2-none-any.whl");
  /*
   * Create a Python wheel distribution.
   */
  project.getTasks().create(TASK_PACKAGE_WHEEL, task -> {
    task.dependsOn(project.getTasks().getByName(StandardTextValues.TASK_INSTALL_PROJECT.getValue()));
    task.getOutputs().file(wheelArtifact);
    task.doLast(it -> project.exec(execSpec -> {
      execSpec.environment(settings.pythonEnvironmentDistgradle);
      execSpec.commandLine(settings.getDetails().getVirtualEnvInterpreter(), "setup.py", "bdist_wheel");
    }));
  });
  LinkedHashMap<String, Object> wheelArtifactInfo = new LinkedHashMap<>(5);
  wheelArtifactInfo.put("name", name);
  wheelArtifactInfo.put("classifier", "py2-none-any");
  wheelArtifactInfo.put("type", "whl");
  wheelArtifactInfo.put("file", wheelArtifact);
  wheelArtifactInfo.put("builtBy", project.getTasks().getByName(TASK_PACKAGE_WHEEL));
  if (!version.contains("SNAPSHOT")) {
    project.getArtifacts().add(StandardTextValues.CONFIGURATION_WHEEL.getValue(), wheelArtifactInfo);
  }
}

代码示例来源:origin: gradle.plugin.com.linkedin.pygradle/pygradle-plugin

@Override
public void applyTo(final Project project) {
  // XXX: This needs to be adjusted to work with a build matrix one day. Until
  // that is ready, we always assume pure Python 2.7 on Linux.
  String version = project.getVersion().toString().replace("-", "_");
  String name = project.getName().replace("-", "_");
  final File wheelArtifact = new File(project.getProjectDir(), "/dist/" + name + "-" + version + "-py2-none-any.whl");
  /*
   * Create a Python wheel distribution.
   */
  project.getTasks().create(TASK_PACKAGE_WHEEL, task -> {
    task.dependsOn(project.getTasks().getByName(StandardTextValues.TASK_INSTALL_PROJECT.getValue()));
    task.getOutputs().file(wheelArtifact);
    task.doLast(it -> project.exec(execSpec -> {
      execSpec.environment(settings.pythonEnvironmentDistgradle);
      execSpec.commandLine(settings.getDetails().getVirtualEnvInterpreter(), "setup.py", "bdist_wheel");
    }));
  });
  LinkedHashMap<String, Object> wheelArtifactInfo = new LinkedHashMap<>(5);
  wheelArtifactInfo.put("name", name);
  wheelArtifactInfo.put("classifier", "py2-none-any");
  wheelArtifactInfo.put("type", "whl");
  wheelArtifactInfo.put("file", wheelArtifact);
  wheelArtifactInfo.put("builtBy", project.getTasks().getByName(TASK_PACKAGE_WHEEL));
  if (!version.contains("SNAPSHOT")) {
    project.getArtifacts().add(StandardTextValues.CONFIGURATION_WHEEL.getValue(), wheelArtifactInfo);
  }
}

代码示例来源:origin: com.amazon.device.tools.build/gradle-core

@Override
public void execute(Task packageTask) {
  project.getArtifacts().add(
      variantData.getVariantDependency().getPublishConfiguration().getName(),
      new ApkPublishArtifact(
          projectBaseName,
          null,
          (FileSupplier) packageTask));
}

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

@Override
  public void apply(final Project project) {
    project.getPlugins().apply("java");

    final CopySpec license = project.copySpec(copy -> copy.from(project.getRootDir()).include("LICENSE"));

    ((Jar) project.getTasks().getByName("jar")).with(license);

    final Jar sourcesJar = project.getTasks().create(SOURCES_JAR_TASK, Jar.class, jar -> {
      jar.from(JavaPluginUtil.getMainSourceSet(project).getAllSource());
      jar.setClassifier("sources");
      jar.with(license);
    });

    final Task javadocJar = project.getTasks().create(JAVADOC_JAR_TASK, Jar.class, jar -> {
      jar.from(project.getTasks().getByName("javadoc"));
      jar.setClassifier("javadoc");
      jar.with(license);
    });

    project.getArtifacts().add("archives", sourcesJar);
    project.getArtifacts().add("archives", javadocJar);
  }
}

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

@Override
  public void apply(final Project project) {
    project.getPlugins().apply("java");

    final CopySpec license = project.copySpec(copy -> copy.from(project.getRootDir()).include("LICENSE"));

    ((Jar) project.getTasks().getByName("jar")).with(license);

    final Jar sourcesJar = project.getTasks().create(SOURCES_JAR_TASK, Jar.class, jar -> {
      jar.from(JavaPluginUtil.getMainSourceSet(project).getAllSource());
      jar.setClassifier("sources");
      jar.with(license);
    });

    final Task javadocJar = project.getTasks().create(JAVADOC_JAR_TASK, Jar.class, jar -> {
      jar.from(project.getTasks().getByName("javadoc"));
      jar.setClassifier("javadoc");
      jar.with(license);
    });

    project.getArtifacts().add("archives", sourcesJar);
    project.getArtifacts().add("archives", javadocJar);
  }
}

代码示例来源:origin: io.freefair.gradle/war-plugin

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

代码示例来源:origin: gradle.plugin.com.github.skazzyy.gradle.plugins/sources-gradle-plugin

protected void createSourcesJars(final Project project) {
  final JavaPluginConvention javaPluginConvention = project.getConvention().getPlugin(JavaPluginConvention.class);
  Task sourcesJar = project.getTasks().create("sourcesJar", Jar.class, jar -> {
    jar.setDescription("Creates a jar with the sources");
    jar.setClassifier("sources");
    jar.from(javaPluginConvention.getSourceSets().getByName("main").getAllSource());
  });
  Task javadocJar = project.getTasks().create("javadocJar", Jar.class, jar -> {
    jar.setDescription("Creates a javadoc jar");
    jar.setClassifier("javadoc");
    Javadoc javadoc = (Javadoc) project.getTasks().getByName(JavaPlugin.JAVADOC_TASK_NAME);
    jar.from(javadoc.getDestinationDir());
    jar.dependsOn(javadoc);
  });
  Task testsJar = project.getTasks().create("testsJar", Jar.class, jar -> {
    jar.setDescription("Creates a jar containing all the source and classes for the tests");
    jar.setClassifier("tests");
    SourceSet test = javaPluginConvention.getSourceSets().getByName("test");
    jar.from(test.getAllJava());
    jar.from(test.getOutput());
  });
  project.getArtifacts().add(Dependency.ARCHIVES_CONFIGURATION, sourcesJar);
  project.getArtifacts().add(Dependency.ARCHIVES_CONFIGURATION, javadocJar);
  project.getArtifacts().add(Dependency.ARCHIVES_CONFIGURATION, testsJar);
}

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

project.getArtifacts().add(CONFIGURATION_PYDOCS.getValue(), packageDocsTask);
project.getArtifacts().add(CONFIGURATION_PYDOCS.getValue(), packageJsonDocsTask);

代码示例来源:origin: gradle.plugin.com.linkedin.pygradle/pygradle-plugin

project.getArtifacts().add(CONFIGURATION_PYDOCS.getValue(), packageDocsTask);
project.getArtifacts().add(CONFIGURATION_PYDOCS.getValue(), packageJsonDocsTask);

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

project.getArtifacts().add("archives", sourcesJar);
project.getArtifacts().add("archives", javadocJar);

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

packageDeployable.dependsOn(project.getTasks().getByName(TASK_BUILD_PEX));
project.getArtifacts().add(StandardTextValues.CONFIGURATION_DEFAULT.getValue(), packageDeployable);

代码示例来源:origin: gradle.plugin.com.linkedin.pygradle/pygradle-plugin

packageDeployable.dependsOn(project.getTasks().getByName(TASK_BUILD_PEX));
project.getArtifacts().add(StandardTextValues.CONFIGURATION_DEFAULT.getValue(), packageDeployable);

代码示例来源:origin: io.freefair.gradle/android-gradle-plugins

@Override
  protected void withAndroid(TestedExtension extension) {
    super.withAndroid(extension);

    getAndroidVariants().all(variant -> {
      Jar sourcesJarTask = getProject().getTasks().create("sources" + capitalize((CharSequence) variant.getName()) + "Jar", Jar.class, jar -> {
        jar.setDescription("Generate the sources jar for the " + variant.getName() + " variant");
        jar.setGroup("jar");

        jar.setClassifier("sources");
        jar.setAppendix(variant.getName());
        jar.from(variant.getJavaCompiler().property("source"));
      });

      allSourcesJarTask.dependsOn(sourcesJarTask);

      if (publishVariant(variant)) {
        getProject().getArtifacts().add(Dependency.ARCHIVES_CONFIGURATION, sourcesJarTask);
      }
    });
  }
}

代码示例来源:origin: palantir/sls-packaging

project.getArtifacts().add(SLS_CONFIGURATION_NAME, configTar);

代码示例来源:origin: io.freefair.gradle/android-gradle-plugins

@Override
  protected void withAndroid(TestedExtension extension) {
    super.withAndroid(extension);

    getAndroidVariants().all(variant -> {

      AndroidJavadocPlugin androidJavadocPlugin = getProject().getPlugins().findPlugin(AndroidJavadocPlugin.class);
      Javadoc javadocTask = androidJavadocPlugin.getJavadocTask(getProject(), variant);

      Jar javadocJarTask = getProject().getTasks().create("javadoc" + capitalize((CharSequence) variant.getName()) + "Jar", Jar.class, jar -> {
        jar.dependsOn(javadocTask);

        jar.setDescription("Generate the javadoc jar for the " + variant.getName() + " variant");
        jar.setGroup("jar");

        jar.setAppendix(variant.getName());
        jar.setClassifier("javadoc");
        jar.from(javadocTask.getDestinationDir());
      });

      allJavadocJarTask.dependsOn(javadocJarTask);

      if (publishVariant(variant)) {
        getProject().getArtifacts().add(Dependency.ARCHIVES_CONFIGURATION, javadocJarTask);
      }
    });
  }
}

代码示例来源:origin: com.android.tools.build/gradle-core

/**
 * Adds the manifest artifact for the variant.
 *
 * <p>This artifact is added if the publishNonDefault option is {@code true}. See variant
 * dependencies evaluation in {@link VariantDependencies} for more details.
 */
private void addManifestArtifact(
    @NonNull TaskFactory tasks,
    @NonNull BaseVariantData<? extends BaseVariantOutputData> variantData) {
  if (variantData.getVariantDependency().getManifestConfiguration() != null) {
    ManifestProcessorTask mergeManifestsTask =
        variantData.getMainOutput().getScope().getManifestProcessorTask().get(tasks);
    project.getArtifacts().add(
        variantData.getVariantDependency().getManifestConfiguration().getName(),
        AndroidArtifacts.buildManifestArtifact(globalScope.getProjectBaseName(),
            new FileSupplier() {
              @NonNull
              @Override
              public Task getTask() {
                return mergeManifestsTask;
              }
              @Override
              public File get() {
                return mergeManifestsTask.getManifestOutputFile();
              }
            }));
  }
}

相关文章