mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-142527 project dependencies are not loaded for a Gradle project with Gradle JPI plugin (Jenkins Plugins)
This commit is contained in:
+12
-8
@@ -1,5 +1,6 @@
|
||||
package com.intellij.openapi.externalSystem.service.project.manage;
|
||||
|
||||
import com.intellij.ide.highlighter.ArchiveFileType;
|
||||
import com.intellij.openapi.components.ServiceManager;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.externalSystem.model.DataNode;
|
||||
@@ -164,16 +165,19 @@ public class LibraryDataService implements ProjectDataServiceEx<LibraryData, Lib
|
||||
}
|
||||
}
|
||||
else {
|
||||
VirtualFile jarRoot = JarFileSystem.getInstance().getJarRootForLocalFile(virtualFile);
|
||||
if (jarRoot == null) {
|
||||
LOG.warn(String.format(
|
||||
"Can't parse contents of the JAR file at path '%s' for the library '%s''", file.getAbsolutePath(), libraryName
|
||||
));
|
||||
continue;
|
||||
VirtualFile root = virtualFile;
|
||||
if (virtualFile.getFileType() instanceof ArchiveFileType) {
|
||||
root = JarFileSystem.getInstance().getJarRootForLocalFile(virtualFile);
|
||||
if (root == null) {
|
||||
LOG.warn(String.format(
|
||||
"Can't parse contents of the JAR file at path '%s' for the library '%s''", file.getAbsolutePath(), libraryName
|
||||
));
|
||||
continue;
|
||||
}
|
||||
}
|
||||
final VirtualFile[] files = model.getFiles(entry.getKey());
|
||||
if (!ArrayUtil.contains(jarRoot, files)) {
|
||||
model.addRoot(jarRoot, entry.getKey());
|
||||
if (!ArrayUtil.contains(root, files)) {
|
||||
model.addRoot(root, entry.getKey());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+6
@@ -35,6 +35,7 @@ import com.intellij.openapi.roots.DependencyScope;
|
||||
import com.intellij.openapi.util.KeyValue;
|
||||
import com.intellij.openapi.util.io.FileFilters;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.util.io.FileUtilRt;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.pom.java.LanguageLevel;
|
||||
import com.intellij.util.*;
|
||||
@@ -747,6 +748,11 @@ public class BaseGradleProjectResolverExtension implements GradleProjectResolver
|
||||
}
|
||||
}
|
||||
|
||||
// add packaging type to distinguish different artifact dependencies with same groupId:artifactId:version
|
||||
if(!FileUtilRt.extensionEquals(binaryPath.getPath(), "jar")) {
|
||||
libraryName += (":" + FileUtilRt.getExtension(binaryPath.getPath()));
|
||||
}
|
||||
|
||||
final LibraryData library = new LibraryData(GradleConstants.SYSTEM_ID, libraryName, unresolved);
|
||||
if (!unresolved) {
|
||||
library.addPath(LibraryPathType.BINARY, binaryPath.getAbsolutePath());
|
||||
|
||||
+5
@@ -66,6 +66,7 @@ public class GradleDependenciesImportingTest extends GradleImportingTestCase {
|
||||
public void testDependencyWithDifferentClassifiers() throws Exception {
|
||||
final VirtualFile depJar = createProjectJarSubFile("lib/dep/dep/1.0/dep-1.0.jar");
|
||||
final VirtualFile depTestsJar = createProjectJarSubFile("lib/dep/dep/1.0/dep-1.0-tests.jar");
|
||||
final VirtualFile depNonJar = createProjectSubFile("lib/dep/dep/1.0/dep-1.0.someExt");
|
||||
|
||||
importProject(
|
||||
"allprojects {\n" +
|
||||
@@ -82,6 +83,7 @@ public class GradleDependenciesImportingTest extends GradleImportingTestCase {
|
||||
"dependencies {\n" +
|
||||
" compile 'dep:dep:1.0'\n" +
|
||||
" testCompile 'dep:dep:1.0:tests'\n" +
|
||||
" runtime 'dep:dep:1.0@someExt'\n" +
|
||||
"}"
|
||||
);
|
||||
|
||||
@@ -92,5 +94,8 @@ public class GradleDependenciesImportingTest extends GradleImportingTestCase {
|
||||
|
||||
assertModuleLibDep("project", "Gradle: dep:dep:1.0:tests", depTestsJar.getUrl());
|
||||
assertModuleLibDepScope("project", "Gradle: dep:dep:1.0:tests", DependencyScope.TEST);
|
||||
|
||||
assertModuleLibDep("project", "Gradle: dep:dep:1.0:someExt", depNonJar.getUrl());
|
||||
assertModuleLibDepScope("project", "Gradle: dep:dep:1.0:someExt", DependencyScope.RUNTIME);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user