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

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

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

Project.setVersion介绍

暂无

代码示例

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

@Override
  public void execute(Project project) {
    project.setVersion(version);
  }
});

代码示例来源:origin: gradle.plugin.com.github.mazzeb/auto-version

private void updateVersion(Project project, Version version) {
  project.setVersion(version);
  versionFile.saveToFile(version);
}

代码示例来源:origin: gradle.plugin.me.bhop.autoversion/gradle-plugin

public void projectId(String pid) {
  this.pid = pid;
  try {
    StringBuilder result = new StringBuilder();
    URL url = new URL(getBaseUrl() + "projects/" + pid + "/version");
    HttpURLConnection conn = (HttpURLConnection) url.openConnection();
    conn.setRequestMethod("GET");
    try (InputStreamReader isr = new InputStreamReader(conn.getInputStream())) {
      try (BufferedReader reader = new BufferedReader(isr)) {
        String line;
        while((line = reader.readLine()) != null)
          result.append(line);
      }
    }
    System.out.println("Applying project version... (" + pid + ") (" + result.toString() + ")");
    project.setVersion(result.toString());
  } catch (IOException e) {
    throw new RuntimeException(e);
  }
}

代码示例来源:origin: gradle.plugin.me.bhop.autoversion/gradle-plugin

@TaskAction
  public void applyVersion() {
    try {
      AutoVersionExtension ext = getProject().getExtensions().getByType(AutoVersionExtension.class);

      StringBuilder result = new StringBuilder();
      URL url = new URL(ext.getBaseUrl() + "projects/" + ext.getProjectId() + "/version");
      HttpURLConnection conn = (HttpURLConnection) url.openConnection();
      conn.setRequestMethod("GET");
      try (InputStreamReader isr = new InputStreamReader(conn.getInputStream())) {
        try (BufferedReader reader = new BufferedReader(isr)) {
          String line;
          while((line = reader.readLine()) != null)
            result.append(line);
        }
      }
      System.out.println("Applying project version... (" + ext.getProjectId() + ") (" + result.toString() + ")");
      getProject().setVersion(result.toString());
    } catch (Exception e) {
      throw new RuntimeException(e);
    }
  }
}

代码示例来源:origin: gradle.plugin.com.github.mazzeb/auto-version

private void afterEvaluate(Project project) {
    logger.debug("opening version file: " + autoVersionConfig.getVersionFile());
    versionFile = openVersionFile(autoVersionConfig.getVersionFile());
    Object existingVersion = project.getVersion();
    logger.debug(format("legacy project version: '%s'", existingVersion.toString()));
    if (UNSPECIFIED.equals(existingVersion)) {
      try {
        version = versionFile.readFromFile();
      } catch (GradleException e) {
        logger.info(format("Could not read version from %s", autoVersionConfig.getVersionFile()));
      }
      project.setVersion(version);
    } else {
      throw new GradleException("please specify version in version.gradle file and remove it from build.gradle");
    }
    logger.debug("applied project version: " + project.getVersion());

  }
}

代码示例来源:origin: gradle.plugin.com.github.krs.xrepo-gradle-plugin/xrepo-gradle-plugin

@Override
protected void execute(final XRepoConfiguration config, final Project project) {
  if (project.getVersion() != null) {
    project.setVersion(project.getVersion().toString() + config.getVersionSuffix());
    info(project, "Setting version to {}", project.getVersion());
  } else {
    warn(project, "Version is not set, cannot add branch suffix");
  }
}

代码示例来源:origin: gradle.plugin.io.apioo.versioning/versioning-plugin

tagAndSignTask.getVersion().set(version);
pushTagToOriginTask.getVersion().set(version);
project.setVersion(version);

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

public void apply(final Project project) {
  LocalSnapshotPlugin snapshotPlugin = project.getPlugins().apply(LocalSnapshotPlugin.class);
  final File versionFile = project.file(VERSION_FILE_NAME);
  final VersionInfo versionInfo = new VersionInfoFactory().createVersionInfo(versionFile,
    project.getVersion(), snapshotPlugin.isSnapshot());
  project.getExtensions().add(VersionInfo.class.getName(), versionInfo);
  final String version = versionInfo.getVersion();
  project.allprojects(project1 -> project1.setVersion(version));
  TaskMaker.task(project, BUMP_VERSION_FILE_TASK, BumpVersionFileTask.class, t -> {
    t.setDescription("Increments version number in " + versionFile.getName());
    t.setVersionFile(versionFile);
    String versionChangeMessage = formatVersionInformationInCommitMessage(version, versionInfo.getPreviousVersion());
    GitPlugin.registerChangesForCommitIfApplied(singletonList(versionFile), versionChangeMessage, t);
  });
}

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

public void apply(final Project project) {
  LocalSnapshotPlugin snapshotPlugin = project.getPlugins().apply(LocalSnapshotPlugin.class);
  final File versionFile = project.file(VERSION_FILE_NAME);
  final VersionInfo versionInfo = new VersionInfoFactory().createVersionInfo(versionFile,
    project.getVersion(), snapshotPlugin.isSnapshot());
  project.getExtensions().add(VersionInfo.class.getName(), versionInfo);
  final String version = versionInfo.getVersion();
  project.allprojects(project1 -> project1.setVersion(version));
  TaskMaker.task(project, BUMP_VERSION_FILE_TASK, BumpVersionFileTask.class, t -> {
    t.setDescription("Increments version number in " + versionFile.getName());
    t.setVersionFile(versionFile);
    String versionChangeMessage = formatVersionInformationInCommitMessage(version, versionInfo.getPreviousVersion());
    GitPlugin.registerChangesForCommitIfApplied(singletonList(versionFile), versionChangeMessage, t);
  });
}

代码示例来源:origin: EvidentSolutions/gradle-beanstalk-plugin

@Test
public void versionShouldIncludePrefix() {
  Project project = ProjectBuilder.builder().build();
  project.setVersion("version");
  Map<String, Object> params = new HashMap<>();
  params.put("type", TestDeployTask.class);
  TestDeployTask task = (TestDeployTask) project.task(params, "tasktest");
  BeanstalkDeployment deployment = new BeanstalkDeployment("tasktest");
  deployment.setVersionPrefix("test-");
  task.setDeployment(deployment);
  assertTrue(task.findVersionLabel().matches("test-version"));
}

代码示例来源:origin: com.jdroidtools/jdroid-gradle-commons-plugin

String newLineContent = versionMatcher.replaceFirst("version = '" + version.getBaseVersion() + "'");
  lines.add(newLineContent);
  getProject().setVersion(version);
  versionFound = true;
} else {

代码示例来源:origin: com.github.oehme.sobula/sobula

if (_hasProperty) {
 Object _property = project.property("releaseVersion");
 it.setVersion(_property);
 it.setStatus("release");

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

project.setVersion(new GitDescriber(project.getProjectDir()).describe(true));
} catch (Exception e) {

相关文章