Maven: extract maven support to the separate module
This commit is contained in:
Generated
+1
@@ -49,6 +49,7 @@
|
||||
<element id="module-output" name="resolution" />
|
||||
<element id="module-output" name="idea-ultimate" />
|
||||
<element id="module-output" name="formatter" />
|
||||
<element id="module-output" name="idea-maven" />
|
||||
</element>
|
||||
<element id="library" level="project" name="javax.inject" />
|
||||
<element id="directory" name="jps">
|
||||
|
||||
Generated
+1
-1
@@ -49,7 +49,7 @@
|
||||
<component name="ProjectResources">
|
||||
<default-html-doctype>http://www.w3.org/1999/xhtml</default-html-doctype>
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_6" assert-keyword="true" jdk-15="true" project-jdk-name="1.6" project-jdk-type="JavaSDK">
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_6" default="false" assert-keyword="true" jdk-15="true" project-jdk-name="1.6" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/out" />
|
||||
</component>
|
||||
<component name="SuppressABINotification">
|
||||
|
||||
Generated
+1
@@ -45,6 +45,7 @@
|
||||
<module fileurl="file://$PROJECT_DIR$/idea/idea-core/idea-core.iml" filepath="$PROJECT_DIR$/idea/idea-core/idea-core.iml" group="ide" />
|
||||
<module fileurl="file://$PROJECT_DIR$/idea/idea-jps-common/idea-jps-common.iml" filepath="$PROJECT_DIR$/idea/idea-jps-common/idea-jps-common.iml" group="ide" />
|
||||
<module fileurl="file://$PROJECT_DIR$/idea/idea-live-templates/idea-live-templates.iml" filepath="$PROJECT_DIR$/idea/idea-live-templates/idea-live-templates.iml" group="ide" />
|
||||
<module fileurl="file://$PROJECT_DIR$/idea/idea-maven/idea-maven.iml" filepath="$PROJECT_DIR$/idea/idea-maven/idea-maven.iml" group="ide" />
|
||||
<module fileurl="file://$PROJECT_DIR$/idea/idea-repl/idea-repl.iml" filepath="$PROJECT_DIR$/idea/idea-repl/idea-repl.iml" group="ide" />
|
||||
<module fileurl="file://$PROJECT_DIR$/idea-runner/idea-runner.iml" filepath="$PROJECT_DIR$/idea-runner/idea-runner.iml" group="ide" />
|
||||
<module fileurl="file://$PROJECT_DIR$/idea/idea-test-framework/idea-test-framework.iml" filepath="$PROJECT_DIR$/idea/idea-test-framework/idea-test-framework.iml" group="ide" />
|
||||
|
||||
@@ -37,6 +37,7 @@
|
||||
<orderEntry type="module" module-name="build-common" scope="TEST" />
|
||||
<orderEntry type="module" module-name="plugins-tests" scope="TEST" />
|
||||
<orderEntry type="module" module-name="idea-android" scope="TEST" />
|
||||
<orderEntry type="module" module-name="idea-maven" scope="TEST" />
|
||||
<orderEntry type="module" module-name="uast-kotlin" scope="TEST" />
|
||||
</component>
|
||||
</module>
|
||||
@@ -57,7 +57,7 @@ import org.jetbrains.kotlin.idea.completion.test.handlers.AbstractKeywordComplet
|
||||
import org.jetbrains.kotlin.idea.completion.test.handlers.AbstractSmartCompletionHandlerTest
|
||||
import org.jetbrains.kotlin.idea.completion.test.weighers.AbstractBasicCompletionWeigherTest
|
||||
import org.jetbrains.kotlin.idea.completion.test.weighers.AbstractSmartCompletionWeigherTest
|
||||
import org.jetbrains.kotlin.idea.configuration.AbstractConfigureProjectByChangingFileTest
|
||||
import org.jetbrains.kotlin.idea.configuration.AbstractMavenConfigureProjectByChangingFileTest
|
||||
import org.jetbrains.kotlin.idea.conversion.copy.AbstractJavaToKotlinCopyPasteConversionTest
|
||||
import org.jetbrains.kotlin.idea.coverage.AbstractKotlinCoverageOutputFilesTest
|
||||
import org.jetbrains.kotlin.idea.debugger.AbstractBeforeExtractFunctionInsertionTest
|
||||
@@ -491,10 +491,6 @@ fun main(args: Array<String>) {
|
||||
model("inspections", pattern = "^(inspections\\.test)$", singleClass = true)
|
||||
}
|
||||
|
||||
testClass<AbstractKotlinMavenInspectionTest> {
|
||||
model("maven-inspections", pattern = "^([\\w\\-]+).xml$", singleClass = true)
|
||||
}
|
||||
|
||||
testClass<AbstractHierarchyTest>() {
|
||||
model("hierarchy/class/type", extension = null, recursive = false, testMethod = "doTypeClassHierarchyTest")
|
||||
model("hierarchy/class/super", extension = null, recursive = false, testMethod = "doSuperClassHierarchyTest")
|
||||
@@ -600,10 +596,8 @@ fun main(args: Array<String>) {
|
||||
model("multiFileInspections", extension = "test", singleClass = true)
|
||||
}
|
||||
|
||||
testClass<AbstractConfigureProjectByChangingFileTest>() {
|
||||
testClass<org.jetbrains.kotlin.idea.configuration.AbstractGradleConfigureProjectByChangingFileTest>() {
|
||||
model("configuration/gradle", pattern = """(\w+)_before\.gradle$""", testMethod = "doTestGradle")
|
||||
model("configuration/maven", extension = null, recursive = false, testMethod = "doTestWithMaven")
|
||||
model("configuration/js-maven", extension = null, recursive = false, testMethod = "doTestWithJSMaven")
|
||||
}
|
||||
|
||||
testClass<AbstractFormatterTest>() {
|
||||
@@ -800,6 +794,17 @@ fun main(args: Array<String>) {
|
||||
}
|
||||
}
|
||||
|
||||
testGroup("idea/idea-maven/test", "idea/idea-maven/testData") {
|
||||
testClass<AbstractMavenConfigureProjectByChangingFileTest>() {
|
||||
model("configurator/jvm", extension = null, recursive = false, testMethod = "doTestWithMaven")
|
||||
model("configurator/js", extension = null, recursive = false, testMethod = "doTestWithJSMaven")
|
||||
}
|
||||
|
||||
testClass<AbstractKotlinMavenInspectionTest> {
|
||||
model("maven-inspections", pattern = "^([\\w\\-]+).xml$", singleClass = true)
|
||||
}
|
||||
}
|
||||
|
||||
testGroup("idea/tests", "compiler/testData") {
|
||||
testClass<AbstractResolveByStubTest>() {
|
||||
model("loadJava/compiledKotlin")
|
||||
|
||||
+2
-1
@@ -18,8 +18,9 @@ package org.jetbrains.kotlin.android.configure;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.kotlin.idea.configuration.AbstractConfigureProjectByChangingFileTest;
|
||||
import org.jetbrains.kotlin.idea.configuration.AbstractGradleConfigureProjectByChangingFileTest;
|
||||
|
||||
public abstract class AbstractConfigureProjectTest extends AbstractConfigureProjectByChangingFileTest {
|
||||
public abstract class AbstractConfigureProjectTest extends AbstractGradleConfigureProjectByChangingFileTest {
|
||||
public void doTestAndroidGradle(@NotNull String path) throws Exception {
|
||||
doTest(path, path.replace("before", "after"), new KotlinAndroidGradleModuleConfigurator());
|
||||
}
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/test" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/resources" type="java-resource" />
|
||||
</content>
|
||||
<orderEntry type="jdk" jdkName="1.8" jdkType="JavaSDK" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="library" name="idea-full" level="project" />
|
||||
<orderEntry type="module" module-name="idea" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="maven" level="project" />
|
||||
<orderEntry type="module" module-name="frontend" />
|
||||
<orderEntry type="library" name="kotlin-runtime" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="kotlin-test" level="project" />
|
||||
<orderEntry type="module" module-name="js.frontend" />
|
||||
<orderEntry type="module" module-name="util.runtime" />
|
||||
<orderEntry type="module" module-name="frontend.java" />
|
||||
<orderEntry type="library" scope="TEST" name="kotlin-reflect" level="project" />
|
||||
<orderEntry type="module" module-name="tests-common" scope="TEST" />
|
||||
</component>
|
||||
</module>
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
<html>
|
||||
<body>
|
||||
This intention moves source directory from execution's configuration to build the corresponding source directory tag
|
||||
</body>
|
||||
</html>
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
<html>
|
||||
<body>
|
||||
This intention moves source directory from build source directory tag
|
||||
to the corresponding kotlin-maven-plugin execution's configuration
|
||||
</body>
|
||||
</html>
|
||||
+1
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2015 JetBrains s.r.o.
|
||||
* Copyright 2010-2016 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -42,7 +42,6 @@ import org.jetbrains.idea.maven.model.MavenPlugin;
|
||||
import org.jetbrains.idea.maven.project.MavenProject;
|
||||
import org.jetbrains.idea.maven.project.MavenProjectsManager;
|
||||
import org.jetbrains.idea.maven.utils.MavenArtifactScope;
|
||||
import org.jetbrains.idea.maven.utils.MavenUtil;
|
||||
import org.jetbrains.kotlin.idea.KotlinPluginUtil;
|
||||
import org.jetbrains.kotlin.idea.framework.ui.ConfigureDialogWithModulesAndVersion;
|
||||
|
||||
+5
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2015 JetBrains s.r.o.
|
||||
* Copyright 2010-2016 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -16,7 +16,10 @@
|
||||
|
||||
package org.jetbrains.kotlin.idea.configuration
|
||||
|
||||
import com.intellij.openapi.components.*
|
||||
import com.intellij.openapi.components.PersistentStateComponent
|
||||
import com.intellij.openapi.components.State
|
||||
import com.intellij.openapi.components.Storage
|
||||
import com.intellij.openapi.components.StoragePathMacros
|
||||
import com.intellij.openapi.externalSystem.service.project.IdeModifiableModelsProvider
|
||||
import com.intellij.openapi.module.Module
|
||||
import org.jdom.Element
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Copyright 2010-2016 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.idea.configuration
|
||||
|
||||
import com.intellij.openapi.module.Module
|
||||
import com.intellij.psi.PsiFile
|
||||
import org.jetbrains.idea.maven.model.MavenConstants
|
||||
|
||||
abstract class AbstractMavenConfigureProjectByChangingFileTest : AbstractConfigureProjectByChangingFileTest<KotlinMavenConfigurator>() {
|
||||
fun doTestWithMaven(path: String) {
|
||||
val pathWithFile = path + "/" + MavenConstants.POM_XML
|
||||
doTest(pathWithFile, pathWithFile.replace("pom", "pom_after"), KotlinJavaMavenConfigurator())
|
||||
}
|
||||
|
||||
fun doTestWithJSMaven(path: String) {
|
||||
val pathWithFile = path + "/" + MavenConstants.POM_XML
|
||||
doTest(pathWithFile, pathWithFile.replace("pom", "pom_after"), KotlinJavascriptMavenConfigurator())
|
||||
}
|
||||
|
||||
override fun runConfigurator(module: Module, file: PsiFile, configurator: KotlinMavenConfigurator, version: String, collector: NotificationMessageCollector) {
|
||||
configurator.changePomFile(module, file, version, collector)
|
||||
}
|
||||
}
|
||||
+5
-4
@@ -62,9 +62,12 @@ abstract class AbstractKotlinMavenInspectionTest : MavenImportingTestCase() {
|
||||
mkJavaFile()
|
||||
}
|
||||
|
||||
val inspectionClassName = "<!--\\s*inspection:\\s*([\\S]+)\\s-->".toRegex().find(pomText)?.groups?.get(1)?.value ?: KotlinMavenPluginPhaseInspection::class.qualifiedName !!
|
||||
val inspectionClass = Class.forName(inspectionClassName)
|
||||
|
||||
val matcher = "<!--\\s*problem:\\s*on\\s*([^,]+),\\s*title\\s*(.+)\\s*-->".toRegex()
|
||||
val expected = pomText.lines().mapNotNull { matcher.find(it) }.map { SimplifiedProblemDescription(it.groups[2]!!.value.trim(), it.groups[1]!!.value.trim()) }
|
||||
val actual = runInspection<KotlinMavenPluginPhaseInspection>().sortedBy { it.first.text }
|
||||
val actual = runInspection(inspectionClass).sortedBy { it.first.text }
|
||||
|
||||
assertEquals(expected.sortedBy { it.text }, actual.map { it.first })
|
||||
|
||||
@@ -147,9 +150,7 @@ abstract class AbstractKotlinMavenInspectionTest : MavenImportingTestCase() {
|
||||
assertTrue(FileTypeIndex.containsFileOfType(JavaFileType.INSTANCE, myProject.allModules().single().moduleScope))
|
||||
}
|
||||
|
||||
private inline fun <reified T : LocalInspectionTool> runInspection(): List<Pair<SimplifiedProblemDescription, ProblemDescriptorBase>> {
|
||||
val inspectionClass = T::class.java
|
||||
|
||||
private fun runInspection(inspectionClass: Class<*>): List<Pair<SimplifiedProblemDescription, ProblemDescriptorBase>> {
|
||||
val toolWrapper = LocalInspectionToolWrapper(inspectionClass.newInstance() as LocalInspectionTool)
|
||||
|
||||
val scope = AnalysisScope(myProject)
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2015 JetBrains s.r.o.
|
||||
* Copyright 2010-2016 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
+8
-8
@@ -27,47 +27,47 @@ import java.util.regex.Pattern;
|
||||
|
||||
/** This class is generated by {@link org.jetbrains.kotlin.generators.tests.TestsPackage}. DO NOT MODIFY MANUALLY */
|
||||
@SuppressWarnings("all")
|
||||
@TestMetadata("idea/testData/maven-inspections")
|
||||
@TestMetadata("idea/idea-maven/testData/maven-inspections")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public class KotlinMavenInspectionTestGenerated extends AbstractKotlinMavenInspectionTest {
|
||||
public void testAllFilesPresentInMaven_inspections() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentInSingleGeneratedClass(this.getClass(), new File("idea/testData/maven-inspections"), Pattern.compile("^([\\w\\-]+).xml$"));
|
||||
KotlinTestUtils.assertAllTestsPresentInSingleGeneratedClass(this.getClass(), new File("idea/idea-maven/testData/maven-inspections"), Pattern.compile("^([\\w\\-]+).xml$"));
|
||||
}
|
||||
|
||||
@TestMetadata("bothCompileAndTestCompileInTheSameExecution.xml")
|
||||
public void testBothCompileAndTestCompileInTheSameExecution() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/maven-inspections/bothCompileAndTestCompileInTheSameExecution.xml");
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/idea-maven/testData/maven-inspections/bothCompileAndTestCompileInTheSameExecution.xml");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("dependencyWithNoExecution.xml")
|
||||
public void testDependencyWithNoExecution() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/maven-inspections/dependencyWithNoExecution.xml");
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/idea-maven/testData/maven-inspections/dependencyWithNoExecution.xml");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("missingDependencies.xml")
|
||||
public void testMissingDependencies() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/maven-inspections/missingDependencies.xml");
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/idea-maven/testData/maven-inspections/missingDependencies.xml");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("noExecutions.xml")
|
||||
public void testNoExecutions() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/maven-inspections/noExecutions.xml");
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/idea-maven/testData/maven-inspections/noExecutions.xml");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("wrongJsExecution.xml")
|
||||
public void testWrongJsExecution() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/maven-inspections/wrongJsExecution.xml");
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/idea-maven/testData/maven-inspections/wrongJsExecution.xml");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("wrongPhaseExecution.xml")
|
||||
public void testWrongPhaseExecution() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/maven-inspections/wrongPhaseExecution.xml");
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/idea-maven/testData/maven-inspections/wrongPhaseExecution.xml");
|
||||
doTest(fileName);
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2015 JetBrains s.r.o.
|
||||
* Copyright 2010-2016 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
+1
-1
@@ -33,7 +33,6 @@
|
||||
<orderEntry type="library" scope="PROVIDED" name="properties" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="java-i18n" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="gradle-and-groovy-plugin" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="maven" level="project" />
|
||||
<orderEntry type="module" module-name="eval4j" />
|
||||
<orderEntry type="module" module-name="idea-core" />
|
||||
<orderEntry type="module" module-name="idea-analysis" exported="" />
|
||||
@@ -53,5 +52,6 @@
|
||||
<orderEntry type="library" scope="TEST" name="kotlin-test" level="project" />
|
||||
<orderEntry type="module" module-name="lint-idea" scope="PROVIDED" />
|
||||
<orderEntry type="module" module-name="formatter" />
|
||||
<orderEntry type="module" module-name="idea-maven" />
|
||||
</component>
|
||||
</module>
|
||||
+15
-26
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2015 JetBrains s.r.o.
|
||||
* Copyright 2010-2016 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -16,51 +16,40 @@
|
||||
|
||||
package org.jetbrains.kotlin.idea.configuration;
|
||||
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.testFramework.LightCodeInsightTestCase;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.idea.maven.model.MavenConstants;
|
||||
import org.jetbrains.kotlin.test.InTextDirectivesUtils;
|
||||
import org.jetbrains.kotlin.test.KotlinTestUtils;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.GroovyFile;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public abstract class AbstractConfigureProjectByChangingFileTest extends LightCodeInsightTestCase {
|
||||
public abstract class AbstractConfigureProjectByChangingFileTest<C extends KotlinProjectConfigurator> extends LightCodeInsightTestCase {
|
||||
private static final String DEFAULT_VERSION = "default_version";
|
||||
|
||||
public void doTestWithMaven(@NotNull String path) throws Exception {
|
||||
String pathWithFile = path + "/" + MavenConstants.POM_XML;
|
||||
doTest(pathWithFile, pathWithFile.replace("pom", "pom_after"), new KotlinJavaMavenConfigurator());
|
||||
}
|
||||
|
||||
public void doTestWithJSMaven(@NotNull String path) throws Exception {
|
||||
String pathWithFile = path + "/" + MavenConstants.POM_XML;
|
||||
doTest(pathWithFile, pathWithFile.replace("pom", "pom_after"), new KotlinJavascriptMavenConfigurator());
|
||||
}
|
||||
|
||||
public void doTestGradle(@NotNull String path) throws Exception {
|
||||
doTest(path, path.replace("before", "after"), new KotlinGradleModuleConfigurator());
|
||||
}
|
||||
|
||||
protected void doTest(@NotNull String beforeFile, @NotNull String afterFile, @NotNull KotlinProjectConfigurator configurator) throws Exception {
|
||||
protected void doTest(@NotNull String beforeFile, @NotNull String afterFile, @NotNull C configurator) throws Exception {
|
||||
configureByFile(beforeFile);
|
||||
|
||||
String versionFromFile = InTextDirectivesUtils.findStringWithPrefixes(getFile().getText(), "// VERSION:");
|
||||
String version = versionFromFile != null ? versionFromFile : DEFAULT_VERSION;
|
||||
|
||||
NotificationMessageCollector collector = NotificationMessageCollectorKt.createConfigureKotlinNotificationCollector(getProject());
|
||||
if (configurator instanceof KotlinWithGradleConfigurator) {
|
||||
((KotlinWithGradleConfigurator) configurator).changeGradleFile((GroovyFile) getFile(), true, version, collector);
|
||||
((KotlinWithGradleConfigurator) configurator).changeGradleFile((GroovyFile) getFile(), false, version, collector);
|
||||
}
|
||||
else if (configurator instanceof KotlinMavenConfigurator) {
|
||||
((KotlinMavenConfigurator) configurator).changePomFile(getModule(), getFile(), version, collector);
|
||||
}
|
||||
|
||||
runConfigurator(getModule(), getFile(), configurator, version, collector);
|
||||
|
||||
collector.showNotification();
|
||||
|
||||
KotlinTestUtils.assertEqualsToFile(new File(afterFile), getFile().getText().replace(version, "$VERSION$"));
|
||||
}
|
||||
|
||||
protected abstract void runConfigurator(
|
||||
Module module, @NotNull PsiFile file,
|
||||
@NotNull C configurator,
|
||||
@NotNull String version,
|
||||
@NotNull NotificationMessageCollector collector
|
||||
);
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
protected String getTestDataPath() {
|
||||
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Copyright 2010-2016 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.idea.configuration
|
||||
|
||||
import com.intellij.openapi.module.Module
|
||||
import com.intellij.psi.PsiFile
|
||||
import org.jetbrains.plugins.groovy.lang.psi.GroovyFile
|
||||
|
||||
abstract class AbstractGradleConfigureProjectByChangingFileTest : AbstractConfigureProjectByChangingFileTest<KotlinWithGradleConfigurator>() {
|
||||
|
||||
fun doTestGradle(path: String) {
|
||||
doTest(path, path.replace("before", "after"), KotlinGradleModuleConfigurator())
|
||||
}
|
||||
|
||||
override fun runConfigurator(module: Module, file: PsiFile, configurator: KotlinWithGradleConfigurator, version: String, collector: NotificationMessageCollector) {
|
||||
if (file !is GroovyFile) {
|
||||
fail("file $file is not a GroovyFile")
|
||||
return
|
||||
}
|
||||
|
||||
configurator.changeGradleFile(file, true, version, collector)
|
||||
configurator.changeGradleFile(file, false, version, collector)
|
||||
}
|
||||
}
|
||||
+55
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
* Copyright 2010-2016 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.idea.configuration;
|
||||
|
||||
import com.intellij.testFramework.TestDataPath;
|
||||
import org.jetbrains.kotlin.test.JUnit3RunnerWithInners;
|
||||
import org.jetbrains.kotlin.test.KotlinTestUtils;
|
||||
import org.jetbrains.kotlin.test.TestMetadata;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/** This class is generated by {@link org.jetbrains.kotlin.generators.tests.TestsPackage}. DO NOT MODIFY MANUALLY */
|
||||
@SuppressWarnings("all")
|
||||
@TestMetadata("idea/testData/configuration/gradle")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public class GradleConfigureProjectByChangingFileTestGenerated extends AbstractGradleConfigureProjectByChangingFileTest {
|
||||
public void testAllFilesPresentInGradle() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/configuration/gradle"), Pattern.compile("(\\w+)_before\\.gradle$"), true);
|
||||
}
|
||||
|
||||
@TestMetadata("default_before.gradle")
|
||||
public void testDefault() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/configuration/gradle/default_before.gradle");
|
||||
doTestGradle(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("missedLibrary_before.gradle")
|
||||
public void testMissedLibrary() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/configuration/gradle/missedLibrary_before.gradle");
|
||||
doTestGradle(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("plugin_present_before.gradle")
|
||||
public void testPlugin_present() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/configuration/gradle/plugin_present_before.gradle");
|
||||
doTestGradle(fileName);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user