use of com.liferay.ide.gradle.core.parser.GradleDependency in project liferay-ide by liferay.
the class GradleParseTests method getAllDependenciesShortFormatAndLongFormat.
@Test
public void getAllDependenciesShortFormatAndLongFormat() throws IOException {
final File inputFile = new File("projects/testParseInput/testDependenciesShortFormatAndLongFormat.gradle");
GradleDependencyUpdater updater = new GradleDependencyUpdater(inputFile);
List<GradleDependency> allDependencies = updater.getAllDependencies();
assertEquals(3, allDependencies.size());
}
use of com.liferay.ide.gradle.core.parser.GradleDependency in project liferay-ide by liferay.
the class GradleParseTests method getAllDependenciesShortFormat.
@Test
public void getAllDependenciesShortFormat() throws IOException {
final File inputFile = new File("projects/testParseInput/testDependenciesShortFormat.gradle");
GradleDependencyUpdater updater = new GradleDependencyUpdater(inputFile);
List<GradleDependency> allDependencies = updater.getAllDependencies();
assertEquals(3, allDependencies.size());
}
use of com.liferay.ide.gradle.core.parser.GradleDependency in project liferay-ide by liferay.
the class GradleProjectBuilder method updateProjectDependency.
@Override
public IStatus updateProjectDependency(IProject project, List<String[]> dependencies) throws CoreException {
if (FileUtil.notExists(_gradleBuildFile)) {
return Status.OK_STATUS;
}
try {
GradleDependencyUpdater updater = new GradleDependencyUpdater(FileUtil.getFile(_gradleBuildFile));
List<GradleDependency> existDependencies = updater.getAllDependencies();
for (String[] dependency : dependencies) {
GradleDependency gd = new GradleDependency(dependency[0], dependency[1], dependency[2]);
if (!existDependencies.contains(gd)) {
updater.insertDependency(gd);
FileUtils.writeLines(_gradleBuildFile.getLocation().toFile(), updater.getGradleFileContents());
GradleUtil.refreshGradleProject(project);
}
}
} catch (IOException ioe) {
return GradleCore.createErrorStatus("Error updating gradle project dependency", ioe);
}
return Status.OK_STATUS;
}
use of com.liferay.ide.gradle.core.parser.GradleDependency in project liferay-ide by liferay.
the class QuickFixGradleDep method _createDepProposal.
private void _createDepProposal(IInvocationContext context, Collection<IJavaCompletionProposal> proposals, ServiceContainer bundle) {
String bundleGroup = bundle.getBundleGroup();
String bundleName = bundle.getBundleName();
String bundleVersion = bundle.getBundleVersion();
proposals.add(new CUCorrectionProposal("Add Gradle Dependence " + bundleName, context.getCompilationUnit(), null, -0) {
@Override
public void apply(IDocument document) {
try {
GradleDependencyUpdater updater = new GradleDependencyUpdater(_gradleFile.getLocation().toFile());
List<GradleDependency> existDependencies = updater.getAllDependencies();
GradleDependency gd = new GradleDependency(bundleGroup, bundleName, bundleVersion);
if (!existDependencies.contains(gd)) {
updater.insertDependency(gd);
File gradleFile = _gradleFile.getLocation().toFile();
Files.write(gradleFile.toPath(), updater.getGradleFileContents(), StandardCharsets.UTF_8);
IResource resource = context.getCompilationUnit().getResource();
IProject project = resource.getProject();
GradleUtil.refreshGradleProject(project);
}
} catch (Exception e) {
GradleCore.logError("Gradle dependence got error", e);
}
}
@Override
public Object getAdditionalProposalInfo(IProgressMonitor monitor) {
return "Add dependenece";
}
@Override
public Image getImage() {
Display display = UIUtil.getActiveShell().getDisplay();
String file = null;
try {
Bundle bundle = GradleUI.getDefault().getBundle();
file = FileLocator.toFileURL(bundle.getEntry("icons/e16/liferay_logo_16.png")).getFile();
} catch (IOException ioe) {
GradleUI.logError(ioe);
}
return new Image(display, file);
}
});
}
use of com.liferay.ide.gradle.core.parser.GradleDependency in project liferay-ide by liferay.
the class GradleParseTests method getAllDependencies.
@Test
public void getAllDependencies() throws IOException {
final File inputFile = new File("projects/testParseInput/testDependencies.gradle");
GradleDependencyUpdater updater = new GradleDependencyUpdater(inputFile);
List<GradleDependency> allDependence = updater.getAllDependencies();
assertEquals(3, allDependence.size());
}
Aggregations