Maven: rebase to master

This commit is contained in:
Sergey Mashkov
2016-04-27 14:56:52 +03:00
parent d9dabeed76
commit e9758099ce
16 changed files with 160 additions and 174 deletions
@@ -34,6 +34,7 @@ import org.jetbrains.idea.maven.dom.model.*
import org.jetbrains.idea.maven.model.MavenId
import org.jetbrains.idea.maven.utils.MavenArtifactScope
import org.jetbrains.jps.model.java.JavaSourceRootType
import org.jetbrains.kotlin.idea.configuration.RepositoryDescription
import org.jetbrains.kotlin.idea.maven.configuration.KotlinMavenConfigurator
import org.jetbrains.kotlin.psi.psiUtil.getChildrenOfType
import java.util.*
@@ -225,12 +226,20 @@ class PomFile(val xmlFile: XmlFile) {
return addRepository(id, name, url, snapshots, releases, { domModel.pluginRepositories.pluginRepositories }, { domModel.pluginRepositories.addPluginRepository() })
}
fun addPluginRepository(description: RepositoryDescription) {
addPluginRepository(description.id, description.name, description.url, description.isSnapshot, true)
}
fun addLibraryRepository(id: String, name: String, url: String, snapshots: Boolean = false, releases: Boolean = true): MavenDomRepository {
ensureRepositories()
return addRepository(id, name, url, snapshots, releases, { domModel.repositories.repositories }, { domModel.repositories.addRepository() })
}
fun addLibraryRepository(description: RepositoryDescription) {
addLibraryRepository(description.id, description.name, description.url, description.isSnapshot, true)
}
private fun addRepository(id: String, name: String, url: String, snapshots: Boolean, releases: Boolean, existing: () -> List<MavenDomRepository>, create: () -> MavenDomRepository): MavenDomRepository {
val repository =
@@ -26,7 +26,7 @@ import org.jetbrains.kotlin.resolve.jvm.platform.JvmPlatform
class KotlinJavaMavenConfigurator : KotlinMavenConfigurator(KotlinJavaMavenConfigurator.STD_LIB_ID, KotlinJavaMavenConfigurator.TEST_LIB_ID, false, KotlinJavaMavenConfigurator.NAME, KotlinJavaMavenConfigurator.PRESENTABLE_TEXT) {
override fun isKotlinModule(module: Module): Boolean {
return hasKotlinRuntimeInScope(module)
return hasKotlinJvmRuntimeInScope(module)
}
override fun isRelevantGoal(goalName: String): Boolean {
@@ -18,15 +18,15 @@ package org.jetbrains.kotlin.idea.maven.configuration
import com.intellij.openapi.module.Module
import org.jetbrains.idea.maven.dom.model.MavenDomPlugin
import org.jetbrains.kotlin.idea.configuration.hasKotlinJsRuntimeInScope
import org.jetbrains.kotlin.idea.maven.PomFile
import org.jetbrains.kotlin.idea.project.ProjectStructureUtil
import org.jetbrains.kotlin.js.resolve.JsPlatform
import org.jetbrains.kotlin.resolve.TargetPlatform
class KotlinJavascriptMavenConfigurator : KotlinMavenConfigurator(KotlinJavascriptMavenConfigurator.STD_LIB_ID, null, false, KotlinJavascriptMavenConfigurator.NAME, KotlinJavascriptMavenConfigurator.PRESENTABLE_TEXT) {
override fun isKotlinModule(module: Module): Boolean {
return ProjectStructureUtil.isJsKotlinModule(module)
return hasKotlinJsRuntimeInScope(module)
}
override fun isRelevantGoal(goalName: String): Boolean {
@@ -35,7 +35,7 @@ class KotlinJavascriptMavenConfigurator : KotlinMavenConfigurator(KotlinJavascri
override fun createExecutions(pomFile: PomFile, kotlinPlugin: MavenDomPlugin, module: Module) {
createExecution(pomFile, kotlinPlugin, PomFile.DefaultPhases.Compile, PomFile.KotlinGoals.Js, module, false)
createExecution(pomFile, kotlinPlugin, PomFile.DefaultPhases.Compile, PomFile.KotlinGoals.TestJs, module, true)
createExecution(pomFile, kotlinPlugin, PomFile.DefaultPhases.TestCompile, PomFile.KotlinGoals.TestJs, module, true)
}
override fun getTargetPlatform(): TargetPlatform {
@@ -36,9 +36,7 @@ import org.jetbrains.idea.maven.model.MavenId
import org.jetbrains.idea.maven.project.MavenProjectsManager
import org.jetbrains.idea.maven.utils.MavenArtifactScope
import org.jetbrains.kotlin.idea.KotlinPluginUtil
import org.jetbrains.kotlin.idea.configuration.KotlinProjectConfigurator
import org.jetbrains.kotlin.idea.configuration.NotificationMessageCollector
import org.jetbrains.kotlin.idea.configuration.createConfigureKotlinNotificationCollector
import org.jetbrains.kotlin.idea.configuration.*
import org.jetbrains.kotlin.idea.framework.ui.ConfigureDialogWithModulesAndVersion
import org.jetbrains.kotlin.idea.maven.PomFile
import org.jetbrains.kotlin.idea.maven.excludeMavenChildrenModules
@@ -123,12 +121,17 @@ abstract class KotlinMavenConfigurator protected constructor(private val stdlibA
pom.addDependency(MavenId(GROUP_ID, testArtifactId, "\${$KOTLIN_VERSION_PROPERTY}"), MavenArtifactScope.TEST, null, false, null)
}
if (addJunit) {
// TODO currently it is always disabled: junit version selection could be shown in the configurator dialog
pom.addDependency(MavenId("junit", "junit", "4.12"), MavenArtifactScope.TEST, null, false, null)
}
if (isSnapshot(version)) {
pom.addLibraryRepository(SNAPSHOT_REPOSITORY_ID, SONATYPE_OSS_REPOSITORY_NAME, SONATYPE_OSS_REPOSITORY_URL, true, false)
pom.addPluginRepository(SNAPSHOT_REPOSITORY_ID, SONATYPE_OSS_REPOSITORY_NAME, SONATYPE_OSS_REPOSITORY_URL, true, false)
pom.addLibraryRepository(SNAPSHOT_REPOSITORY)
pom.addPluginRepository(SNAPSHOT_REPOSITORY)
}
if (isEap(version)) {
pom.addLibraryRepository(EAP_REPOSITORY)
pom.addPluginRepository(EAP_REPOSITORY)
}
val plugin = pom.addPlugin(MavenId(GROUP_ID, MAVEN_PLUGIN_ID, "\${$KOTLIN_VERSION_PROPERTY}"))
@@ -156,9 +159,6 @@ abstract class KotlinMavenConfigurator protected constructor(private val stdlibA
val GROUP_ID = "org.jetbrains.kotlin"
val MAVEN_PLUGIN_ID = "kotlin-maven-plugin"
private val KOTLIN_VERSION_PROPERTY = "kotlin.version"
private val SNAPSHOT_REPOSITORY_ID = "sonatype.oss.snapshots"
private val SONATYPE_OSS_REPOSITORY_NAME = "Sonatype OSS Snapshot Repository"
private val SONATYPE_OSS_REPOSITORY_URL = "http://oss.sonatype.org/content/repositories/snapshots"
private fun hasJavaFiles(module: Module): Boolean {
return !FileTypeIndex.getFiles(JavaFileType.INSTANCE, GlobalSearchScope.moduleScope(module)).isEmpty()
@@ -176,10 +176,6 @@ abstract class KotlinMavenConfigurator protected constructor(private val stdlibA
return null
}
private fun isSnapshot(version: String): Boolean {
return version.contains("SNAPSHOT")
}
private fun canConfigureFile(file: PsiFile): Boolean {
return WritingAccessProvider.isPotentiallyWritable(file.virtualFile, null)
}
@@ -28,126 +28,87 @@ import java.util.regex.Pattern;
/** This class is generated by {@link org.jetbrains.kotlin.generators.tests.TestsPackage}. DO NOT MODIFY MANUALLY */
@SuppressWarnings("all")
@RunWith(JUnit3RunnerWithInners.class)
public class ConfigureProjectByChangingFileTestGenerated extends AbstractConfigureProjectByChangingFileTest {
@TestMetadata("idea/testData/configuration/gradle")
public class MavenConfigureProjectByChangingFileTestGenerated extends AbstractMavenConfigureProjectByChangingFileTest {
@TestMetadata("idea/idea-maven/testData/configurator/jvm")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class Gradle extends AbstractConfigureProjectByChangingFileTest {
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("eapVersion_before.gradle")
public void testEapVersion() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/configuration/gradle/eapVersion_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);
}
@TestMetadata("rcVersion_before.gradle")
public void testRcVersion() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/configuration/gradle/rcVersion_before.gradle");
doTestGradle(fileName);
}
}
@TestMetadata("idea/testData/configuration/maven")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class Maven extends AbstractConfigureProjectByChangingFileTest {
public void testAllFilesPresentInMaven() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/configuration/maven"), Pattern.compile("^([^\\.]+)$"), false);
public static class Jvm extends AbstractMavenConfigureProjectByChangingFileTest {
public void testAllFilesPresentInJvm() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/idea-maven/testData/configurator/jvm"), Pattern.compile("^([^\\.]+)$"), false);
}
@TestMetadata("fixExisting")
public void testFixExisting() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/configuration/maven/fixExisting/");
String fileName = KotlinTestUtils.navigationMetadata("idea/idea-maven/testData/configurator/jvm/fixExisting/");
doTestWithMaven(fileName);
}
@TestMetadata("libraryMissed")
public void testLibraryMissed() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/configuration/maven/libraryMissed/");
String fileName = KotlinTestUtils.navigationMetadata("idea/idea-maven/testData/configurator/jvm/libraryMissed/");
doTestWithMaven(fileName);
}
@TestMetadata("pluginMissed")
public void testPluginMissed() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/configuration/maven/pluginMissed/");
String fileName = KotlinTestUtils.navigationMetadata("idea/idea-maven/testData/configurator/jvm/pluginMissed/");
doTestWithMaven(fileName);
}
@TestMetadata("simpleProject")
public void testSimpleProject() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/configuration/maven/simpleProject/");
String fileName = KotlinTestUtils.navigationMetadata("idea/idea-maven/testData/configurator/jvm/simpleProject/");
doTestWithMaven(fileName);
}
@TestMetadata("simpleProjectEAP")
public void testSimpleProjectEAP() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/configuration/maven/simpleProjectEAP/");
String fileName = KotlinTestUtils.navigationMetadata("idea/idea-maven/testData/configurator/jvm/simpleProjectEAP/");
doTestWithMaven(fileName);
}
@TestMetadata("simpleProjectRc")
public void testSimpleProjectRc() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/configuration/maven/simpleProjectRc/");
String fileName = KotlinTestUtils.navigationMetadata("idea/idea-maven/testData/configurator/jvm/simpleProjectRc/");
doTestWithMaven(fileName);
}
@TestMetadata("simpleProjectSnapshot")
public void testSimpleProjectSnapshot() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/configuration/maven/simpleProjectSnapshot/");
String fileName = KotlinTestUtils.navigationMetadata("idea/idea-maven/testData/configurator/jvm/simpleProjectSnapshot/");
doTestWithMaven(fileName);
}
}
@TestMetadata("idea/testData/configuration/js-maven")
@TestMetadata("idea/idea-maven/testData/configurator/js")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class Js_maven extends AbstractConfigureProjectByChangingFileTest {
public void testAllFilesPresentInJs_maven() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/configuration/js-maven"), Pattern.compile("^([^\\.]+)$"), false);
public static class Js extends AbstractMavenConfigureProjectByChangingFileTest {
public void testAllFilesPresentInJs() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/idea-maven/testData/configurator/js"), Pattern.compile("^([^\\.]+)$"), false);
}
@TestMetadata("libraryMissed")
public void testLibraryMissed() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/configuration/js-maven/libraryMissed/");
String fileName = KotlinTestUtils.navigationMetadata("idea/idea-maven/testData/configurator/js/libraryMissed/");
doTestWithJSMaven(fileName);
}
@TestMetadata("pluginMissed")
public void testPluginMissed() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/configuration/js-maven/pluginMissed/");
String fileName = KotlinTestUtils.navigationMetadata("idea/idea-maven/testData/configurator/js/pluginMissed/");
doTestWithJSMaven(fileName);
}
@TestMetadata("simpleProject")
public void testSimpleProject() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/configuration/js-maven/simpleProject/");
String fileName = KotlinTestUtils.navigationMetadata("idea/idea-maven/testData/configurator/js/simpleProject/");
doTestWithJSMaven(fileName);
}
@TestMetadata("simpleProjectSnapshot")
public void testSimpleProjectSnapshot() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/configuration/js-maven/simpleProjectSnapshot/");
String fileName = KotlinTestUtils.navigationMetadata("idea/idea-maven/testData/configurator/js/simpleProjectSnapshot/");
doTestWithJSMaven(fileName);
}
}
@@ -15,7 +15,7 @@
<version>${kotlin.version}</version>
<executions>
<execution>
<id>js</id>
<id>compile</id>
<phase>compile</phase>
<goals>
<goal>js</goal>
@@ -16,14 +16,14 @@
<version>${kotlin.version}</version>
<executions>
<execution>
<id>js</id>
<id>compile</id>
<phase>compile</phase>
<goals>
<goal>js</goal>
</goals>
</execution>
<execution>
<id>js-test</id>
<id>test-compile</id>
<phase>test-compile</phase>
<goals>
<goal>test-js</goal>
@@ -27,14 +27,14 @@
<version>${kotlin.version}</version>
<executions>
<execution>
<id>js</id>
<id>compile</id>
<phase>compile</phase>
<goals>
<goal>js</goal>
</goals>
</execution>
<execution>
<id>js-test</id>
<id>test-compile</id>
<phase>test-compile</phase>
<goals>
<goal>test-js</goal>
@@ -29,14 +29,14 @@
<version>${kotlin.version}</version>
<executions>
<execution>
<id>js</id>
<id>compile</id>
<phase>compile</phase>
<goals>
<goal>js</goal>
</goals>
</execution>
<execution>
<id>js-test</id>
<id>test-compile</id>
<phase>test-compile</phase>
<goals>
<goal>test-js</goal>
@@ -23,7 +23,7 @@
<repositories>
<repository>
<releases>
<enabled>false</enabled>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
@@ -37,7 +37,7 @@
<pluginRepositories>
<pluginRepository>
<releases>
<enabled>false</enabled>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
@@ -57,14 +57,14 @@
<version>${kotlin.version}</version>
<executions>
<execution>
<id>js</id>
<id>compile</id>
<phase>compile</phase>
<goals>
<goal>js</goal>
</goals>
</execution>
<execution>
<id>js-test</id>
<id>test-compile</id>
<phase>test-compile</phase>
<goals>
<goal>test-js</goal>
@@ -7,39 +7,25 @@
<groupId>maventest</groupId>
<artifactId>maventest</artifactId>
<version>1.0-SNAPSHOT</version>
<build>
<plugins>
<plugin>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-maven-plugin</artifactId>
<version>${kotlin.version}</version>
<executions>
<execution>
<id>compile</id>
<phase>compile</phase>
<goals>
<goal>compile</goal>
</goals>
<configuration>
<sourceDirs>
<source></source>
</sourceDirs>
</configuration>
</execution>
<execution>
<id>test-compile</id>
<phase>test-compile</phase>
<goals>
<goal>test-compile</goal>
</goals>
<configuration>
<sourceDirs></sourceDirs>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<properties>
<kotlin.version>$VERSION$</kotlin.version>
</properties>
<dependencies>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-stdlib</artifactId>
<version>${kotlin.version}</version>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-test</artifactId>
<version>${kotlin.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
<repositories>
<repository>
<releases>
@@ -53,6 +39,7 @@
<url>http://dl.bintray.com/kotlin/kotlin-eap</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<releases>
@@ -66,16 +53,33 @@
<url>http://dl.bintray.com/kotlin/kotlin-eap</url>
</pluginRepository>
</pluginRepositories>
<dependencies>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-stdlib</artifactId>
<version>${kotlin.version}</version>
</dependency>
</dependencies>
<properties>
<kotlin.version>$VERSION$</kotlin.version>
</properties>
<build>
<sourceDirectory></sourceDirectory>
<plugins>
<plugin>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-maven-plugin</artifactId>
<version>${kotlin.version}</version>
<executions>
<execution>
<id>compile</id>
<phase>compile</phase>
<goals>
<goal>compile</goal>
</goals>
</execution>
<execution>
<id>test-compile</id>
<phase>test-compile</phase>
<goals>
<goal>test-compile</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
@@ -7,39 +7,25 @@
<groupId>maventest</groupId>
<artifactId>maventest</artifactId>
<version>1.0-SNAPSHOT</version>
<build>
<plugins>
<plugin>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-maven-plugin</artifactId>
<version>${kotlin.version}</version>
<executions>
<execution>
<id>compile</id>
<phase>compile</phase>
<goals>
<goal>compile</goal>
</goals>
<configuration>
<sourceDirs>
<source></source>
</sourceDirs>
</configuration>
</execution>
<execution>
<id>test-compile</id>
<phase>test-compile</phase>
<goals>
<goal>test-compile</goal>
</goals>
<configuration>
<sourceDirs></sourceDirs>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<properties>
<kotlin.version>$VERSION$</kotlin.version>
</properties>
<dependencies>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-stdlib</artifactId>
<version>${kotlin.version}</version>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-test</artifactId>
<version>${kotlin.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
<repositories>
<repository>
<releases>
@@ -53,6 +39,7 @@
<url>http://dl.bintray.com/kotlin/kotlin-eap</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<releases>
@@ -66,16 +53,33 @@
<url>http://dl.bintray.com/kotlin/kotlin-eap</url>
</pluginRepository>
</pluginRepositories>
<dependencies>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-stdlib</artifactId>
<version>${kotlin.version}</version>
</dependency>
</dependencies>
<properties>
<kotlin.version>$VERSION$</kotlin.version>
</properties>
<build>
<sourceDirectory></sourceDirectory>
<plugins>
<plugin>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-maven-plugin</artifactId>
<version>${kotlin.version}</version>
<executions>
<execution>
<id>compile</id>
<phase>compile</phase>
<goals>
<goal>compile</goal>
</goals>
</execution>
<execution>
<id>test-compile</id>
<phase>test-compile</phase>
<goals>
<goal>test-compile</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
@@ -29,7 +29,7 @@
<repositories>
<repository>
<releases>
<enabled>false</enabled>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
@@ -43,7 +43,7 @@
<pluginRepositories>
<pluginRepository>
<releases>
<enabled>false</enabled>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
@@ -41,6 +41,12 @@ public class GradleConfigureProjectByChangingFileTestGenerated extends AbstractG
doTestGradle(fileName);
}
@TestMetadata("eapVersion_before.gradle")
public void testEapVersion() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/configuration/gradle/eapVersion_before.gradle");
doTestGradle(fileName);
}
@TestMetadata("missedLibrary_before.gradle")
public void testMissedLibrary() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/configuration/gradle/missedLibrary_before.gradle");
@@ -52,4 +58,10 @@ public class GradleConfigureProjectByChangingFileTestGenerated extends AbstractG
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/configuration/gradle/plugin_present_before.gradle");
doTestGradle(fileName);
}
@TestMetadata("rcVersion_before.gradle")
public void testRcVersion() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/configuration/gradle/rcVersion_before.gradle");
doTestGradle(fileName);
}
}