Skip to content

Commit

Permalink
try to fix some issues with resolving source roots
Browse files Browse the repository at this point in the history
  • Loading branch information
VISTALL committed Jan 20, 2025
1 parent 2961198 commit 18351d4
Show file tree
Hide file tree
Showing 8 changed files with 321 additions and 240 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@
import org.jetbrains.plugins.gradle.tooling.impl.builder.ModelBuildScriptClasspathBuilderImpl;
import org.jetbrains.plugins.gradle.tooling.impl.internal.init.Init;
import org.jetbrains.plugins.gradle.tooling.model.BuildScriptClasspathModel;
import org.jetbrains.plugins.gradle.tooling.model.ExtIdeaContentRoot;
import org.jetbrains.plugins.gradle.tooling.model.ModuleExtendedModel;
import org.jetbrains.plugins.gradle.tooling.model.ProjectImportAction;
import org.jetbrains.plugins.gradle.util.GradleUtil;
Expand Down Expand Up @@ -231,14 +230,12 @@ public void populateModuleContentRoots(@Nonnull IdeaModule gradleModule, @Nonnul
populateContentRoot(ideContentRoot, ExternalSystemSourceType.SOURCE, gradleContentRoot.getSourceDirectories());
populateContentRoot(ideContentRoot, ExternalSystemSourceType.TEST, gradleContentRoot.getTestDirectories());

if (gradleContentRoot instanceof ExtIdeaContentRoot extIdeaContentRoot) {
populateContentRoot(ideContentRoot, ExternalSystemSourceType.RESOURCE, extIdeaContentRoot.getResourceDirectories());
populateContentRoot(
ideContentRoot,
ExternalSystemSourceType.TEST_RESOURCE,
extIdeaContentRoot.getTestResourceDirectories()
);
}
populateContentRoot(ideContentRoot, ExternalSystemSourceType.RESOURCE, gradleContentRoot.getResourceDirectories());
populateContentRoot(
ideContentRoot,
ExternalSystemSourceType.TEST_RESOURCE,
gradleContentRoot.getTestResourceDirectories()
);

Set<File> excluded = gradleContentRoot.getExcludeDirectories();
if (excluded != null) {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
package org.jetbrains.plugins.gradle.tooling.model;

import org.gradle.tooling.model.DomainObjectSet;
import org.gradle.tooling.model.idea.IdeaContentRoot;

import java.io.File;
import java.io.Serializable;
Expand Down Expand Up @@ -62,7 +63,7 @@ public interface ModuleExtendedModel extends Serializable {
*
* @return content roots
*/
DomainObjectSet<? extends ExtIdeaContentRoot> getContentRoots();
DomainObjectSet<? extends IdeaContentRoot> getContentRoots();

/**
* The build directory.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package org.jetbrains.plugins.gradle.tooling.util;

import org.gradle.util.GradleVersion;

public final class GradleVersionUtil {

private static final GradleVersion currentGradleVersion = GradleVersion.current().getBaseVersion();

public static boolean isCurrentGradleAtLeast(String version) {
return currentGradleVersion.compareTo(GradleVersion.version(version)) >= 0;
}

public static boolean isGradleAtLeast(GradleVersion actualVersion, String version) {
return actualVersion.getBaseVersion().compareTo(GradleVersion.version(version)) >= 0;
}

public static boolean isGradleAtLeast(String actualVersion, String version) {
return isGradleAtLeast(GradleVersion.version(actualVersion), version);
}

public static boolean isCurrentGradleOlderThan(String version) {
return !isCurrentGradleAtLeast(version);
}

public static boolean isGradleOlderThan(GradleVersion actualVersion, String version) {
return !isGradleAtLeast(actualVersion, version);
}

public static boolean isGradleOlderThan(String actualVersion, String version) {
return !isGradleAtLeast(actualVersion, version);
}

/**
* @see GradleVersionUtil#isGradleAtLeast
* @see GradleVersionUtil#isCurrentGradleAtLeast
* @deprecated Gradle version comparisons '>' and '<=' aren't logical.
* Changes can be made only in the specific version and present in the future.
* We always can identify the version where new changes were made.
*/
@Deprecated
@SuppressWarnings("DeprecatedIsStillUsed")
public static boolean isCurrentGradleNewerThan(String version) {
return currentGradleVersion.compareTo(GradleVersion.version(version)) > 0;
}

/**
* @deprecated See {@link GradleVersionUtil#isCurrentGradleNewerThan} for details
*/
@Deprecated
@SuppressWarnings("DeprecatedIsStillUsed")
public static boolean isGradleNewerThan(GradleVersion actualVersion, String version) {
return actualVersion.getBaseVersion().compareTo(GradleVersion.version(version)) > 0;
}

/**
* @deprecated See {@link GradleVersionUtil#isCurrentGradleNewerThan} for details
*/
@Deprecated
@SuppressWarnings("DeprecatedIsStillUsed")
public static boolean isGradleNewerThan(String actualVersion, String version) {
return isGradleNewerThan(GradleVersion.version(actualVersion), version);
}

/**
* @deprecated See {@link GradleVersionUtil#isCurrentGradleNewerThan} for details
*/
@Deprecated
@SuppressWarnings("DeprecatedIsStillUsed")
public static boolean isCurrentGradleOlderOrSameAs(String version) {
return !isCurrentGradleNewerThan(version);
}

/**
* @deprecated See {@link GradleVersionUtil#isCurrentGradleNewerThan} for details
*/
@Deprecated
@SuppressWarnings("DeprecatedIsStillUsed")
public static boolean isGradleOlderOrSameAs(GradleVersion actualVersion, String version) {
return !isGradleNewerThan(actualVersion, version);
}

/**
* @deprecated See {@link GradleVersionUtil#isCurrentGradleNewerThan} for details
*/
@Deprecated
@SuppressWarnings("DeprecatedIsStillUsed")
public static boolean isGradleOlderOrSameAs(String actualVersion, String version) {
return !isGradleNewerThan(actualVersion, version);
}
}
Loading

0 comments on commit 18351d4

Please sign in to comment.