本文整理汇总了Java中org.jetbrains.plugins.gradle.settings.GradleProjectSettings类的典型用法代码示例。如果您正苦于以下问题:Java GradleProjectSettings类的具体用法?Java GradleProjectSettings怎么用?Java GradleProjectSettings使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
GradleProjectSettings类属于org.jetbrains.plugins.gradle.settings包,在下文中一共展示了GradleProjectSettings类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: execute
import org.jetbrains.plugins.gradle.settings.GradleProjectSettings; //导入依赖的package包/类
@Override
protected void execute(@NotNull Project project) {
File projectDirPath = getBaseDirPath(project);
try {
createGradleWrapper(projectDirPath);
GradleProjectSettings settings = getGradleProjectSettings(project);
if (settings != null) {
settings.setDistributionType(DEFAULT_WRAPPED);
}
GradleProjectImporter.getInstance().requestProjectSync(project, null);
}
catch (IOException e) {
// Unlikely to happen.
Messages.showErrorDialog(project, "Failed to create Gradle wrapper: " + e.getMessage(), "Quick Fix");
}
}
示例2: DisableAutoImportNotificationPanel
import org.jetbrains.plugins.gradle.settings.GradleProjectSettings; //导入依赖的package包/类
DisableAutoImportNotificationPanel(@NotNull final GradleProjectSettings settings) {
setText("Gradle 'auto-import' will considerably slow down the IDE, due to a known bug.");
createActionLabel("Open bug report", new Runnable() {
@Override
public void run() {
BrowserUtil.browse("https://code.google.com/p/android/issues/detail?id=59965");
}
});
createActionLabel("Disable 'auto-import'", new Runnable() {
@Override
public void run() {
settings.setUseAutoImport(false);
myNotifications.updateAllNotifications();
}
});
}
示例3: setUp
import org.jetbrains.plugins.gradle.settings.GradleProjectSettings; //导入依赖的package包/类
@Override
public void setUp() throws Exception {
myJdkHome = IdeaTestUtil.requireRealJdkHome();
super.setUp();
assumeThat(gradleVersion, versionMatcherRule.getMatcher());
new WriteAction() {
@Override
protected void run(@NotNull Result result) throws Throwable {
Sdk oldJdk = ProjectJdkTable.getInstance().findJdk(GRADLE_JDK_NAME);
if (oldJdk != null) {
ProjectJdkTable.getInstance().removeJdk(oldJdk);
}
VirtualFile jdkHomeDir = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(new File(myJdkHome));
Sdk jdk = SdkConfigurationUtil.setupSdk(new Sdk[0], jdkHomeDir, JavaSdk.getInstance(), true, null, GRADLE_JDK_NAME);
assertNotNull("Cannot create JDK for " + myJdkHome, jdk);
ProjectJdkTable.getInstance().addJdk(jdk);
}
}.execute();
myProjectSettings = new GradleProjectSettings();
GradleSettings.getInstance(myProject).setGradleVmOptions("-Xmx64m -XX:MaxPermSize=64m");
System.setProperty(ExternalSystemExecutionSettings.REMOTE_PROCESS_IDLE_TTL_IN_MS_KEY, String.valueOf(GRADLE_DAEMON_TTL_MS));
configureWrapper();
}
示例4: validate
import org.jetbrains.plugins.gradle.settings.GradleProjectSettings; //导入依赖的package包/类
@Override
public boolean validate(GradleProjectSettings settings) throws ConfigurationException {
if (myGradleHomePathField == null) return true;
String gradleHomePath = FileUtil.toCanonicalPath(myGradleHomePathField.getText());
if (myUseLocalDistributionButton != null && myUseLocalDistributionButton.isSelected()) {
if (StringUtil.isEmpty(gradleHomePath)) {
myGradleHomeSettingType = LocationSettingType.UNKNOWN;
throw new ConfigurationException(GradleBundle.message("gradle.home.setting.type.explicit.empty", gradleHomePath));
}
else if (!myInstallationManager.isGradleSdkHome(new File(gradleHomePath))) {
myGradleHomeSettingType = LocationSettingType.EXPLICIT_INCORRECT;
new DelayedBalloonInfo(MessageType.ERROR, myGradleHomeSettingType, 0).run();
throw new ConfigurationException(GradleBundle.message("gradle.home.setting.type.explicit.incorrect", gradleHomePath));
}
}
return true;
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:IdeaGradleProjectSettingsControlBuilder.java
示例5: getManuallyDefinedGradleHome
import org.jetbrains.plugins.gradle.settings.GradleProjectSettings; //导入依赖的package包/类
/**
* Allows to ask for user-defined path to gradle.
*
* @param project target project to use (if any)
* @return path to the gradle distribution (if the one is explicitly configured)
*/
@Nullable
public File getManuallyDefinedGradleHome(@Nullable Project project, @NotNull String linkedProjectPath) {
if (project == null) {
return null;
}
GradleProjectSettings settings = GradleSettings.getInstance(project).getLinkedProjectSettings(linkedProjectPath);
if (settings == null) {
return null;
}
String path = settings.getGradleHome();
if (path == null) {
return null;
}
File candidate = new File(path);
return isGradleSdkHome(candidate) ? candidate : null;
}
示例6: canSync
import org.jetbrains.plugins.gradle.settings.GradleProjectSettings; //导入依赖的package包/类
@NotNull
static PreSyncCheckResult canSync(@NotNull Project project) {
VirtualFile baseDir = project.getBaseDir();
if (baseDir == null) {
// Unlikely to happen because it would mean this is the default project.
return PreSyncCheckResult.success();
}
if (isAndroidStudio()) {
// We only check proxy settings for Studio, because Studio does not pass the IDE's proxy settings to Gradle.
// See https://code.google.com/p/android/issues/detail?id=169743
checkHttpProxySettings(project);
}
ProjectSyncMessages syncMessages = ProjectSyncMessages.getInstance(project);
syncMessages.removeMessages(PROJECT_SYNCING_ERROR_GROUP);
if (!ApplicationManager.getApplication().isUnitTestMode()) {
attemptToUseEmbeddedGradle(project);
}
GradleProjectSettings gradleSettings = getGradleProjectSettings(project);
File wrapperPropertiesFile = findWrapperPropertiesFile(project);
DistributionType distributionType = gradleSettings != null ? gradleSettings.getDistributionType() : null;
boolean usingWrapper = (distributionType == null || distributionType == DEFAULT_WRAPPED) && wrapperPropertiesFile != null;
if (usingWrapper && gradleSettings != null) {
// Do this just to ensure that the right distribution type is set. If this is not set, build.gradle editor will not have code
// completion (see BuildClasspathModuleGradleDataService, line 119).
gradleSettings.setDistributionType(DEFAULT_WRAPPED);
}
else if (!ApplicationManager.getApplication().isUnitTestMode()) {
if (wrapperPropertiesFile == null && gradleSettings != null) {
createWrapperIfNecessary(project, gradleSettings, distributionType);
}
}
return PreSyncCheckResult.success();
}
示例7: getProjectSettingsControlBuilder
import org.jetbrains.plugins.gradle.settings.GradleProjectSettings; //导入依赖的package包/类
@Override
public GradleProjectSettingsControlBuilder getProjectSettingsControlBuilder(@NotNull GradleProjectSettings initialSettings) {
return new IdeaGradleProjectSettingsControlBuilder(initialSettings)
.dropCustomizableWrapperButton()
.dropUseBundledDistributionButton()
.dropGradleJdkComponents()
.dropCreateEmptyContentRootDirectoriesBox()
.dropUseAutoImportBox();
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:10,代码来源:AndroidStudioGradleSettingsControlProvider.java
示例8: execute
import org.jetbrains.plugins.gradle.settings.GradleProjectSettings; //导入依赖的package包/类
@Override
protected void execute(@NotNull Project project) {
updateGradleVersion(project, myWrapperPropertiesFile, myGradleVersion);
GradleProjectSettings settings = GradleUtil.getGradleProjectSettings(project);
if (settings != null) {
settings.setDistributionType(DistributionType.DEFAULT_WRAPPED);
}
GradleProjectImporter.getInstance().requestProjectSync(project, null);
}
示例9: handleError
import org.jetbrains.plugins.gradle.settings.GradleProjectSettings; //导入依赖的package包/类
@Override
public boolean handleError(@NotNull List<String> message,
@NotNull ExternalSystemException error,
@NotNull NotificationData notification,
@NotNull Project project) {
String lastLine = message.get(message.size() - 1);
if (OPEN_GRADLE_SETTINGS.equals(lastLine) || lastLine.contains(FIX_GRADLE_VERSION)) {
List<NotificationHyperlink> hyperlinks = Lists.newArrayList();
File wrapperPropertiesFile = GradleUtil.findWrapperPropertiesFile(project);
if (wrapperPropertiesFile != null) {
// It is very likely that we need to fix the model version as well. Do everything in one shot.
NotificationHyperlink hyperlink = FixGradleVersionInWrapperHyperlink.createIfProjectUsesGradleWrapper(project);
if (hyperlink != null) {
hyperlinks.add(hyperlink);
}
}
else {
GradleProjectSettings gradleProjectSettings = GradleUtil.getGradleProjectSettings(project);
if (gradleProjectSettings != null && gradleProjectSettings.getDistributionType() == DistributionType.LOCAL) {
hyperlinks.add(new CreateGradleWrapperHyperlink());
}
}
hyperlinks.add(new OpenGradleSettingsHyperlink());
updateNotification(notification, project, error.getMessage(), hyperlinks);
return true;
}
return false;
}
示例10: isUsingWrapper
import org.jetbrains.plugins.gradle.settings.GradleProjectSettings; //导入依赖的package包/类
private static boolean isUsingWrapper(@NotNull Project project) {
GradleProjectSettings gradleSettings = getGradleProjectSettings(project);
File wrapperPropertiesFile = findWrapperPropertiesFile(project);
DistributionType distributionType = gradleSettings != null ? gradleSettings.getDistributionType() : null;
return (distributionType == null || distributionType == DistributionType.DEFAULT_WRAPPED) && wrapperPropertiesFile != null;
}
示例11: getGradleExecutionSettings
import org.jetbrains.plugins.gradle.settings.GradleProjectSettings; //导入依赖的package包/类
@Nullable
public static GradleExecutionSettings getGradleExecutionSettings(@NotNull Project project) {
GradleProjectSettings projectSettings = getGradleProjectSettings(project);
if (projectSettings == null) {
File baseDirPath = getBaseDirPath(project);
String msg = String.format("Unable to obtain Gradle project settings for project '%1$s', located at '%2$s'", project.getName(),
baseDirPath.getPath());
LOG.info(msg);
return null;
}
// Set the JDK again, just in case it changed name after creating a project.
// See https://code.google.com/p/android/issues/detail?id=156747
Sdk jdk = IdeSdks.getJdk();
if (jdk != null) {
projectSettings.setGradleJvm(jdk.getName());
}
try {
GradleExecutionSettings settings = getExecutionSettings(project, projectSettings.getExternalProjectPath(), GRADLE_SYSTEM_ID);
if (settings != null) {
// By setting the Gradle daemon timeout to -1, we don't allow IDEA to set it to 1 minute. Gradle daemons need to be reused as
// much as possible. The default timeout is 3 hours.
settings.setRemoteProcessIdleTtlInMs(GRADLE_DAEMON_TIMEOUT_MS);
}
return settings;
}
catch (IllegalArgumentException e) {
LOG.info("Failed to obtain Gradle execution settings", e);
return null;
}
}
示例12: getGradleProjectSettings
import org.jetbrains.plugins.gradle.settings.GradleProjectSettings; //导入依赖的package包/类
@Nullable
public static GradleProjectSettings getGradleProjectSettings(@NotNull Project project) {
GradleSettings settings = (GradleSettings)getSettings(project, GRADLE_SYSTEM_ID);
GradleSettings.MyState state = settings.getState();
assert state != null;
Set<GradleProjectSettings> allProjectsSettings = state.getLinkedExternalProjectsSettings();
return getFirstNotNull(allProjectsSettings);
}
示例13: getFirstNotNull
import org.jetbrains.plugins.gradle.settings.GradleProjectSettings; //导入依赖的package包/类
@Nullable
private static GradleProjectSettings getFirstNotNull(@Nullable Set<GradleProjectSettings> allProjectSettings) {
if (allProjectSettings != null) {
for (GradleProjectSettings settings : allProjectSettings) {
if (settings != null) {
return settings;
}
}
}
return null;
}
示例14: getGradleVersion
import org.jetbrains.plugins.gradle.settings.GradleProjectSettings; //导入依赖的package包/类
@Nullable
public static FullRevision getGradleVersion(@NotNull Project project) {
String gradleVersion = getGradleVersionUsed(project);
if (isNotEmpty(gradleVersion)) {
// The version of Gradle used is retrieved one of the Gradle models. If that fails, we try to deduce it from the project's Gradle
// settings.
FullRevision revision = parseRevision(removeTimestampFromGradleVersion(gradleVersion));
if (revision != null) {
return revision;
}
}
GradleProjectSettings gradleSettings = getGradleProjectSettings(project);
if (gradleSettings != null) {
DistributionType distributionType = gradleSettings.getDistributionType();
if (distributionType == DEFAULT_WRAPPED) {
File wrapperPropertiesFile = findWrapperPropertiesFile(project);
if (wrapperPropertiesFile != null) {
try {
String wrapperVersion = getGradleWrapperVersion(wrapperPropertiesFile);
if (wrapperVersion != null) {
return parseRevision(removeTimestampFromGradleVersion(wrapperVersion));
}
}
catch (IOException e) {
LOG.info("Failed to read Gradle version in wrapper", e);
}
}
}
else if (distributionType == LOCAL) {
String gradleHome = gradleSettings.getGradleHome();
if (isNotEmpty(gradleHome)) {
File gradleHomePath = new File(gradleHome);
return getGradleVersion(gradleHomePath);
}
}
}
return null;
}
示例15: attemptToUseEmbeddedGradle
import org.jetbrains.plugins.gradle.settings.GradleProjectSettings; //导入依赖的package包/类
public static void attemptToUseEmbeddedGradle(@NotNull Project project) {
if (isAndroidStudio()) {
File wrapperPropertiesFile = findWrapperPropertiesFile(project);
if (wrapperPropertiesFile != null) {
String gradleVersion = null;
try {
Properties properties = getProperties(wrapperPropertiesFile);
String url = properties.getProperty(DISTRIBUTION_URL_PROPERTY);
gradleVersion = getGradleWrapperVersionOnlyIfComingForGradleDotOrg(url);
}
catch (IOException e) {
LOG.warn("Failed to read file " + wrapperPropertiesFile.getPath());
}
if (gradleVersion != null &&
isCompatibleWithEmbeddedGradleVersion(gradleVersion) &&
!isWrapperInGradleCache(project, gradleVersion)) {
File embeddedGradlePath = findEmbeddedGradleDistributionPath();
if (embeddedGradlePath != null) {
GradleProjectSettings gradleSettings = getGradleProjectSettings(project);
if (gradleSettings != null) {
gradleSettings.setDistributionType(LOCAL);
gradleSettings.setGradleHome(embeddedGradlePath.getPath());
}
}
}
}
}
}