integration tests: ensure maven repository configured

This commit is contained in:
Anna.Kozlova
2018-07-23 19:20:54 +02:00
parent 88410fa83f
commit 2cc2fb05eb
@@ -1,11 +1,13 @@
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.java.execution;
import com.intellij.openapi.application.PathMacros;
import com.intellij.openapi.compiler.CompilerMessage;
import com.intellij.openapi.compiler.CompilerMessageCategory;
import com.intellij.openapi.roots.ModuleRootModificationUtil;
import com.intellij.testFramework.CompilerTester;
import java.io.File;
import java.util.List;
import java.util.stream.Collectors;
@@ -18,6 +20,7 @@ public abstract class AbstractTestFrameworkCompilingIntegrationTest extends Abst
protected void setUp() throws Exception {
super.setUp();
setupModule();
PathMacros.getInstance().setMacro("MAVEN_REPOSITORY", getDefaultMavenRepositoryPath());
myCompilerTester = new CompilerTester(myModule);
List<CompilerMessage> compilerMessages = myCompilerTester.rebuild();
assertEmpty(compilerMessages.stream()
@@ -25,6 +28,11 @@ public abstract class AbstractTestFrameworkCompilingIntegrationTest extends Abst
.collect(Collectors.toSet()));
}
protected String getDefaultMavenRepositoryPath() {
final String root = System.getProperty("user.home", null);
return (root != null ? new File(root, ".m2/repository") : new File(".m2/repository")).getAbsolutePath();
}
protected void setupModule() throws Exception {
ModuleRootModificationUtil.updateModel(myModule,
model -> model.addContentEntry(getTestContentRoot())