mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-03-22 15:19:59 +07:00
GradleProjectStartupActivity - use ProjectActivity
GitOrigin-RevId: 2853d3a34dc5849840f033bf2fe5f1a726945f45
This commit is contained in:
committed by
intellij-monorepo-bot
parent
c08fdc0832
commit
92723627f0
@@ -1,18 +1,4 @@
|
||||
/*
|
||||
* Copyright 2000-2013 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.
|
||||
*/
|
||||
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package org.jetbrains.plugins.gradle.integrations.maven;
|
||||
|
||||
import com.intellij.openapi.externalSystem.model.task.ExternalSystemTaskId;
|
||||
@@ -27,15 +13,15 @@ import org.jetbrains.plugins.gradle.util.GradleConstants;
|
||||
*
|
||||
* @author Vladislav.Soroka
|
||||
*/
|
||||
public class GradleMavenProjectImportNotificationListener extends ExternalSystemTaskNotificationListenerAdapter {
|
||||
|
||||
final class GradleMavenProjectImportNotificationListener extends ExternalSystemTaskNotificationListenerAdapter {
|
||||
@Override
|
||||
public void onSuccess(@NotNull ExternalSystemTaskId id) {
|
||||
if (GradleConstants.SYSTEM_ID.getId().equals(id.getProjectSystemId().getId())
|
||||
&& id.getType() == ExternalSystemTaskType.RESOLVE_PROJECT) {
|
||||
final Project project = id.findProject();
|
||||
if (project == null) return;
|
||||
new ImportMavenRepositoriesTask(project).schedule();
|
||||
Project project = id.findProject();
|
||||
if (project != null) {
|
||||
new ImportMavenRepositoriesTask(project).schedule();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,16 +1,23 @@
|
||||
// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package org.jetbrains.plugins.gradle.integrations.maven;
|
||||
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package org.jetbrains.plugins.gradle.integrations.maven
|
||||
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.startup.StartupActivity;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import com.intellij.openapi.application.ApplicationManager
|
||||
import com.intellij.openapi.application.ReadConstraint
|
||||
import com.intellij.openapi.application.constrainedReadAction
|
||||
import com.intellij.openapi.extensions.ExtensionNotApplicableException
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.openapi.startup.ProjectActivity
|
||||
|
||||
/**
|
||||
* @author Vladislav.Soroka
|
||||
*/
|
||||
final class GradleProjectStartupActivity implements StartupActivity {
|
||||
@Override
|
||||
public void runActivity(@NotNull final Project project) {
|
||||
new ImportMavenRepositoriesTask(project).schedule();
|
||||
private class GradleProjectStartupActivity : ProjectActivity {
|
||||
init {
|
||||
if (ApplicationManager.getApplication().isUnitTestMode) {
|
||||
throw ExtensionNotApplicableException.create()
|
||||
}
|
||||
}
|
||||
|
||||
override suspend fun execute(project: Project) {
|
||||
constrainedReadAction(ReadConstraint.inSmartMode(project)) {
|
||||
ImportMavenRepositoriesTask(project).performTask()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2000-2019 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-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package org.jetbrains.plugins.gradle.integrations.maven;
|
||||
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
@@ -39,8 +39,7 @@ import java.util.stream.Collectors;
|
||||
/**
|
||||
* @author Vladislav.Soroka
|
||||
*/
|
||||
class ImportMavenRepositoriesTask {
|
||||
|
||||
final class ImportMavenRepositoriesTask {
|
||||
@NotNull
|
||||
private final MavenRemoteRepository mavenCentralRemoteRepository;
|
||||
|
||||
@@ -52,11 +51,13 @@ class ImportMavenRepositoriesTask {
|
||||
}
|
||||
|
||||
void schedule() {
|
||||
if (ApplicationManager.getApplication().isUnitTestMode()) return;
|
||||
if (ApplicationManager.getApplication().isUnitTestMode()) {
|
||||
return;
|
||||
}
|
||||
ReadAction.nonBlocking(this::performTask).inSmartMode(myProject).submit(AppExecutorUtil.getAppExecutorService());
|
||||
}
|
||||
|
||||
private void performTask() {
|
||||
void performTask() {
|
||||
final LocalFileSystem localFileSystem = LocalFileSystem.getInstance();
|
||||
final List<PsiFile> psiFileList = new ArrayList<>();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user