Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Fix]: Fixes IDEA not detecting preRun tasks #221

Merged
merged 1 commit into from
Jun 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,9 @@ private void configureIDEAIDEConventions(Project project, IDE ideConventions) {
if (ideaConventions.getShouldUsePostSyncTask().get())
return;

if (!ideManagementExtension.isIdeaSyncing())
return;

final StartParameter startParameter = innerProject.getGradle().getStartParameter();
final List<TaskExecutionRequest> taskRequests = new ArrayList<>(startParameter.getTaskRequests());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public IdeManagementExtension(Project project) {
// IntelliJ remembers to run the task post-sync even if the import fails. That will cause
// situations where import errors (i.e. dependency resolution errors) will be masked by
// the failed idePostSync task, since it was never created in that particular import.
if (isIdeaImport()) {
if (isIdeaAttached() && isIdeaSyncing()) {
getOrCreateIdeImportTask();
}
}
Expand All @@ -62,7 +62,18 @@ public IdeManagementExtension(Project project) {
*
* @return whether this is an IntelliJ-based invocation
*/
public boolean isIdeaImport() {
public boolean isIdeaAttached() {
return Boolean.getBoolean("idea.active");
}

/**
* Get whether Gradle is being invoked through IntelliJ IDEA.
*
* <p>This can be through a project import, or a task execution.</p>
*
* @return whether this is an IntelliJ-based invocation
*/
marchermans marked this conversation as resolved.
Show resolved Hide resolved
public boolean isIdeaSyncing() {
return Boolean.getBoolean("idea.sync.active");
}

Expand Down Expand Up @@ -105,7 +116,7 @@ public static boolean isVscodePluginImport(final Project project)
* @return {@code true} if an IDE import is ongoing, {@code false} otherwise
*/
public boolean isIdeImportInProgress() {
return isIdeaImport() || isEclipseImport() || isVscodeImport();
return isIdeaAttached() || isEclipseImport() || isVscodeImport();
}

/**
Expand Down Expand Up @@ -191,7 +202,7 @@ public void apply(final IdeImportAction toPerform) {
public void onIdea(final IdeaIdeImportAction toPerform) {
//When the IDEA plugin is available, configure it
project.getPlugins().withType(IdeaExtPlugin.class, plugin -> {
if (!isIdeaImport()) {
if (!isIdeaAttached()) {
//No IDEA import even though the plugin is available, so don't configure it.
return;
}
Expand Down Expand Up @@ -261,7 +272,7 @@ private void onCommonEclipse(final BiConsumer<Project, EclipseModel> toPerform)
* @param toPerform the actions to perform
*/
public void onGradle(final GradleIdeImportAction toPerform) {
if (!isEclipseImport() && !isIdeaImport() && !isVscodeImport()) {
if (!isEclipseImport() && !isIdeaAttached() && !isVscodeImport()) {
toPerform.gradle(project);
}
}
Expand Down
Loading