本文整理汇总了Java中org.gradle.tooling.GradleConnector.useGradleVersion方法的典型用法代码示例。如果您正苦于以下问题:Java GradleConnector.useGradleVersion方法的具体用法?Java GradleConnector.useGradleVersion怎么用?Java GradleConnector.useGradleVersion使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.gradle.tooling.GradleConnector
的用法示例。
在下文中一共展示了GradleConnector.useGradleVersion方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createProjectConnection
import org.gradle.tooling.GradleConnector; //导入方法依赖的package包/类
private ProjectConnection createProjectConnection(ComparableGradleBuildExecuter executer) {
GradleConnector connector = GradleConnector.newConnector();
connector.forProjectDirectory(executer.getSpec().getProjectDir());
File gradleUserHomeDir = gradle.getStartParameter().getGradleUserHomeDir();
if (gradleUserHomeDir != null) {
connector.useGradleUserHomeDir(gradleUserHomeDir);
}
GradleVersion gradleVersion = executer.getGradleVersion();
if (gradleVersion.equals(GradleVersion.current())) {
connector.useInstallation(gradle.getGradleHomeDir());
} else {
connector.useGradleVersion(gradleVersion.getVersion());
}
return connector.connect();
}
示例2: generate
import org.gradle.tooling.GradleConnector; //导入方法依赖的package包/类
@Override
public void generate(File targetDir, ProjectRequest projectRequest) {
GradleConnector gradleConnector = GradleConnector.newConnector().forProjectDirectory(targetDir);
if (projectRequest.getGradleVersion() != null) {
gradleConnector.useGradleVersion(projectRequest.getGradleVersion());
}
ProjectConnection connection = gradleConnector.connect();
try {
connection.newBuild().forTasks(buildTasks(projectRequest)).run();
} finally {
connection.close();
}
}
示例3: createProject
import org.gradle.tooling.GradleConnector; //导入方法依赖的package包/类
public ProjectConnection createProject(String name) throws IOException {
File projectDirectory = new File("target/" + name);
projectDirectory.mkdirs();
File gradleScript = new File(projectDirectory, "build.gradle");
if (new File("src/test/resources", name).isDirectory()) {
FileSystemUtils.copyRecursively(new File("src/test/resources", name),
projectDirectory);
}
else {
FileCopyUtils.copy(new File("src/test/resources/" + name + ".gradle"),
gradleScript);
}
GradleConnector gradleConnector = GradleConnector.newConnector();
gradleConnector.useGradleVersion(this.gradleVersion);
((DefaultGradleConnector) gradleConnector).embedded(true);
return gradleConnector.forProjectDirectory(projectDirectory).connect();
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:22,代码来源:ProjectCreator.java
示例4: createConnector
import org.gradle.tooling.GradleConnector; //导入方法依赖的package包/类
/**
* Creates a new Gradle connector for the context.
* @param context the target context
* @return a connector
*/
public static GradleConnector createConnector(GradleContext context) {
GradleConnector connector = GradleConnector.newConnector();
connector.forProjectDirectory(context.getProjectDirectory().getAbsoluteFile());
String versionLabel;
if (context.getGradleDistribution() != null) {
versionLabel = context.getGradleDistribution().toString();
connector.useDistribution(context.getGradleDistribution());
} else {
String version = context.getGradleVersion();
version = version == null ? GradleVersion.current().getVersion() : version;
versionLabel = version;
URI distribution = toDistributionUri(version, context.isUseHttps());
if (distribution != null) {
connector.useDistribution(distribution);
} else {
connector.useGradleVersion(version);
}
}
context.information(MessageFormat.format(
Messages.GradleUtil_infoPrepareDaemon,
versionLabel));
if (context.getGradleUserHomeDir() != null) {
connector.useGradleUserHomeDir(context.getGradleUserHomeDir().getAbsoluteFile());
}
return connector;
}
示例5: configureGradleRuntime
import org.gradle.tooling.GradleConnector; //导入方法依赖的package包/类
/**
* Configure the gradle runtime, version or home depending on the settings.
* @param connector
*/
public static void configureGradleRuntime(GradleConnector connector, IPreferenceStore prefs) {
String gradleVersion = prefs.getString(WorkbenchPreferencePage.GRADLE_VERSION_ID);
if (GradlePluginConstants.USE_GRADLE_HOME_VERSION_VALUE.equals(gradleVersion)) {
String gradleHome = prefs.getString(WorkbenchPreferencePage.GRADLE_HOME_ID);
File gradleHomeDir = new File(gradleHome);
if (isFileValidGradleInstallation(gradleHomeDir)) {
connector.useInstallation(gradleHomeDir);
return;
} else {
throw new IllegalStateException("Configured gradle home is not valid");
}
}
connector.useGradleVersion(gradleVersion);
}
示例6: applyTo
import org.gradle.tooling.GradleConnector; //导入方法依赖的package包/类
@Override
public void applyTo(GradleConnector gradleConnector) {
gradleConnector.useGradleVersion(gradleVersion);
}