mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Merge branch 'vsoroka/gradle_native'
This commit is contained in:
Generated
+2
@@ -430,6 +430,8 @@
|
||||
<module fileurl="file://$PROJECT_DIR$/plugins/gradle/intellij.gradle.common.iml" filepath="$PROJECT_DIR$/plugins/gradle/intellij.gradle.common.iml" />
|
||||
<module fileurl="file://$PROJECT_DIR$/plugins/gradle/java/intellij.gradle.java.iml" filepath="$PROJECT_DIR$/plugins/gradle/java/intellij.gradle.java.iml" />
|
||||
<module fileurl="file://$PROJECT_DIR$/plugins/gradle/java/intellij.gradle.java.tests.iml" filepath="$PROJECT_DIR$/plugins/gradle/java/intellij.gradle.java.tests.iml" />
|
||||
<module fileurl="file://$PROJECT_DIR$/plugins/gradle/native/intellij.gradle.native.iml" filepath="$PROJECT_DIR$/plugins/gradle/native/intellij.gradle.native.iml" />
|
||||
<module fileurl="file://$PROJECT_DIR$/plugins/gradle/native/tooling/intellij.gradle.native.tooling.iml" filepath="$PROJECT_DIR$/plugins/gradle/native/tooling/intellij.gradle.native.tooling.iml" />
|
||||
<module fileurl="file://$PROJECT_DIR$/plugins/gradle/jps-plugin/intellij.gradle.jps.iml" filepath="$PROJECT_DIR$/plugins/gradle/jps-plugin/intellij.gradle.jps.iml" />
|
||||
<module fileurl="file://$PROJECT_DIR$/plugins/gradle/intellij.gradle.tests.iml" filepath="$PROJECT_DIR$/plugins/gradle/intellij.gradle.tests.iml" />
|
||||
<module fileurl="file://$PROJECT_DIR$/plugins/gradle/tooling-extension-api/intellij.gradle.toolingExtension.iml" filepath="$PROJECT_DIR$/plugins/gradle/tooling-extension-api/intellij.gradle.toolingExtension.iml" />
|
||||
|
||||
+2
-1
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package com.intellij.openapi.externalSystem.settings;
|
||||
|
||||
import com.intellij.openapi.externalSystem.util.ExternalSystemApiUtil;
|
||||
import com.intellij.openapi.util.Comparing;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -45,7 +46,7 @@ public abstract class ExternalProjectSettings implements Comparable<ExternalProj
|
||||
|
||||
private boolean myUseAutoImport;
|
||||
private boolean myCreateEmptyContentRootDirectories;
|
||||
private boolean myUseQualifiedModuleNames;
|
||||
private boolean myUseQualifiedModuleNames = !ExternalSystemApiUtil.isJavaCompatibleIde();
|
||||
|
||||
public String getExternalProjectPath() {
|
||||
return myExternalProjectPath;
|
||||
|
||||
+15
@@ -56,6 +56,7 @@ import com.intellij.util.containers.*;
|
||||
import com.intellij.util.containers.Stack;
|
||||
import com.intellij.util.lang.UrlClassLoader;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jetbrains.annotations.Contract;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -71,6 +72,8 @@ import java.util.Queue;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import static com.intellij.util.PlatformUtils.*;
|
||||
|
||||
/**
|
||||
* @author Denis Zhdanov
|
||||
* @since 4/1/13 1:31 PM
|
||||
@@ -867,4 +870,16 @@ public class ExternalSystemApiUtil {
|
||||
//noinspection unchecked
|
||||
getSettings(project, systemId).subscribe(listener);
|
||||
}
|
||||
|
||||
/**
|
||||
* DO NOT USE THIS METHOD.
|
||||
* The method should be removed when the 'java' subsystem features will be extracted from External System API [IDEA-187832]
|
||||
*
|
||||
* @return check if the current IDE is compatible with the 'java' IntelliJ subsystem
|
||||
*/
|
||||
@ApiStatus.Experimental
|
||||
@Deprecated
|
||||
public static boolean isJavaCompatibleIde() {
|
||||
return isIdeaUltimate() || isIdeaCommunity() || "AndroidStudio".equals(getPlatformPrefix());
|
||||
}
|
||||
}
|
||||
|
||||
+13
-4
@@ -20,6 +20,7 @@ import com.intellij.ide.actions.ImportModuleAction;
|
||||
import com.intellij.ide.util.newProjectWizard.AddModuleWizard;
|
||||
import com.intellij.openapi.actionSystem.AnAction;
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import com.intellij.openapi.actionSystem.Presentation;
|
||||
import com.intellij.openapi.externalSystem.ExternalSystemManager;
|
||||
import com.intellij.openapi.externalSystem.model.ExternalSystemDataKeys;
|
||||
import com.intellij.openapi.externalSystem.model.ProjectSystemId;
|
||||
@@ -43,14 +44,22 @@ public class AttachExternalProjectAction extends AnAction {
|
||||
|
||||
@Override
|
||||
public void update(AnActionEvent e) {
|
||||
Presentation presentation = e.getPresentation();
|
||||
// todo [Vlad, IDEA-187835]: provide java subsystem independent implementation
|
||||
if (!ExternalSystemApiUtil.isJavaCompatibleIde()) {
|
||||
presentation.setVisible(false);
|
||||
presentation.setEnabled(false);
|
||||
return;
|
||||
}
|
||||
|
||||
ProjectSystemId externalSystemId = ExternalSystemDataKeys.EXTERNAL_SYSTEM_ID.getData(e.getDataContext());
|
||||
if (externalSystemId != null) {
|
||||
String name = externalSystemId.getReadableName();
|
||||
e.getPresentation().setText(ExternalSystemBundle.message("action.attach.external.project.text", name));
|
||||
e.getPresentation().setDescription(ExternalSystemBundle.message("action.attach.external.project.description", name));
|
||||
presentation.setText(ExternalSystemBundle.message("action.attach.external.project.text", name));
|
||||
presentation.setDescription(ExternalSystemBundle.message("action.attach.external.project.description", name));
|
||||
}
|
||||
|
||||
e.getPresentation().setIcon(SystemInfoRt.isMac ? AllIcons.ToolbarDecorator.Mac.Add : AllIcons.ToolbarDecorator.Add);
|
||||
|
||||
presentation.setIcon(SystemInfoRt.isMac ? AllIcons.ToolbarDecorator.Mac.Add : AllIcons.ToolbarDecorator.Add);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+40
-25
@@ -63,6 +63,7 @@ import com.intellij.openapi.vfs.VfsUtil;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.search.GlobalSearchScope;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import com.intellij.util.PlatformUtils;
|
||||
import com.intellij.util.SmartList;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.net.NetUtils;
|
||||
@@ -281,33 +282,11 @@ public class ExternalSystemRunConfiguration extends LocatableConfigurationBase i
|
||||
public ExecutionResult execute(Executor executor, @NotNull ProgramRunner runner) throws ExecutionException {
|
||||
if (myProject.isDisposed()) return null;
|
||||
|
||||
final JavaParameters extensionsJP = new JavaParameters();
|
||||
final RunConfigurationExtension[] extensions = Extensions.getExtensions(RunConfigurationExtension.EP_NAME);
|
||||
for (RunConfigurationExtension ext : extensions) {
|
||||
ext.updateJavaParameters(myConfiguration, extensionsJP, myEnv.getRunnerSettings());
|
||||
if (mySettings.getTaskNames().isEmpty()) {
|
||||
throw new ExecutionException(ExternalSystemBundle.message("run.error.undefined.task"));
|
||||
}
|
||||
|
||||
String jvmAgentSetup;
|
||||
if (myDebugPort > 0) {
|
||||
jvmAgentSetup = DEBUG_SETUP_PREFIX + myDebugPort;
|
||||
if (getForkSocket() != null) {
|
||||
jvmAgentSetup += " -forkSocket" + getForkSocket().getLocalPort();
|
||||
}
|
||||
}
|
||||
else {
|
||||
ParametersList parametersList = extensionsJP.getVMParametersList();
|
||||
final ParametersList data = myEnv.getUserData(ExternalSystemTaskExecutionSettings.JVM_AGENT_SETUP_KEY);
|
||||
if (data != null) {
|
||||
parametersList.addAll(data.getList());
|
||||
}
|
||||
for (String parameter : parametersList.getList()) {
|
||||
if (parameter.startsWith("-agentlib:")) continue;
|
||||
if (parameter.startsWith("-agentpath:")) continue;
|
||||
if (parameter.startsWith("-javaagent:")) continue;
|
||||
throw new ExecutionException(ExternalSystemBundle.message("run.invalid.jvm.agent.configuration", parameter));
|
||||
}
|
||||
jvmAgentSetup = parametersList.getParametersString();
|
||||
}
|
||||
String jvmAgentSetup = getJvmAgentSetup();
|
||||
|
||||
ApplicationManager.getApplication().assertIsDispatchThread();
|
||||
FileDocumentManager.getInstance().saveAllDocuments();
|
||||
@@ -468,6 +447,42 @@ public class ExternalSystemRunConfiguration extends LocatableConfigurationBase i
|
||||
return executionResult;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private String getJvmAgentSetup() throws ExecutionException {
|
||||
// todo [Vlad, IDEA-187832]: extract to `external-system-java` module
|
||||
if(!ExternalSystemApiUtil.isJavaCompatibleIde()) return null;
|
||||
|
||||
final JavaParameters extensionsJP = new JavaParameters();
|
||||
final RunConfigurationExtension[] extensions = Extensions.getExtensions(RunConfigurationExtension.EP_NAME);
|
||||
for (RunConfigurationExtension ext : extensions) {
|
||||
ext.updateJavaParameters(myConfiguration, extensionsJP, myEnv.getRunnerSettings());
|
||||
}
|
||||
|
||||
String jvmAgentSetup;
|
||||
|
||||
if (myDebugPort > 0) {
|
||||
jvmAgentSetup = DEBUG_SETUP_PREFIX + myDebugPort;
|
||||
if (getForkSocket() != null) {
|
||||
jvmAgentSetup += " -forkSocket" + getForkSocket().getLocalPort();
|
||||
}
|
||||
}
|
||||
else {
|
||||
ParametersList parametersList = extensionsJP.getVMParametersList();
|
||||
final ParametersList data = myEnv.getUserData(ExternalSystemTaskExecutionSettings.JVM_AGENT_SETUP_KEY);
|
||||
if (data != null) {
|
||||
parametersList.addAll(data.getList());
|
||||
}
|
||||
for (String parameter : parametersList.getList()) {
|
||||
if (parameter.startsWith("-agentlib:")) continue;
|
||||
if (parameter.startsWith("-agentpath:")) continue;
|
||||
if (parameter.startsWith("-javaagent:")) continue;
|
||||
throw new ExecutionException(ExternalSystemBundle.message("run.invalid.jvm.agent.configuration", parameter));
|
||||
}
|
||||
jvmAgentSetup = parametersList.getParametersString();
|
||||
}
|
||||
return jvmAgentSetup;
|
||||
}
|
||||
|
||||
private BuildProgressListener createBuildView(ExternalSystemTaskId id,
|
||||
String executionName,
|
||||
String workingDir,
|
||||
|
||||
+5
-1
@@ -105,7 +105,11 @@ public abstract class AbstractModuleDataService<E extends ModuleData> extends Ab
|
||||
setModuleOptions(module, node);
|
||||
ModifiableRootModel modifiableRootModel = modelsProvider.getModifiableRootModel(module);
|
||||
syncPaths(module, modifiableRootModel, node.getData());
|
||||
setLanguageLevel(modifiableRootModel, node.getData());
|
||||
|
||||
if(ModuleTypeId.JAVA_MODULE.equals(module.getModuleTypeName())) {
|
||||
// todo [Vlad, IDEA-187832]: extract to `external-system-java` module
|
||||
setLanguageLevel(modifiableRootModel, node.getData());
|
||||
}
|
||||
setSdk(modifiableRootModel, node.getData());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,35 +1,38 @@
|
||||
<idea-plugin>
|
||||
<extensionPoints>
|
||||
<extensionPoint name="externalSystemManager" interface="com.intellij.openapi.externalSystem.ExternalSystemManager"/>
|
||||
<extensionPoint name="externalSystemWorkspaceContributor"
|
||||
<extensionPoint qualifiedName="com.intellij.externalSystemManager"
|
||||
interface="com.intellij.openapi.externalSystem.ExternalSystemManager"/>
|
||||
<extensionPoint qualifiedName="com.intellij.externalSystemWorkspaceContributor"
|
||||
interface="com.intellij.openapi.externalSystem.service.project.ExternalProjectsWorkspaceImpl$Contributor"/>
|
||||
<extensionPoint name="externalProjectDataService"
|
||||
<extensionPoint qualifiedName="com.intellij.externalProjectDataService"
|
||||
interface="com.intellij.openapi.externalSystem.service.project.manage.ProjectDataService"/>
|
||||
<extensionPoint name="externalSystemConfigurationHandler"
|
||||
<extensionPoint qualifiedName="com.intellij.externalSystemConfigurationHandler"
|
||||
interface="com.intellij.openapi.externalSystem.service.project.settings.ConfigurationHandler"/>
|
||||
<extensionPoint name="externalSystem.runConfigurationImporter"
|
||||
<extensionPoint qualifiedName="com.intellij.externalSystem.runConfigurationImporter"
|
||||
interface="com.intellij.openapi.externalSystem.service.project.settings.RunConfigurationImporter"/>
|
||||
<extensionPoint name="externalSystem.facetConfigurationImporter"
|
||||
<extensionPoint qualifiedName="com.intellij.externalSystem.facetConfigurationImporter"
|
||||
interface="com.intellij.openapi.externalSystem.service.project.settings.FacetConfigurationImporter"/>
|
||||
<extensionPoint name="externalSystem.codeStyleConfigurationImporter"
|
||||
<extensionPoint qualifiedName="com.intellij.externalSystem.codeStyleConfigurationImporter"
|
||||
interface="com.intellij.openapi.externalSystem.service.project.settings.CodeStyleConfigurationImporter"/>
|
||||
<extensionPoint name="externalSystem.beforeRunTaskImporter"
|
||||
<extensionPoint qualifiedName="com.intellij.externalSystem.beforeRunTaskImporter"
|
||||
interface="com.intellij.openapi.externalSystem.service.project.settings.BeforeRunTaskImporter"/>
|
||||
<extensionPoint name="externalSystemConfigLocator"
|
||||
<extensionPoint qualifiedName="com.intellij.externalSystemConfigLocator"
|
||||
interface="com.intellij.openapi.externalSystem.service.settings.ExternalSystemConfigLocator"/>
|
||||
<extensionPoint name="externalSystemNotificationExtension"
|
||||
<extensionPoint qualifiedName="com.intellij.externalSystemNotificationExtension"
|
||||
interface="com.intellij.openapi.externalSystem.service.notification.ExternalSystemNotificationExtension"/>
|
||||
<extensionPoint name="externalSystemKeymapProvider"
|
||||
<extensionPoint qualifiedName="com.intellij.externalSystemKeymapProvider"
|
||||
interface="com.intellij.openapi.externalSystem.service.project.manage.ExternalSystemKeymapExtension$ActionsProvider"/>
|
||||
<extensionPoint name="externalSystemTaskNotificationListener"
|
||||
<extensionPoint qualifiedName="com.intellij.externalSystemTaskNotificationListener"
|
||||
interface="com.intellij.openapi.externalSystem.model.task.ExternalSystemTaskNotificationListener"/>
|
||||
<extensionPoint name="externalSystemExecutionConsoleManager"
|
||||
<extensionPoint qualifiedName="com.intellij.externalSystemExecutionConsoleManager"
|
||||
interface="com.intellij.openapi.externalSystem.execution.ExternalSystemExecutionConsoleManager"/>
|
||||
<extensionPoint name="externalSystemOutputParserProvider"
|
||||
<extensionPoint qualifiedName="com.intellij.externalSystemOutputParserProvider"
|
||||
interface="com.intellij.openapi.externalSystem.service.execution.ExternalSystemOutputParserProvider"/>
|
||||
<extensionPoint name="externalSystemViewContributor" interface="com.intellij.openapi.externalSystem.view.ExternalSystemViewContributor"/>
|
||||
<extensionPoint name="externalProjectStructureCustomizer" interface="com.intellij.openapi.externalSystem.importing.ExternalProjectStructureCustomizer"/>
|
||||
<extensionPoint name="externalProjectWatcherContributor"
|
||||
<extensionPoint qualifiedName="com.intellij.externalSystemViewContributor"
|
||||
interface="com.intellij.openapi.externalSystem.view.ExternalSystemViewContributor"/>
|
||||
<extensionPoint qualifiedName="com.intellij.externalProjectStructureCustomizer"
|
||||
interface="com.intellij.openapi.externalSystem.importing.ExternalProjectStructureCustomizer"/>
|
||||
<extensionPoint qualifiedName="com.intellij.externalProjectWatcherContributor"
|
||||
interface="com.intellij.openapi.externalSystem.service.project.autoimport.ExternalSystemProjectsWatcherImpl$Contributor"/>
|
||||
</extensionPoints>
|
||||
</idea-plugin>
|
||||
@@ -273,11 +273,11 @@ public class GradleResourceCompilerConfigurationGenerator {
|
||||
rootConfiguration.targetPath = FileUtil.toSystemIndependentName(target);
|
||||
|
||||
rootConfiguration.includes.clear();
|
||||
for (String include : directorySet.getIncludes()) {
|
||||
for (String include : directorySet.getPatterns().getIncludes()) {
|
||||
rootConfiguration.includes.add(include.trim());
|
||||
}
|
||||
rootConfiguration.excludes.clear();
|
||||
for (String exclude : directorySet.getExcludes()) {
|
||||
for (String exclude : directorySet.getPatterns().getExcludes()) {
|
||||
rootConfiguration.excludes.add(exclude.trim());
|
||||
}
|
||||
if (sourcesDirectorySet != null && sourcesDirectorySet.getSrcDirs().contains(file)) {
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" packagePrefix="org.jetbrains.plugins.gradle.nativeplatform" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/resources" type="java-resource" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="module" module-name="intellij.platform.lang" />
|
||||
<orderEntry type="module" module-name="intellij.platform.lang.impl" />
|
||||
<orderEntry type="module" module-name="intellij.gradle" />
|
||||
<orderEntry type="module" module-name="intellij.gradle.common" exported="" />
|
||||
<orderEntry type="module" module-name="intellij.gradle.native.tooling" exported="" />
|
||||
<orderEntry type="module" module-name="intellij.gradle.toolingExtension.impl" />
|
||||
</component>
|
||||
</module>
|
||||
@@ -0,0 +1,24 @@
|
||||
<!--
|
||||
~ Copyright 2000-2018 JetBrains s.r.o.
|
||||
~ Licensed under the Apache License, Version 2.0 (the "License");
|
||||
~ you may not use this file except in compliance with the License.
|
||||
~ You may obtain a copy of the License at
|
||||
~
|
||||
~ http://www.apache.org/licenses/LICENSE-2.0
|
||||
~
|
||||
~ Unless required by applicable law or agreed to in writing, software
|
||||
~ distributed under the License is distributed on an "AS IS" BASIS,
|
||||
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
~ See the License for the specific language governing permissions and
|
||||
~ limitations under the License.
|
||||
~
|
||||
-->
|
||||
|
||||
<idea-plugin>
|
||||
<module value="org.jetbrains.plugins.gradle.native"/>
|
||||
<depends>org.jetbrains.plugins.gradle</depends>
|
||||
|
||||
<extensions defaultExtensionNs="org.jetbrains.plugins.gradle">
|
||||
<projectResolve implementation="org.jetbrains.plugins.gradle.nativeplatform.project.GradleNativeProjectResolver"/>
|
||||
</extensions>
|
||||
</idea-plugin>
|
||||
@@ -0,0 +1,66 @@
|
||||
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package org.jetbrains.plugins.gradle.nativeplatform.project;
|
||||
|
||||
import com.intellij.openapi.externalSystem.model.DataNode;
|
||||
import com.intellij.openapi.externalSystem.model.Key;
|
||||
import com.intellij.openapi.externalSystem.model.ProjectKeys;
|
||||
import com.intellij.openapi.externalSystem.model.project.ContentRootData;
|
||||
import com.intellij.openapi.externalSystem.model.project.ExternalSystemSourceType;
|
||||
import com.intellij.openapi.externalSystem.model.project.ModuleData;
|
||||
import com.intellij.openapi.externalSystem.util.ExternalSystemConstants;
|
||||
import com.intellij.openapi.externalSystem.util.Order;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import org.gradle.tooling.model.idea.IdeaModule;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.plugins.gradle.nativeplatform.tooling.builder.CppModelBuilder;
|
||||
import org.jetbrains.plugins.gradle.nativeplatform.tooling.model.CppProject;
|
||||
import org.jetbrains.plugins.gradle.nativeplatform.tooling.model.SourceFolder;
|
||||
import org.jetbrains.plugins.gradle.nativeplatform.tooling.model.impl.CppProjectImpl;
|
||||
import org.jetbrains.plugins.gradle.service.project.AbstractProjectResolverExtension;
|
||||
import org.jetbrains.plugins.gradle.util.GradleConstants;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author Vladislav.Soroka
|
||||
*/
|
||||
@Order(ExternalSystemConstants.UNORDERED)
|
||||
public class GradleNativeProjectResolver extends AbstractProjectResolverExtension {
|
||||
@NotNull public static final Key<CppProject> CPP_PROJECT = Key.create(CppProject.class, ProjectKeys.MODULE.getProcessingWeight() + 1);
|
||||
|
||||
@Override
|
||||
public void populateModuleContentRoots(@NotNull IdeaModule gradleModule, @NotNull DataNode<ModuleData> ideModule) {
|
||||
CppProject cppProject = resolverCtx.getExtraProject(gradleModule, CppProject.class);
|
||||
if (cppProject != null) {
|
||||
// store a local process copy of the object to get rid of proxy types for further serialization
|
||||
ideModule.createChild(CPP_PROJECT, new CppProjectImpl(cppProject));
|
||||
|
||||
Set<SourceFolder> sourceFolders = cppProject.getSourceFolders();
|
||||
for (SourceFolder folder : sourceFolders) {
|
||||
File baseDir = folder.getBaseDir();
|
||||
ContentRootData ideContentRoot = new ContentRootData(GradleConstants.SYSTEM_ID, baseDir.getAbsolutePath());
|
||||
ideContentRoot.storePath(ExternalSystemSourceType.SOURCE, baseDir.getAbsolutePath());
|
||||
ideModule.createChild(ProjectKeys.CONTENT_ROOT, ideContentRoot);
|
||||
}
|
||||
}
|
||||
|
||||
nextResolver.populateModuleContentRoots(gradleModule, ideModule);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Set<Class> getExtraProjectModelClasses() {
|
||||
return Collections.singleton(CppProject.class);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Set<Class> getToolingExtensionsClasses() {
|
||||
return ContainerUtil.set(
|
||||
// native-gradle-tooling jar
|
||||
CppModelBuilder.class
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_6" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" packagePrefix="org.jetbrains.plugins.gradle.nativeplatform.tooling" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/resources" type="java-resource" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="module" module-name="intellij.platform.annotations.java5" />
|
||||
<orderEntry type="module" module-name="intellij.gradle.toolingExtension" />
|
||||
<orderEntry type="module" module-name="intellij.gradle.toolingExtension.impl" />
|
||||
<orderEntry type="library" name="Gradle" level="project" />
|
||||
</component>
|
||||
</module>
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
# Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
#
|
||||
# Copyright 2000-2018 JetBrains s.r.o.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
org.jetbrains.plugins.gradle.nativeplatform.tooling.builder.CppModelBuilder
|
||||
@@ -0,0 +1,203 @@
|
||||
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package org.jetbrains.plugins.gradle.nativeplatform.tooling.builder;
|
||||
|
||||
import org.gradle.api.Project;
|
||||
import org.gradle.api.component.SoftwareComponent;
|
||||
import org.gradle.api.file.FileCollection;
|
||||
import org.gradle.api.file.RegularFileProperty;
|
||||
import org.gradle.api.internal.file.FileCollectionInternal;
|
||||
import org.gradle.api.internal.file.FileCollectionVisitor;
|
||||
import org.gradle.api.internal.file.FileTreeInternal;
|
||||
import org.gradle.api.internal.file.collections.DirectoryFileTree;
|
||||
import org.gradle.api.provider.Provider;
|
||||
import org.gradle.api.tasks.util.PatternSet;
|
||||
import org.gradle.internal.impldep.org.apache.commons.lang.StringUtils;
|
||||
import org.gradle.internal.os.OperatingSystem;
|
||||
import org.gradle.language.cpp.CppBinary;
|
||||
import org.gradle.language.cpp.CppComponent;
|
||||
import org.gradle.language.cpp.CppSharedLibrary;
|
||||
import org.gradle.language.cpp.CppStaticLibrary;
|
||||
import org.gradle.language.cpp.plugins.CppBasePlugin;
|
||||
import org.gradle.language.cpp.tasks.CppCompile;
|
||||
import org.gradle.language.nativeplatform.ComponentWithExecutable;
|
||||
import org.gradle.nativeplatform.tasks.LinkExecutable;
|
||||
import org.gradle.nativeplatform.toolchain.Clang;
|
||||
import org.gradle.nativeplatform.toolchain.Gcc;
|
||||
import org.gradle.nativeplatform.toolchain.NativeToolChain;
|
||||
import org.gradle.nativeplatform.toolchain.internal.ToolType;
|
||||
import org.gradle.nativeplatform.toolchain.internal.tools.CommandLineToolSearchResult;
|
||||
import org.gradle.nativeplatform.toolchain.internal.tools.ToolSearchPath;
|
||||
import org.gradle.util.GradleVersion;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.plugins.gradle.model.FilePatternSetImpl;
|
||||
import org.jetbrains.plugins.gradle.nativeplatform.tooling.model.CompilerDetails;
|
||||
import org.jetbrains.plugins.gradle.nativeplatform.tooling.model.CppBinary.TargetType;
|
||||
import org.jetbrains.plugins.gradle.nativeplatform.tooling.model.CppProject;
|
||||
import org.jetbrains.plugins.gradle.nativeplatform.tooling.model.LinkerDetails;
|
||||
import org.jetbrains.plugins.gradle.nativeplatform.tooling.model.impl.*;
|
||||
import org.jetbrains.plugins.gradle.tooling.ErrorMessageBuilder;
|
||||
import org.jetbrains.plugins.gradle.tooling.ModelBuilderService;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* The prototype of the C++ project gradle tooling model builder.
|
||||
* This implementation should be moved or replaced with the similar model builder from the Gradle distribution.
|
||||
*
|
||||
* @author Vladislav.Soroka
|
||||
*/
|
||||
public class CppModelBuilder implements ModelBuilderService {
|
||||
|
||||
@Override
|
||||
public boolean canBuild(String modelName) {
|
||||
return CppProject.class.getName().equals(modelName);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Object buildAll(final String modelName, final Project project) {
|
||||
final CppBasePlugin cppPlugin = project.getPlugins().findPlugin(CppBasePlugin.class);
|
||||
if (cppPlugin == null) return null;
|
||||
|
||||
final CppProjectImpl cppProject = new CppProjectImpl();
|
||||
for (SoftwareComponent component : project.getComponents()) {
|
||||
if (component instanceof CppComponent) {
|
||||
File cppCompilerExecutable = null;
|
||||
CppComponent cppComponent = (CppComponent)component;
|
||||
for (CppBinary cppBinary : cppComponent.getBinaries().get()) {
|
||||
if (cppCompilerExecutable == null) {
|
||||
cppCompilerExecutable = findCppCompilerExecutable(cppBinary);
|
||||
}
|
||||
|
||||
List<String> compilerArgs = new ArrayList<String>();
|
||||
Set<File> compileIncludePath = cppBinary.getCompileIncludePath().getFiles();
|
||||
|
||||
Set<File> sources = cppBinary.getCppSource().getFiles();
|
||||
String baseName = cppBinary.getBaseName().getOrElse("");
|
||||
String variantName = StringUtils.removeStart(cppBinary.getName(), "main");
|
||||
String compileTaskName = null;
|
||||
Set<File> systemIncludes = new LinkedHashSet<File>();
|
||||
Provider<CppCompile> compileTask = cppBinary.getCompileTask();
|
||||
if (compileTask.isPresent()) {
|
||||
CppCompile cppCompile = compileTask.get();
|
||||
compileTaskName = cppCompile.getPath();
|
||||
compilerArgs.addAll(cppCompile.getCompilerArgs().getOrElse(Collections.<String>emptyList()));
|
||||
systemIncludes.addAll(cppCompile.getIncludes().getFiles());
|
||||
}
|
||||
|
||||
File executableFile = null;
|
||||
String linkTaskName = null;
|
||||
boolean isExecutable = cppBinary instanceof ComponentWithExecutable;
|
||||
if (isExecutable) {
|
||||
Provider<? extends LinkExecutable> fileProvider = ((ComponentWithExecutable)cppBinary).getLinkTask();
|
||||
if (fileProvider.isPresent()) {
|
||||
LinkExecutable linkExecutable = fileProvider.get();
|
||||
linkTaskName = linkExecutable.getPath();
|
||||
executableFile = getExecutableFile(linkExecutable);
|
||||
}
|
||||
}
|
||||
|
||||
TargetType targetType = null;
|
||||
if (isExecutable) {
|
||||
targetType = TargetType.EXECUTABLE;
|
||||
}
|
||||
else if (cppBinary instanceof CppSharedLibrary) {
|
||||
targetType = TargetType.SHARED_LIBRARY;
|
||||
}
|
||||
else if (cppBinary instanceof CppStaticLibrary) {
|
||||
targetType = TargetType.STATIC_LIBRARY;
|
||||
}
|
||||
|
||||
// resolve compiler working dir as compiler executable file parent dir
|
||||
// https://github.com/gradle/gradle/blob/7422d5fc2e04d564dfd73bc539a37b62f8e2113a/subprojects/platform-native/src/main/java/org/gradle/nativeplatform/toolchain/internal/metadata/AbstractMetadataProvider.java#L61
|
||||
File compilerWorkingDir = cppCompilerExecutable == null ? null : cppCompilerExecutable.getParentFile();
|
||||
CompilerDetails compilerDetails = new CompilerDetailsImpl(
|
||||
compileTaskName, cppCompilerExecutable, compilerWorkingDir, compilerArgs, compileIncludePath, systemIncludes);
|
||||
LinkerDetails linkerDetails = new LinkerDetailsImpl(linkTaskName, executableFile);
|
||||
cppProject.addBinary(new CppBinaryImpl(baseName, variantName, sources, compilerDetails, linkerDetails, targetType));
|
||||
}
|
||||
|
||||
addSourceFolders(cppProject, cppComponent);
|
||||
}
|
||||
}
|
||||
|
||||
return cppProject;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static File getExecutableFile(LinkExecutable linkExecutable) {
|
||||
File executableFile;
|
||||
RegularFileProperty binaryFile = null;
|
||||
if (GradleVersion.current().compareTo(GradleVersion.version("4.7")) < 0) {
|
||||
binaryFile = linkExecutable.getBinaryFile();
|
||||
}
|
||||
else {
|
||||
try {
|
||||
Object linkedFile = linkExecutable.getClass().getMethod("getLinkedFile").invoke(linkExecutable);
|
||||
if (linkedFile instanceof RegularFileProperty) {
|
||||
binaryFile = (RegularFileProperty)linkedFile;
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
//noinspection CallToPrintStackTrace
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
executableFile = binaryFile != null ? binaryFile.getAsFile().getOrNull() : null;
|
||||
return executableFile;
|
||||
}
|
||||
|
||||
private static void addSourceFolders(final CppProjectImpl cppProject, CppComponent cppComponent) {
|
||||
for (File dir : cppComponent.getPrivateHeaderDirs()) {
|
||||
cppProject.addSourceFolder(
|
||||
new SourceFolderImpl(dir, new FilePatternSetImpl(Collections.<String>emptySet(), Collections.<String>emptySet())));
|
||||
}
|
||||
|
||||
FileCollection cppSource = cppComponent.getCppSource();
|
||||
// try to resolve cpp source folders
|
||||
((FileCollectionInternal)cppSource).visitRootElements(new FileCollectionVisitor() {
|
||||
@Override
|
||||
public void visitCollection(FileCollectionInternal internal) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitTree(FileTreeInternal internal) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitDirectoryTree(DirectoryFileTree tree) {
|
||||
File dir = tree.getDir();
|
||||
PatternSet patterns = tree.getPatterns();
|
||||
cppProject.addSourceFolder(new SourceFolderImpl(dir, new FilePatternSetImpl(patterns.getIncludes(), patterns.getExcludes())));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static File findCppCompilerExecutable(CppBinary cppBinary) {
|
||||
NativeToolChain toolChain = cppBinary.getToolChain();
|
||||
String exeName;
|
||||
if (toolChain instanceof Gcc) {
|
||||
exeName = "g++";
|
||||
}
|
||||
else if (toolChain instanceof Clang) {
|
||||
exeName = "clang++";
|
||||
}
|
||||
else {
|
||||
return null;
|
||||
}
|
||||
ToolSearchPath toolSearchPath = new ToolSearchPath(OperatingSystem.current());
|
||||
CommandLineToolSearchResult searchResult = toolSearchPath.locate(ToolType.CPP_COMPILER, exeName);
|
||||
return searchResult.isAvailable() ? searchResult.getTool() : null;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public ErrorMessageBuilder getErrorMessageBuilder(@NotNull Project project, @NotNull Exception e) {
|
||||
return ErrorMessageBuilder.create(
|
||||
project, e, "C++ project import errors"
|
||||
).withDescription("Unable to import C++ project");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package org.jetbrains.plugins.gradle.nativeplatform.tooling.model;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author Vladislav.Soroka
|
||||
*/
|
||||
public interface CompilerDetails extends Serializable {
|
||||
String getCompileTaskName();
|
||||
|
||||
Set<File> getIncludePath();
|
||||
|
||||
Set<File> getSystemIncludes();
|
||||
|
||||
File getExecutable();
|
||||
|
||||
File getWorkingDir();
|
||||
|
||||
List<String> getArgs();
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package org.jetbrains.plugins.gradle.nativeplatform.tooling.model;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author Vladislav.Soroka
|
||||
*/
|
||||
public interface CppBinary extends Serializable {
|
||||
/**
|
||||
* Returns the base name of this component. This is used by Gradle to calculate output file names.
|
||||
*/
|
||||
String getBaseName();
|
||||
|
||||
/**
|
||||
* Returns the binary variant name, e.g. Debug, Release etc.
|
||||
*/
|
||||
String getVariantName();
|
||||
|
||||
Set<File> getSources();
|
||||
|
||||
CompilerDetails getCompilerDetails();
|
||||
|
||||
Set<File> getCompileIncludePath();
|
||||
|
||||
File getCompilerExecutable();
|
||||
|
||||
List<String> getCompilerArgs();
|
||||
|
||||
LinkerDetails getLinkerDetails();
|
||||
|
||||
File getOutputFile();
|
||||
|
||||
TargetType getTargetType();
|
||||
|
||||
enum TargetType {
|
||||
EXECUTABLE,
|
||||
STATIC_LIBRARY,
|
||||
SHARED_LIBRARY
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package org.jetbrains.plugins.gradle.nativeplatform.tooling.model;
|
||||
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author Vladislav.Soroka
|
||||
*/
|
||||
public interface CppProject extends Serializable {
|
||||
Set<SourceFolder> getSourceFolders();
|
||||
|
||||
Set<CppBinary> getBinaries();
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package org.jetbrains.plugins.gradle.nativeplatform.tooling.model;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author Vladislav.Soroka
|
||||
*/
|
||||
public interface LinkerDetails extends Serializable {
|
||||
File getOutputFile();
|
||||
|
||||
String getLinkTaskName();
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package org.jetbrains.plugins.gradle.nativeplatform.tooling.model;
|
||||
|
||||
import org.jetbrains.plugins.gradle.model.FilePatternSet;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author Vladislav.Soroka
|
||||
*/
|
||||
public interface SourceFolder extends Serializable {
|
||||
File getBaseDir();
|
||||
|
||||
FilePatternSet getPatterns();
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package org.jetbrains.plugins.gradle.nativeplatform.tooling.model.impl;
|
||||
|
||||
import org.jetbrains.plugins.gradle.nativeplatform.tooling.model.CompilerDetails;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author Vladislav.Soroka
|
||||
*/
|
||||
public class CompilerDetailsImpl implements CompilerDetails {
|
||||
|
||||
private final Set<File> myIncludePath;
|
||||
private final Set<File> mySystemIncludes;
|
||||
private final String myCompileTaskName;
|
||||
private final File myExecutable;
|
||||
private final File myWorkingDir;
|
||||
private final List<String> myArgs;
|
||||
|
||||
public CompilerDetailsImpl(String compileTaskName,
|
||||
File executable,
|
||||
File workingDir,
|
||||
List<String> args,
|
||||
Set<File> includePath,
|
||||
Set<File> systemIncludes) {
|
||||
myCompileTaskName = compileTaskName;
|
||||
myExecutable = executable;
|
||||
myWorkingDir = workingDir;
|
||||
myArgs = args;
|
||||
myIncludePath = new LinkedHashSet<File>(includePath);
|
||||
mySystemIncludes = new LinkedHashSet<File>(systemIncludes);
|
||||
}
|
||||
|
||||
public CompilerDetailsImpl(CompilerDetails details) {
|
||||
this(details.getCompileTaskName(), details.getExecutable(), details.getWorkingDir(), details.getArgs(),
|
||||
details.getIncludePath(), details.getSystemIncludes());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCompileTaskName() {
|
||||
return myCompileTaskName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<File> getIncludePath() {
|
||||
return Collections.unmodifiableSet(myIncludePath);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<File> getSystemIncludes() {
|
||||
return Collections.unmodifiableSet(mySystemIncludes);
|
||||
}
|
||||
|
||||
@Override
|
||||
public File getExecutable() {
|
||||
return myExecutable;
|
||||
}
|
||||
|
||||
@Override
|
||||
public File getWorkingDir() {
|
||||
return myWorkingDir;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getArgs() {
|
||||
return Collections.unmodifiableList(myArgs);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package org.jetbrains.plugins.gradle.nativeplatform.tooling.model.impl;
|
||||
|
||||
import org.jetbrains.plugins.gradle.nativeplatform.tooling.model.CompilerDetails;
|
||||
import org.jetbrains.plugins.gradle.nativeplatform.tooling.model.CppBinary;
|
||||
import org.jetbrains.plugins.gradle.nativeplatform.tooling.model.LinkerDetails;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @author Vladislav.Soroka
|
||||
*/
|
||||
public class CppBinaryImpl implements CppBinary {
|
||||
private final String myBaseName;
|
||||
private final String myVariantName;
|
||||
private final Set<File> mySources;
|
||||
private final CompilerDetails myCompilerDetails;
|
||||
private final LinkerDetails myLinkerDetails;
|
||||
private final TargetType myTargetType;
|
||||
|
||||
public CppBinaryImpl(String baseName, String variantName,
|
||||
Collection<File> sources,
|
||||
CompilerDetails compilerDetails,
|
||||
LinkerDetails linkerDetails,
|
||||
TargetType targetType) {
|
||||
myBaseName = baseName;
|
||||
myVariantName = variantName;
|
||||
mySources = new LinkedHashSet<File>(sources);
|
||||
myCompilerDetails = compilerDetails;
|
||||
myLinkerDetails = linkerDetails;
|
||||
myTargetType = targetType;
|
||||
}
|
||||
|
||||
public CppBinaryImpl(CppBinary binary) {
|
||||
this(binary.getBaseName(), binary.getVariantName(), binary.getSources(),
|
||||
new CompilerDetailsImpl(binary.getCompilerDetails()), new LinkerDetailsImpl(binary.getLinkerDetails()), binary.getTargetType());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getBaseName() {
|
||||
return myBaseName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getVariantName() {
|
||||
return myVariantName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<File> getSources() {
|
||||
return Collections.unmodifiableSet(mySources);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompilerDetails getCompilerDetails() {
|
||||
return myCompilerDetails;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<File> getCompileIncludePath() {
|
||||
return myCompilerDetails.getIncludePath();
|
||||
}
|
||||
|
||||
@Override
|
||||
public File getCompilerExecutable() {
|
||||
return myCompilerDetails.getExecutable();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getCompilerArgs() {
|
||||
return myCompilerDetails.getArgs();
|
||||
}
|
||||
|
||||
@Override
|
||||
public LinkerDetails getLinkerDetails() {
|
||||
return myLinkerDetails;
|
||||
}
|
||||
|
||||
@Override
|
||||
public File getOutputFile() {
|
||||
return myLinkerDetails.getOutputFile();
|
||||
}
|
||||
|
||||
@Override
|
||||
public TargetType getTargetType() {
|
||||
return myTargetType;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package org.jetbrains.plugins.gradle.nativeplatform.tooling.model.impl;
|
||||
|
||||
import org.jetbrains.plugins.gradle.nativeplatform.tooling.model.CppBinary;
|
||||
import org.jetbrains.plugins.gradle.nativeplatform.tooling.model.CppProject;
|
||||
import org.jetbrains.plugins.gradle.nativeplatform.tooling.model.SourceFolder;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author Vladislav.Soroka
|
||||
*/
|
||||
public class CppProjectImpl implements CppProject {
|
||||
|
||||
private final Set<SourceFolder> mySourceFolders = new LinkedHashSet<SourceFolder>();
|
||||
private final Set<CppBinary> binaries = new LinkedHashSet<CppBinary>();
|
||||
|
||||
public CppProjectImpl() {
|
||||
}
|
||||
|
||||
public CppProjectImpl(CppProject cppProject) {
|
||||
for (CppBinary binary : cppProject.getBinaries()) {
|
||||
addBinary(new CppBinaryImpl(binary));
|
||||
}
|
||||
for (SourceFolder sourceFolder : cppProject.getSourceFolders()) {
|
||||
addSourceFolder(new SourceFolderImpl(sourceFolder));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<SourceFolder> getSourceFolders() {
|
||||
return Collections.unmodifiableSet(mySourceFolders);
|
||||
}
|
||||
|
||||
public void addSourceFolder(SourceFolder folder) {
|
||||
mySourceFolders.add(folder);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<CppBinary> getBinaries() {
|
||||
return Collections.unmodifiableSet(binaries);
|
||||
}
|
||||
|
||||
public void addBinary(CppBinary binary) {
|
||||
binaries.add(binary);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package org.jetbrains.plugins.gradle.nativeplatform.tooling.model.impl;
|
||||
|
||||
import org.jetbrains.plugins.gradle.nativeplatform.tooling.model.LinkerDetails;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
/**
|
||||
* @author Vladislav.Soroka
|
||||
*/
|
||||
public class LinkerDetailsImpl implements LinkerDetails {
|
||||
private final String myLinkTaskName;
|
||||
private final File myOutputFile;
|
||||
|
||||
public LinkerDetailsImpl(String linkTaskName, File outputFile) {
|
||||
myLinkTaskName = linkTaskName;
|
||||
myOutputFile = outputFile;
|
||||
}
|
||||
|
||||
public LinkerDetailsImpl(LinkerDetails details) {
|
||||
this(details.getLinkTaskName(), details.getOutputFile());
|
||||
}
|
||||
|
||||
@Override
|
||||
public File getOutputFile() {
|
||||
return myOutputFile;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getLinkTaskName() {
|
||||
return myLinkTaskName;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package org.jetbrains.plugins.gradle.nativeplatform.tooling.model.impl;
|
||||
|
||||
import org.jetbrains.plugins.gradle.model.FilePatternSet;
|
||||
import org.jetbrains.plugins.gradle.model.FilePatternSetImpl;
|
||||
import org.jetbrains.plugins.gradle.nativeplatform.tooling.model.SourceFolder;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
/**
|
||||
* @author Vladislav.Soroka
|
||||
*/
|
||||
public class SourceFolderImpl implements SourceFolder {
|
||||
private final File myBaseDir;
|
||||
private final FilePatternSet myPatterns;
|
||||
|
||||
public SourceFolderImpl(File dir, FilePatternSet patterns) {
|
||||
myBaseDir = dir;
|
||||
myPatterns = patterns;
|
||||
}
|
||||
|
||||
public SourceFolderImpl(SourceFolder folder) {
|
||||
this(folder.getBaseDir(), folder.getPatterns() != null
|
||||
? new FilePatternSetImpl(folder.getPatterns().getIncludes(), folder.getPatterns().getExcludes()) : null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public File getBaseDir() {
|
||||
return myBaseDir;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FilePatternSet getPatterns() {
|
||||
return myPatterns;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
SourceFolderImpl folder = (SourceFolderImpl)o;
|
||||
|
||||
if (myBaseDir != null ? !myBaseDir.equals(folder.myBaseDir) : folder.myBaseDir != null) return false;
|
||||
if (myPatterns != null ? !myPatterns.equals(folder.myPatterns) : folder.myPatterns != null) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = myBaseDir != null ? myBaseDir.hashCode() : 0;
|
||||
result = 31 * result + (myPatterns != null ? myPatterns.hashCode() : 0);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -21,6 +21,9 @@
|
||||
</description>
|
||||
|
||||
<depends>com.intellij.modules.lang</depends>
|
||||
<xi:include href="/META-INF/ExternalBuildSystemsSupport.xml" xpointer="xpointer(/idea-plugin/*)">
|
||||
<xi:fallback/>
|
||||
</xi:include>
|
||||
<xi:include href="/META-INF/gradle-java-integration.xml" xpointer="xpointer(/idea-plugin/*)">
|
||||
<xi:fallback/>
|
||||
</xi:include>
|
||||
|
||||
@@ -22,6 +22,10 @@ import com.intellij.execution.configurations.SearchScopeProvider;
|
||||
import com.intellij.execution.configurations.SimpleJavaParameters;
|
||||
import com.intellij.execution.testframework.sm.runner.SMTRunnerConsoleProperties;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.extensions.ExtensionPoint;
|
||||
import com.intellij.openapi.extensions.ExtensionPointListener;
|
||||
import com.intellij.openapi.extensions.Extensions;
|
||||
import com.intellij.openapi.extensions.impl.ExtensionPointImpl;
|
||||
import com.intellij.openapi.externalSystem.ExternalSystemAutoImportAware;
|
||||
import com.intellij.openapi.externalSystem.ExternalSystemConfigurableAware;
|
||||
import com.intellij.openapi.externalSystem.ExternalSystemManager;
|
||||
@@ -60,6 +64,7 @@ import com.intellij.psi.search.GlobalSearchScope;
|
||||
import com.intellij.util.Function;
|
||||
import com.intellij.util.PathUtil;
|
||||
import com.intellij.util.PathsList;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.containers.ContainerUtilRt;
|
||||
import com.intellij.util.messages.MessageBusConnection;
|
||||
import icons.GradleIcons;
|
||||
@@ -82,6 +87,7 @@ import javax.swing.*;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
import static com.intellij.openapi.util.io.FileUtil.pathsEqual;
|
||||
|
||||
@@ -111,7 +117,33 @@ public class GradleManager
|
||||
@Override
|
||||
protected List<GradleProjectResolverExtension> compute() {
|
||||
List<GradleProjectResolverExtension> result = ContainerUtilRt.newArrayList();
|
||||
Collections.addAll(result, GradleProjectResolverExtension.EP_NAME.getExtensions());
|
||||
|
||||
// It's possible usecase when 'java' subsystem dependent plugins bundled with the non-java IDE using fat plugin distribution.
|
||||
// This approach can lead to unwanted/incompatible extensions to be loaded.
|
||||
// The workaround extensionsFilter should be removed when the IntelliJ java subsystem will become a regular plugin
|
||||
// or those plugins will be fixed using the optional plugin dependency on 'org.jetbrains.plugins.gradle.java'
|
||||
boolean isJavaIde = ExternalSystemApiUtil.isJavaCompatibleIde();
|
||||
if(!isJavaIde) {
|
||||
ExtensionPoint<GradleProjectResolverExtension> point =
|
||||
Extensions.getRootArea().getExtensionPoint(GradleProjectResolverExtension.EP_NAME);
|
||||
if(point instanceof ExtensionPointImpl) {
|
||||
((ExtensionPointImpl<GradleProjectResolverExtension>)point).removeUnloadableExtensions();
|
||||
}
|
||||
}
|
||||
Set<String> javaIdeDependentExtensions = ContainerUtil.set(
|
||||
"org.jetbrains.kotlin.idea.configuration.KotlinGradleProjectResolverExtension",
|
||||
"org.jetbrains.kotlin.kapt.idea.KaptProjectResolverExtension",
|
||||
"org.jetbrains.kotlin.allopen.ide.AllOpenProjectResolverExtension",
|
||||
"org.jetbrains.kotlin.noarg.ide.NoArgProjectResolverExtension",
|
||||
"org.jetbrains.kotlin.samWithReceiver.ide.SamWithReceiverProjectResolverExtension"
|
||||
);
|
||||
Predicate<GradleProjectResolverExtension> extensionsFilter = ext ->
|
||||
isJavaIde || !javaIdeDependentExtensions.contains(ext.getClass().getName());
|
||||
|
||||
Arrays.stream(GradleProjectResolverExtension.EP_NAME.getExtensions())
|
||||
.filter(extensionsFilter)
|
||||
.forEach(result::add);
|
||||
|
||||
ExternalSystemApiUtil.orderAwareSort(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
+12
-2
@@ -218,7 +218,12 @@ public class GradleProjectResolver implements ExternalSystemProjectResolver<Grad
|
||||
|
||||
if(!resolverCtx.isPreviewMode()){
|
||||
// register classes of extra gradle project models required for extensions (e.g. com.android.builder.model.AndroidProject)
|
||||
projectImportAction.addExtraProjectModelClasses(resolverExtension.getExtraProjectModelClasses());
|
||||
try {
|
||||
projectImportAction.addExtraProjectModelClasses(resolverExtension.getExtraProjectModelClasses());
|
||||
}
|
||||
catch (Throwable t) {
|
||||
LOG.warn(t);
|
||||
}
|
||||
}
|
||||
|
||||
if (importCustomizer == null || importCustomizer.useExtraJvmArgs()) {
|
||||
@@ -232,7 +237,12 @@ public class GradleProjectResolver implements ExternalSystemProjectResolver<Grad
|
||||
// collect extra command-line arguments
|
||||
executionSettings.withArguments(resolverExtension.getExtraCommandLineArgs());
|
||||
// collect tooling extensions classes
|
||||
toolingExtensionClasses.addAll(resolverExtension.getToolingExtensionsClasses());
|
||||
try {
|
||||
toolingExtensionClasses.addAll(resolverExtension.getToolingExtensionsClasses());
|
||||
}
|
||||
catch (Throwable t) {
|
||||
LOG.warn(t);
|
||||
}
|
||||
}
|
||||
|
||||
BuildActionExecuter<ProjectImportAction.AllModels> buildActionExecutor = resolverCtx.getConnection().action(projectImportAction);
|
||||
|
||||
+10
@@ -190,6 +190,16 @@ public class ExternalProjectSerializer {
|
||||
}
|
||||
);
|
||||
|
||||
myKryo.register(
|
||||
FilePatternSetImpl.class,
|
||||
new FieldSerializer<FilePatternSetImpl>(myKryo, FilePatternSetImpl.class) {
|
||||
@Override
|
||||
protected FilePatternSetImpl create(Kryo kryo, Input input, Class<FilePatternSetImpl> type) {
|
||||
return new FilePatternSetImpl(new LinkedHashSet<>(), new LinkedHashSet<>());
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
myKryo.register(LinkedHashSet.class, new CollectionSerializer() {
|
||||
@Override
|
||||
protected Collection create(Kryo kryo, Input input, Class<Collection> type) {
|
||||
|
||||
@@ -3,6 +3,7 @@ package org.jetbrains.plugins.gradle.settings;
|
||||
|
||||
import com.intellij.openapi.externalSystem.service.execution.ExternalSystemJdkUtil;
|
||||
import com.intellij.openapi.externalSystem.settings.ExternalProjectSettings;
|
||||
import com.intellij.openapi.externalSystem.util.ExternalSystemApiUtil;
|
||||
import com.intellij.util.SmartList;
|
||||
import com.intellij.util.ThreeState;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
@@ -25,7 +26,7 @@ public class GradleProjectSettings extends ExternalProjectSettings {
|
||||
@Nullable private String myGradleJvm = ExternalSystemJdkUtil.USE_PROJECT_JDK;
|
||||
@Nullable private DistributionType distributionType;
|
||||
private boolean disableWrapperSourceDistributionNotification;
|
||||
private boolean resolveModulePerSourceSet = true;
|
||||
private boolean resolveModulePerSourceSet = ExternalSystemApiUtil.isJavaCompatibleIde();
|
||||
@Nullable private CompositeBuild myCompositeBuild;
|
||||
|
||||
private ThreeState storeProjectFilesExternally = ThreeState.NO;
|
||||
|
||||
+3
@@ -57,6 +57,9 @@ public interface ExternalSourceDirectorySet extends Serializable {
|
||||
@NotNull
|
||||
Set<String> getIncludes();
|
||||
|
||||
@NotNull
|
||||
FilePatternSet getPatterns();
|
||||
|
||||
@NotNull
|
||||
List<ExternalFilter> getFilters();
|
||||
}
|
||||
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package org.jetbrains.plugins.gradle.model;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author Vladislav.Soroka
|
||||
*/
|
||||
public interface FilePatternSet extends Serializable {
|
||||
Set<String> getIncludes();
|
||||
Set<String> getExcludes();
|
||||
}
|
||||
+21
-17
@@ -33,10 +33,7 @@ public class DefaultExternalSourceDirectorySet implements ExternalSourceDirector
|
||||
private Set<File> mySrcDirs;
|
||||
private File myOutputDir;
|
||||
private final List<File> myGradleOutputDirs;
|
||||
@NotNull
|
||||
private Set<String> myExcludes;
|
||||
@NotNull
|
||||
private Set<String> myIncludes;
|
||||
private final FilePatternSet myPatterns;
|
||||
@NotNull
|
||||
private List<ExternalFilter> myFilters;
|
||||
|
||||
@@ -44,10 +41,9 @@ public class DefaultExternalSourceDirectorySet implements ExternalSourceDirector
|
||||
|
||||
public DefaultExternalSourceDirectorySet() {
|
||||
mySrcDirs = new HashSet<File>();
|
||||
myExcludes = new HashSet<String>();
|
||||
myIncludes = new HashSet<String>();
|
||||
myFilters = new ArrayList<ExternalFilter>();
|
||||
myGradleOutputDirs = new ArrayList<File>();
|
||||
myPatterns = new FilePatternSetImpl(new LinkedHashSet<String>(), new LinkedHashSet<String>());
|
||||
}
|
||||
|
||||
public DefaultExternalSourceDirectorySet(ExternalSourceDirectorySet sourceDirectorySet) {
|
||||
@@ -57,8 +53,8 @@ public class DefaultExternalSourceDirectorySet implements ExternalSourceDirector
|
||||
myOutputDir = sourceDirectorySet.getOutputDir();
|
||||
myGradleOutputDirs.addAll(sourceDirectorySet.getGradleOutputDirs());
|
||||
|
||||
myExcludes = new HashSet<String>(sourceDirectorySet.getExcludes());
|
||||
myIncludes = new HashSet<String>(sourceDirectorySet.getIncludes());
|
||||
myPatterns.getIncludes().addAll(sourceDirectorySet.getPatterns().getIncludes());
|
||||
myPatterns.getExcludes().addAll(sourceDirectorySet.getPatterns().getExcludes());
|
||||
for (ExternalFilter filter : sourceDirectorySet.getFilters()) {
|
||||
myFilters.add(new DefaultExternalFilter(filter));
|
||||
}
|
||||
@@ -117,28 +113,36 @@ public class DefaultExternalSourceDirectorySet implements ExternalSourceDirector
|
||||
return myInheritedCompilerOutput;
|
||||
}
|
||||
|
||||
public void setInheritedCompilerOutput(boolean inheritedCompilerOutput) {
|
||||
myInheritedCompilerOutput = inheritedCompilerOutput;
|
||||
@NotNull
|
||||
@Override
|
||||
public Set<String> getExcludes() {
|
||||
return myPatterns.getExcludes();
|
||||
}
|
||||
|
||||
public void setExcludes(Set<String> excludes) {
|
||||
myPatterns.getExcludes().clear();
|
||||
myPatterns.getExcludes().addAll(excludes);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Set<String> getIncludes() {
|
||||
return myIncludes;
|
||||
return myPatterns.getIncludes();
|
||||
}
|
||||
|
||||
public void setIncludes(@NotNull Set<String> includes) {
|
||||
myIncludes = includes;
|
||||
public void setIncludes(Set<String> includes) {
|
||||
myPatterns.getIncludes().clear();
|
||||
myPatterns.getIncludes().addAll(includes);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Set<String> getExcludes() {
|
||||
return myExcludes;
|
||||
public FilePatternSet getPatterns() {
|
||||
return myPatterns;
|
||||
}
|
||||
|
||||
public void setExcludes(@NotNull Set<String> excludes) {
|
||||
myExcludes = excludes;
|
||||
public void setInheritedCompilerOutput(boolean inheritedCompilerOutput) {
|
||||
myInheritedCompilerOutput = inheritedCompilerOutput;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
+47
@@ -0,0 +1,47 @@
|
||||
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package org.jetbrains.plugins.gradle.model;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author Vladislav.Soroka
|
||||
*/
|
||||
public class FilePatternSetImpl implements FilePatternSet {
|
||||
private final Set<String> includes;
|
||||
private final Set<String> excludes;
|
||||
|
||||
public FilePatternSetImpl(Set<String> includes, Set<String> excludes) {
|
||||
this.includes = includes;
|
||||
this.excludes = excludes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<String> getIncludes() {
|
||||
return includes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<String> getExcludes() {
|
||||
return excludes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
FilePatternSetImpl set = (FilePatternSetImpl)o;
|
||||
|
||||
if (includes != null ? !includes.equals(set.includes) : set.includes != null) return false;
|
||||
if (excludes != null ? !excludes.equals(set.excludes) : set.excludes != null) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = includes != null ? includes.hashCode() : 0;
|
||||
result = 31 * result + (excludes != null ? excludes.hashCode() : 0);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user