mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
make external annotations download optional for Gradle and Maven imports IDEA-199964 IDEA-132487 IDEA-200003
This commit is contained in:
@@ -16,6 +16,7 @@ import com.intellij.openapi.progress.runBackgroundableTask
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.openapi.roots.libraries.Library
|
||||
import com.intellij.openapi.util.registry.Registry
|
||||
import org.jetbrains.plugins.gradle.settings.GradleSettings
|
||||
|
||||
@Order(value = ExternalSystemConstants.UNORDERED)
|
||||
class ExternalAnnotationsDataService: AbstractProjectDataService<LibraryData, Library>() {
|
||||
@@ -29,6 +30,18 @@ class ExternalAnnotationsDataService: AbstractProjectDataService<LibraryData, Li
|
||||
return
|
||||
}
|
||||
|
||||
projectData?.apply {
|
||||
GradleSettings
|
||||
.getInstance(project)
|
||||
.linkedProjectsSettings
|
||||
.find { settings -> settings.externalProjectPath == linkedExternalProjectPath }
|
||||
?.let {
|
||||
if (!it.isResolveExternalAnnotations) {
|
||||
return@onSuccessImport
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
val resolver = ExternalAnnotationsArtifactsResolver.EP_NAME.extensionList.firstOrNull() ?: return
|
||||
val totalSize = imported.size.toDouble()
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ import com.intellij.openapi.externalSystem.model.project.ProjectData
|
||||
import com.intellij.openapi.externalSystem.service.project.IdeModelsProvider
|
||||
import com.intellij.openapi.externalSystem.service.project.manage.AbstractProjectDataService
|
||||
import com.intellij.openapi.project.Project
|
||||
import org.jetbrains.plugins.gradle.settings.GradleSettings
|
||||
|
||||
class MavenRepositoriesDataService: AbstractProjectDataService<MavenRepositoryData, Void>() {
|
||||
override fun getTargetDataKey(): Key<MavenRepositoryData> = MavenRepositoryData.KEY
|
||||
@@ -19,6 +20,19 @@ class MavenRepositoriesDataService: AbstractProjectDataService<MavenRepositoryDa
|
||||
project: Project,
|
||||
modelsProvider: IdeModelsProvider) {
|
||||
|
||||
projectData?.apply {
|
||||
GradleSettings
|
||||
.getInstance(project)
|
||||
.linkedProjectsSettings
|
||||
.find { settings -> settings.externalProjectPath == linkedExternalProjectPath }
|
||||
?.let {
|
||||
if (!it.isResolveExternalAnnotations) {
|
||||
return@onSuccessImport
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
val repositoriesConfiguration = RemoteRepositoriesConfiguration.getInstance(project)
|
||||
|
||||
val repositories = linkedSetOf<RemoteRepositoryDescription>().apply {
|
||||
|
||||
@@ -14,6 +14,7 @@ gradle.settings.text.jvm.path=Gradle JVM:
|
||||
gradle.settings.text.service.dir.path=Service directory path:
|
||||
gradle.settings.text.vm.options=Gradle VM options:
|
||||
gradle.settings.text.offline_work=Offline work
|
||||
gradle.settings.text.resolve.external.annotations=Resolve external annotations
|
||||
gradle.settings.title.service.dir.path=Select gradle service directory to use
|
||||
gradle.generic.text.error.jar.not.found=Gradle JARs location is unknown
|
||||
|
||||
|
||||
+30
@@ -114,10 +114,15 @@ public class IdeaGradleProjectSettingsControlBuilder implements GradleProjectSet
|
||||
@Nullable
|
||||
private JBRadioButton myUseBundledDistributionButton;
|
||||
private boolean dropUseBundledDistributionButton;
|
||||
|
||||
@Nullable
|
||||
private JBCheckBox myResolveModulePerSourceSetCheckBox;
|
||||
private boolean dropResolveModulePerSourceSetCheckBox;
|
||||
|
||||
@Nullable
|
||||
private JBCheckBox myResolveExternalAnnotationsCheckBox;
|
||||
private boolean dropResolveExternalAnnotationsCheckBox;
|
||||
|
||||
@Nullable
|
||||
private JBCheckBox myStoreExternallyCheckBox;
|
||||
private boolean dropStoreExternallyCheckBox;
|
||||
@@ -204,6 +209,11 @@ public class IdeaGradleProjectSettingsControlBuilder implements GradleProjectSet
|
||||
return this;
|
||||
}
|
||||
|
||||
public IdeaGradleProjectSettingsControlBuilder dropResolveExternalAnnotationsCheckBox() {
|
||||
dropResolveExternalAnnotationsCheckBox = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
public IdeaGradleProjectSettingsControlBuilder dropStoreExternallyCheckBox() {
|
||||
dropStoreExternallyCheckBox = true;
|
||||
return this;
|
||||
@@ -257,6 +267,11 @@ public class IdeaGradleProjectSettingsControlBuilder implements GradleProjectSet
|
||||
content.add(myResolveModulePerSourceSetCheckBox, ExternalSystemUiUtil.getFillLineConstraints(indentLevel));
|
||||
}
|
||||
|
||||
if (!dropResolveExternalAnnotationsCheckBox) {
|
||||
myResolveExternalAnnotationsCheckBox = new JBCheckBox(GradleBundle.message("gradle.settings.text.resolve.external.annotations"));
|
||||
content.add(myResolveExternalAnnotationsCheckBox, ExternalSystemUiUtil.getFillLineConstraints(indentLevel));
|
||||
}
|
||||
|
||||
if (!dropStoreExternallyCheckBox && myInitialSettings.getStoreProjectFilesExternally() != ThreeState.UNSURE) {
|
||||
myStoreExternallyCheckBox = new JBCheckBox("Store generated project files externally");
|
||||
content.add(myStoreExternallyCheckBox, ExternalSystemUiUtil.getFillLineConstraints(indentLevel));
|
||||
@@ -416,6 +431,10 @@ public class IdeaGradleProjectSettingsControlBuilder implements GradleProjectSet
|
||||
settings.setResolveModulePerSourceSet(myResolveModulePerSourceSetCheckBox.isSelected());
|
||||
}
|
||||
|
||||
if (myResolveExternalAnnotationsCheckBox != null) {
|
||||
settings.setResolveExternalAnnotations(myResolveExternalAnnotationsCheckBox.isSelected());
|
||||
}
|
||||
|
||||
if (myStoreExternallyCheckBox != null) {
|
||||
settings.setStoreProjectFilesExternally(ThreeState.fromBoolean(myStoreExternallyCheckBox.isSelected()));
|
||||
}
|
||||
@@ -460,6 +479,11 @@ public class IdeaGradleProjectSettingsControlBuilder implements GradleProjectSet
|
||||
return true;
|
||||
}
|
||||
|
||||
if (myResolveExternalAnnotationsCheckBox != null &&
|
||||
(myResolveExternalAnnotationsCheckBox.isSelected() != myInitialSettings.isResolveExternalAnnotations())) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (myStoreExternallyCheckBox != null && ThreeState.fromBoolean(myStoreExternallyCheckBox.isSelected()) != myInitialSettings.getStoreProjectFilesExternally()) {
|
||||
return true;
|
||||
}
|
||||
@@ -496,6 +520,9 @@ public class IdeaGradleProjectSettingsControlBuilder implements GradleProjectSet
|
||||
if (myResolveModulePerSourceSetCheckBox != null) {
|
||||
myResolveModulePerSourceSetCheckBox.setSelected(settings.isResolveModulePerSourceSet());
|
||||
}
|
||||
if (myResolveExternalAnnotationsCheckBox != null) {
|
||||
myResolveExternalAnnotationsCheckBox.setSelected(settings.isResolveExternalAnnotations());
|
||||
}
|
||||
if (myStoreExternallyCheckBox != null) {
|
||||
myStoreExternallyCheckBox.setSelected(settings.getStoreProjectFilesExternally() == ThreeState.YES);
|
||||
}
|
||||
@@ -530,6 +557,9 @@ public class IdeaGradleProjectSettingsControlBuilder implements GradleProjectSet
|
||||
if (myResolveModulePerSourceSetCheckBox != null) {
|
||||
myResolveModulePerSourceSetCheckBox.setSelected(settings.isResolveModulePerSourceSet());
|
||||
}
|
||||
if (myResolveExternalAnnotationsCheckBox != null) {
|
||||
myResolveExternalAnnotationsCheckBox.setSelected(settings.isResolveExternalAnnotations());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -27,6 +27,7 @@ public class GradleProjectSettings extends ExternalProjectSettings {
|
||||
@Nullable private DistributionType distributionType;
|
||||
private boolean disableWrapperSourceDistributionNotification;
|
||||
private boolean resolveModulePerSourceSet = ExternalSystemApiUtil.isJavaCompatibleIde();
|
||||
private boolean resolveExternalAnnotations;
|
||||
@Nullable private CompositeBuild myCompositeBuild;
|
||||
|
||||
private ThreeState storeProjectFilesExternally = ThreeState.NO;
|
||||
@@ -74,6 +75,14 @@ public class GradleProjectSettings extends ExternalProjectSettings {
|
||||
this.resolveModulePerSourceSet = useIdeModulePerSourceSet;
|
||||
}
|
||||
|
||||
public boolean isResolveExternalAnnotations() {
|
||||
return resolveExternalAnnotations;
|
||||
}
|
||||
|
||||
public void setResolveExternalAnnotations(boolean resolveExternalAnnotations) {
|
||||
this.resolveExternalAnnotations = resolveExternalAnnotations;
|
||||
}
|
||||
|
||||
@OptionTag(tag = "compositeConfiguration", nameAttribute = "")
|
||||
@Nullable
|
||||
public CompositeBuild getCompositeBuild() {
|
||||
@@ -94,6 +103,7 @@ public class GradleProjectSettings extends ExternalProjectSettings {
|
||||
result.distributionType = distributionType;
|
||||
result.disableWrapperSourceDistributionNotification = disableWrapperSourceDistributionNotification;
|
||||
result.resolveModulePerSourceSet = resolveModulePerSourceSet;
|
||||
result.resolveExternalAnnotations = resolveExternalAnnotations;
|
||||
result.myCompositeBuild = myCompositeBuild != null ? myCompositeBuild.copy() : null;
|
||||
return result;
|
||||
}
|
||||
|
||||
+12
-6
@@ -11,16 +11,15 @@ import com.intellij.openapi.progress.runBackgroundableTask
|
||||
import com.intellij.openapi.roots.libraries.Library
|
||||
import com.intellij.openapi.util.registry.Registry
|
||||
import org.jetbrains.idea.maven.model.MavenArtifact
|
||||
import org.jetbrains.idea.maven.project.MavenProject
|
||||
import org.jetbrains.idea.maven.project.MavenProjectChanges
|
||||
import org.jetbrains.idea.maven.project.MavenProjectsProcessorTask
|
||||
import org.jetbrains.idea.maven.project.MavenProjectsTree
|
||||
import org.jetbrains.idea.maven.project.*
|
||||
|
||||
class ExternalAnnotationsImporter : MavenImporter("org.apache.maven.plugins", "maven-compiler-plugin") {
|
||||
|
||||
private val myProcessedLibraries = hashSetOf<MavenArtifact>()
|
||||
|
||||
override fun isApplicable(mavenProject: MavenProject?): Boolean = super.isApplicable(mavenProject) && Registry.`is`("external.system.import.resolve.annotations")
|
||||
override fun isApplicable(mavenProject: MavenProject?): Boolean {
|
||||
return super.isApplicable(mavenProject) && Registry.`is`("external.system.import.resolve.annotations")
|
||||
}
|
||||
override fun processChangedModulesOnly(): Boolean = false
|
||||
|
||||
override fun process(modifiableModelsProvider: IdeModifiableModelsProvider?,
|
||||
@@ -38,9 +37,12 @@ class ExternalAnnotationsImporter : MavenImporter("org.apache.maven.plugins", "m
|
||||
mavenProject: MavenProject?,
|
||||
changes: MavenProjectChanges?,
|
||||
modifiableModelsProvider: IdeModifiableModelsProvider?) {
|
||||
if (module == null || mavenProject == null) {
|
||||
if (module == null
|
||||
|| mavenProject == null
|
||||
|| !MavenProjectsManager.getInstance(module.project).importingSettings.isDownloadAnnotationsAutomatically) {
|
||||
return
|
||||
}
|
||||
|
||||
val repoConfig = RemoteRepositoriesConfiguration.getInstance(module.project)
|
||||
val repositories: MutableCollection<RemoteRepositoryDescription> =
|
||||
hashSetOf<RemoteRepositoryDescription>().apply { addAll(repoConfig.repositories) }
|
||||
@@ -59,6 +61,10 @@ class ExternalAnnotationsImporter : MavenImporter("org.apache.maven.plugins", "m
|
||||
val project = module.project
|
||||
val librariesMap = mutableMapOf<MavenArtifact, Library>()
|
||||
|
||||
if (!MavenProjectsManager.getInstance(project).importingSettings.isDownloadAnnotationsAutomatically) {
|
||||
return
|
||||
}
|
||||
|
||||
mavenProject.dependencies.forEach {
|
||||
val library = modifiableModelsProvider.getLibraryByName(it.libraryName)
|
||||
if (library != null) {
|
||||
|
||||
+12
@@ -50,6 +50,7 @@ public class MavenImportingSettings implements Cloneable {
|
||||
|
||||
private boolean downloadSourcesAutomatically = false;
|
||||
private boolean downloadDocsAutomatically = false;
|
||||
private boolean downloadAnnotationsAutomatically = false;
|
||||
|
||||
private GeneratedSourcesFolder generatedSourcesFolder = GeneratedSourcesFolder.AUTODETECT;
|
||||
|
||||
@@ -187,6 +188,14 @@ public class MavenImportingSettings implements Cloneable {
|
||||
this.downloadDocsAutomatically = value;
|
||||
}
|
||||
|
||||
public boolean isDownloadAnnotationsAutomatically() {
|
||||
return downloadAnnotationsAutomatically;
|
||||
}
|
||||
|
||||
public void setDownloadAnnotationsAutomatically(boolean value) {
|
||||
this.downloadAnnotationsAutomatically = value;
|
||||
}
|
||||
|
||||
@Property
|
||||
@NotNull
|
||||
public GeneratedSourcesFolder getGeneratedSourcesFolder() {
|
||||
@@ -212,6 +221,7 @@ public class MavenImportingSettings implements Cloneable {
|
||||
if (!dependencyTypes.equals(that.dependencyTypes)) return false;
|
||||
if (downloadDocsAutomatically != that.downloadDocsAutomatically) return false;
|
||||
if (downloadSourcesAutomatically != that.downloadSourcesAutomatically) return false;
|
||||
if (downloadAnnotationsAutomatically != that.downloadAnnotationsAutomatically) return false;
|
||||
if (lookForNested != that.lookForNested) return false;
|
||||
if (keepSourceFolders != that.keepSourceFolders) return false;
|
||||
if (excludeTargetFolder != that.excludeTargetFolder) return false;
|
||||
@@ -247,6 +257,8 @@ public class MavenImportingSettings implements Cloneable {
|
||||
result <<= 1;
|
||||
if (downloadDocsAutomatically) result++;
|
||||
result <<= 1;
|
||||
if (downloadAnnotationsAutomatically) result++;
|
||||
result <<= 1;
|
||||
|
||||
result = 31 * result + (updateFoldersOnImportPhase != null ? updateFoldersOnImportPhase.hashCode() : 0);
|
||||
result = 31 * result + dedicatedModuleDir.hashCode();
|
||||
|
||||
+11
-3
@@ -3,7 +3,7 @@
|
||||
<grid id="27dc6" binding="myPanel" layout-manager="GridLayoutManager" row-count="19" column-count="3" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="0" left="0" bottom="0" right="0"/>
|
||||
<constraints>
|
||||
<xy x="20" y="20" width="769" height="588"/>
|
||||
<xy x="20" y="20" width="769" height="603"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
@@ -60,7 +60,7 @@
|
||||
<toolTipText value="Synchronize Maven project model and IDEA project model each time when pom.xml is changed "/>
|
||||
</properties>
|
||||
</component>
|
||||
<grid id="49dc8" layout-manager="GridLayoutManager" row-count="1" column-count="4" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<grid id="49dc8" layout-manager="GridLayoutManager" row-count="1" column-count="5" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="10" left="0" bottom="0" right="0"/>
|
||||
<constraints>
|
||||
<grid row="14" column="0" row-span="1" col-span="2" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
@@ -96,9 +96,17 @@
|
||||
</component>
|
||||
<hspacer id="79b58">
|
||||
<constraints>
|
||||
<grid row="0" column="3" row-span="1" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
<grid row="0" column="4" row-span="1" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
</hspacer>
|
||||
<component id="1a87b" class="com.intellij.ui.components.JBCheckBox" binding="myDownloadAnnotationsCheckBox">
|
||||
<constraints>
|
||||
<grid row="0" column="3" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="0" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="Annotations"/>
|
||||
</properties>
|
||||
</component>
|
||||
</children>
|
||||
</grid>
|
||||
<component id="6d280" class="javax.swing.JCheckBox" binding="myKeepSourceFoldersCheckBox">
|
||||
|
||||
+3
@@ -38,6 +38,7 @@ public class MavenImportingSettingsForm {
|
||||
private JCheckBox myUseMavenOutputCheckBox;
|
||||
private JCheckBox myDownloadSourcesCheckBox;
|
||||
private JCheckBox myDownloadDocsCheckBox;
|
||||
private JCheckBox myDownloadAnnotationsCheckBox;
|
||||
|
||||
private JPanel myAdditionalSettingsPanel;
|
||||
private JComboBox myGeneratedSourcesComboBox;
|
||||
@@ -114,6 +115,7 @@ public class MavenImportingSettingsForm {
|
||||
|
||||
data.setDownloadSourcesAutomatically(myDownloadSourcesCheckBox.isSelected());
|
||||
data.setDownloadDocsAutomatically(myDownloadDocsCheckBox.isSelected());
|
||||
data.setDownloadAnnotationsAutomatically(myDownloadAnnotationsCheckBox.isSelected());
|
||||
|
||||
data.setDependencyTypes(myDependencyTypes.getText());
|
||||
}
|
||||
@@ -145,6 +147,7 @@ public class MavenImportingSettingsForm {
|
||||
|
||||
myDownloadSourcesCheckBox.setSelected(data.isDownloadSourcesAutomatically());
|
||||
myDownloadDocsCheckBox.setSelected(data.isDownloadDocsAutomatically());
|
||||
myDownloadAnnotationsCheckBox.setSelected(data.isDownloadAnnotationsAutomatically());
|
||||
|
||||
myDependencyTypes.setText(data.getDependencyTypes());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user