use of org.gradle.tooling.model.idea.IdeaDependencyScope in project android by JetBrains.
the class JavaModuleDependency method copy.
@Nullable
public static JavaModuleDependency copy(IdeaModuleDependency original) {
IdeaModule module = original.getDependencyModule();
if (module != null && isNotEmpty(module.getName())) {
String scope = null;
IdeaDependencyScope originalScope = original.getScope();
if (originalScope != null) {
scope = originalScope.getScope();
}
return new JavaModuleDependency(module.getName(), scope, original.getExported());
}
return null;
}
use of org.gradle.tooling.model.idea.IdeaDependencyScope in project android by JetBrains.
the class JarLibraryDependencyTest method testCopyWithResolvedDependency.
@Test
public void testCopyWithResolvedDependency() {
FileStub binaryPath = new FileStub("fake.jar", true);
FileStub sourcePath = new FileStub("fake-src.jar", true);
FileStub javadocPath = new FileStub("fake-javadoc.jar", true);
IdeaDependencyScope scope = mock(IdeaDependencyScope.class);
GradleModuleVersion moduleVersion = mock(GradleModuleVersion.class);
when(myOriginalDependency.getFile()).thenReturn(binaryPath);
when(myOriginalDependency.getSource()).thenReturn(sourcePath);
when(myOriginalDependency.getJavadoc()).thenReturn(javadocPath);
when(myOriginalDependency.getScope()).thenReturn(scope);
when(myOriginalDependency.getGradleModuleVersion()).thenReturn(moduleVersion);
when(scope.getScope()).thenReturn("compile");
JarLibraryDependency dependency = JarLibraryDependency.copy(myOriginalDependency);
assertNotNull(dependency);
assertEquals("fake", dependency.getName());
assertEquals("compile", dependency.getScope());
assertSame(binaryPath, dependency.getBinaryPath());
assertSame(sourcePath, dependency.getSourcePath());
assertSame(javadocPath, dependency.getJavadocPath());
assertSame(moduleVersion, dependency.getModuleVersion());
assertTrue(dependency.isResolved());
}
use of org.gradle.tooling.model.idea.IdeaDependencyScope in project android by JetBrains.
the class JarLibraryDependency method copy.
@Nullable
public static JarLibraryDependency copy(@NotNull IdeaSingleEntryLibraryDependency original) {
File binaryPath = original.getFile();
if (binaryPath != null) {
String scope = null;
IdeaDependencyScope originalScope = original.getScope();
if (originalScope != null) {
scope = originalScope.getScope();
}
boolean resolved = isResolved(original);
String name;
if (resolved) {
// Gradle API doesn't provide library name at the moment.
name = binaryPath.isFile() ? getNameWithoutExtension(binaryPath) : sanitizeFileName(binaryPath.getPath());
} else {
name = getUnresolvedDependencyName(original);
if (name == null) {
return null;
}
}
return new JarLibraryDependency(name, binaryPath, original.getSource(), original.getJavadoc(), scope, original.getGradleModuleVersion(), resolved);
}
return null;
}
use of org.gradle.tooling.model.idea.IdeaDependencyScope in project android by JetBrains.
the class JavaModuleDependencyTest method testCopy.
@Test
public void testCopy() {
String moduleName = "lib";
IdeaDependencyScope scope = createMock(IdeaDependencyScope.class);
expect(myOriginalDependency.getDependencyModule()).andStubReturn(myIdeaModule);
expect(myIdeaModule.getName()).andStubReturn(moduleName);
expect(myOriginalDependency.getScope()).andStubReturn(scope);
expect(myOriginalDependency.getExported()).andStubReturn(true);
expect(scope.getScope()).andStubReturn("compile");
replay(myOriginalDependency, myIdeaModule, scope);
JavaModuleDependency copy = JavaModuleDependency.copy(myOriginalDependency);
assertNotNull(copy);
assertEquals(moduleName, copy.getModuleName());
assertSame("compile", copy.getScope());
assertTrue(copy.isExported());
verify(myOriginalDependency, myIdeaModule, scope);
}
Aggregations