Search in sources :

Example 6 with GradleExecutionSettings

use of org.jetbrains.plugins.gradle.settings.GradleExecutionSettings in project android by JetBrains.

the class GradleUtil method getOrCreateGradleExecutionSettings.

@Nullable
public static GradleExecutionSettings getOrCreateGradleExecutionSettings(@NotNull Project project, boolean useEmbeddedGradle) {
    GradleExecutionSettings executionSettings = getGradleExecutionSettings(project);
    if (IdeInfo.getInstance().isAndroidStudio() && useEmbeddedGradle) {
        if (executionSettings == null) {
            File gradlePath = EmbeddedDistributionPaths.getInstance().findEmbeddedGradleDistributionPath();
            assert gradlePath != null && gradlePath.isDirectory();
            executionSettings = new GradleExecutionSettings(gradlePath.getPath(), null, LOCAL, null, false);
            File jdkPath = IdeSdks.getInstance().getJdkPath();
            if (jdkPath != null) {
                executionSettings.setJavaHome(jdkPath.getPath());
            }
        }
    }
    return executionSettings;
}
Also used : GradleExecutionSettings(org.jetbrains.plugins.gradle.settings.GradleExecutionSettings) VirtualFile(com.intellij.openapi.vfs.VirtualFile) VfsUtil.findFileByIoFile(com.intellij.openapi.vfs.VfsUtil.findFileByIoFile) VfsUtilCore.virtualToIoFile(com.intellij.openapi.vfs.VfsUtilCore.virtualToIoFile) File(java.io.File) Nullable(org.jetbrains.annotations.Nullable)

Example 7 with GradleExecutionSettings

use of org.jetbrains.plugins.gradle.settings.GradleExecutionSettings in project android by JetBrains.

the class AndroidGradleBuildProcessParametersProviderTest method testPopulateJvmArgsWithGradleExecutionSettings.

public void testPopulateJvmArgsWithGradleExecutionSettings() {
    executeProjectChangeAction(true, new DisposeAwareProjectChange(myProject) {

        @Override
        public void execute() {
            removeAllKnownJdks();
            String jdkHome = myJdk.getHomePath();
            assertNotNull(jdkHome);
            File jdkHomePath = new File(toSystemDependentName(jdkHome));
            IdeSdks.getInstance().setJdkPath(jdkHomePath);
        }
    });
    GradleExecutionSettings settings = createMock(GradleExecutionSettings.class);
    expect(settings.getGradleHome()).andReturn("~/gradle-1.6");
    expect(settings.isVerboseProcessing()).andReturn(true);
    expect(settings.getServiceDirectory()).andReturn("~./gradle");
    if (!IdeInfo.getInstance().isAndroidStudio()) {
        expect(settings.getVmOptions()).andReturn(Sets.newLinkedHashSet("-Xmx2048m", "-XX:MaxPermSize=512m"));
    }
    replay(settings);
    List<String> jvmArgList = Lists.newArrayList();
    myParametersProvider.populateJvmArgs(settings, jvmArgList);
    Map<String, String> jvmArgs = convertJvmArgsToMap(jvmArgList);
    verify(settings);
    String projectDirPath = Projects.getBaseDirPath(myProject).getPath();
    assertEquals(projectDirPath, jvmArgs.get("-Dcom.android.studio.gradle.project.path"));
    assertEquals("~" + File.separatorChar + "gradle-1.6", jvmArgs.get("-Dcom.android.studio.gradle.home.path"));
    assertEquals("true", jvmArgs.get("-Dcom.android.studio.gradle.use.verbose.logging"));
    assertEquals("~." + File.separatorChar + "gradle", jvmArgs.get("-Dcom.android.studio.gradle.service.dir.path"));
    if (IdeInfo.getInstance().isAndroidStudio()) {
        String javaPath = FileUtilRt.toSystemDependentName(EmbeddedDistributionPaths.getInstance().getEmbeddedJdkPath().getAbsolutePath());
        assertEquals(javaPath, jvmArgs.get("-Dcom.android.studio.gradle.java.home.path"));
    } else {
        assertEquals("-Xmx2048m", jvmArgs.get("-Dcom.android.studio.gradle.daemon.jvm.option.0"));
        assertEquals("-XX:MaxPermSize=512m", jvmArgs.get("-Dcom.android.studio.gradle.daemon.jvm.option.1"));
        String javaHomeDirPath = myJdk.getHomePath();
        assertNotNull(javaHomeDirPath);
        javaHomeDirPath = toSystemDependentName(javaHomeDirPath);
        assertEquals(javaHomeDirPath, jvmArgs.get("-Dcom.android.studio.gradle.java.home.path"));
    }
}
Also used : GradleExecutionSettings(org.jetbrains.plugins.gradle.settings.GradleExecutionSettings) DisposeAwareProjectChange(com.intellij.openapi.externalSystem.util.DisposeAwareProjectChange) File(java.io.File)

Aggregations

GradleExecutionSettings (org.jetbrains.plugins.gradle.settings.GradleExecutionSettings)7 NotNull (org.jetbrains.annotations.NotNull)5 File (java.io.File)4 ExternalSystemTaskId (com.intellij.openapi.externalSystem.model.task.ExternalSystemTaskId)3 Nullable (org.jetbrains.annotations.Nullable)3 GradleUtil.getGradleExecutionSettings (com.android.tools.idea.gradle.util.GradleUtil.getGradleExecutionSettings)2 ExternalSystemTaskNotificationListener (com.intellij.openapi.externalSystem.model.task.ExternalSystemTaskNotificationListener)2 ActionCallback (com.intellij.openapi.util.ActionCallback)2 Function (com.intellij.util.Function)2 List (java.util.List)2 CancellationTokenSource (org.gradle.tooling.CancellationTokenSource)2 ProjectConnection (org.gradle.tooling.ProjectConnection)2 GradleVersion (org.gradle.util.GradleVersion)2 GradleExecutionHelper (org.jetbrains.plugins.gradle.service.execution.GradleExecutionHelper)2 UnsupportedCancellationToken (org.jetbrains.plugins.gradle.service.execution.UnsupportedCancellationToken)2 GradleBuildParticipant (org.jetbrains.plugins.gradle.settings.GradleBuildParticipant)2 AndroidProject (com.android.builder.model.AndroidProject)1 NativeAndroidProject (com.android.builder.model.NativeAndroidProject)1 CommandLineArgs (com.android.tools.idea.gradle.project.sync.common.CommandLineArgs)1 GRADLE_SYSTEM_ID (com.android.tools.idea.gradle.util.GradleUtil.GRADLE_SYSTEM_ID)1