Move model interfaces code from Java to Kotlin

This commit is contained in:
Lucas Smaira
2018-07-30 12:18:04 +01:00
committed by Sergey Igushkin
parent 52990c9eb1
commit 49292cd26c
21 changed files with 130 additions and 359 deletions
@@ -12,26 +12,12 @@ import java.io.Serializable
* Implementation of the [AllOpen] interface.
*/
data class AllOpenImpl(
private val myName: String,
private val myAnnotations: List<String>,
private val myPresets: List<String>
override val name: String,
override val annotations: List<String>,
override val presets: List<String>
) : AllOpen, Serializable {
override fun getModelVersion(): Long {
return serialVersionUID
}
override fun getName(): String {
return myName
}
override fun getAnnotations(): List<String> {
return myAnnotations
}
override fun getPresets(): List<String> {
return myPresets
}
override val modelVersion = serialVersionUID
companion object {
private const val serialVersionUID = 1L
@@ -8,7 +8,7 @@ repositories {
}
dependencies {
compile "org.jetbrains:annotations:13.0"
compile project(':kotlin-stdlib')
}
artifacts {
@@ -3,17 +3,13 @@
* that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.gradle.model;
import org.jetbrains.annotations.NotNull;
import java.util.List;
package org.jetbrains.kotlin.gradle.model
/**
* Entry point for Kotlin All Open models.
* Represents the description of annotations interpreted by 'kotlin-allopen' plugin.
*/
public interface AllOpen {
interface AllOpen {
/**
* Return a number representing the version of this API.
@@ -21,29 +17,26 @@ public interface AllOpen {
*
* @return the version of this model.
*/
long getModelVersion();
val modelVersion: Long
/**
* Returns the module (Gradle project) name.
*
* @return the module name.
*/
@NotNull
String getName();
val name: String
/**
* Return the list of annotations.
*
* @return the list of annotations.
*/
@NotNull
List<String> getAnnotations();
val annotations: List<String>
/**
* Return the list of presets.
*
* @return the list of presets.
*/
@NotNull
List<String> getPresets();
}
val presets: List<String>
}
@@ -3,40 +3,34 @@
* that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.gradle.model;
package org.jetbrains.kotlin.gradle.model
import org.jetbrains.annotations.NotNull;
import java.io.File;
import java.util.List;
import java.io.File
/**
* Represents the compiler arguments for a given Kotlin source set.
* @see SourceSet
*/
public interface CompilerArguments {
interface CompilerArguments {
/**
* Return current arguments for the given source set.
*
* @return current arguments for the given source set.
*/
@NotNull
List<String> getCurrentArguments();
val currentArguments: List<String>
/**
* Return default arguments for the given source set.
*
* @return default arguments for the given source set.
*/
@NotNull
List<String> getDefaultArguments();
val defaultArguments: List<String>
/**
* Return the classpath the given source set is compiled against.
*
* @return the classpath the given source set is compiled against.
*/
@NotNull
List<File> getCompileClasspath();
}
val compileClasspath: List<File>
}
@@ -3,21 +3,18 @@
* that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.gradle.model;
import org.jetbrains.annotations.Nullable;
package org.jetbrains.kotlin.gradle.model
/**
* Wraps all experimental features information for a given Kotlin project.
* @see KotlinProject
*/
public interface ExperimentalFeatures {
interface ExperimentalFeatures {
/**
* Return coroutines string.
*
* @return coroutines.
*/
@Nullable
String getCoroutines();
}
val coroutines: String?
}
@@ -3,17 +3,13 @@
* that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.gradle.model;
import org.jetbrains.annotations.NotNull;
import java.util.Collection;
package org.jetbrains.kotlin.gradle.model
/**
* Entry point for annotation processor model.
* Plugin 'kotlin-kapt' can produce this model.
*/
public interface Kapt {
interface Kapt {
/**
* Return a number representing the version of this API.
@@ -21,21 +17,19 @@ public interface Kapt {
*
* @return the version of this model.
*/
long getModelVersion();
val modelVersion: Long
/**
* Returns the module (Gradle project) name.
*
* @return the module name.
*/
@NotNull
String getName();
val name: String
/**
* Return all kapt source sets.
*
* @return all kapt source sets.
*/
@NotNull
Collection<KaptSourceSet> getKaptSourceSets();
}
val kaptSourceSets: Collection<KaptSourceSet>
}
@@ -3,22 +3,20 @@
* that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.gradle.model;
package org.jetbrains.kotlin.gradle.model
import org.jetbrains.annotations.NotNull;
import java.io.File;
import java.io.File
/**
* Represents a source set for a given kapt model.
* @see Kapt
*/
public interface KaptSourceSet {
interface KaptSourceSet {
/**
* Possible source set types.
*/
enum KaptSourceSetType {
enum class KaptSourceSetType {
PRODUCTION,
TEST
}
@@ -28,38 +26,33 @@ public interface KaptSourceSet {
*
* @return the source set name.
*/
@NotNull
String getName();
val name: String
/**
* Return the type of the source set.
*
* @return the type of the source set.
*/
@NotNull
KaptSourceSetType getType();
val type: KaptSourceSetType
/**
* Return generated sources directory.
*
* @return generated sources directory.
*/
@NotNull
File getGeneratedSourcesDirectory();
val generatedSourcesDirectory: File
/**
* Return Kotlin generated sources directory.
*
* @return Kotlin generated sources directory.
*/
@NotNull
File getGeneratedKotlinSourcesDirectory();
val generatedKotlinSourcesDirectory: File
/**
* Return Kotlin generated classes directory.
*
* @return Kotlin generated classes directory.
*/
@NotNull
File getGeneratedClassesDirectory();
}
val generatedClassesDirectory: File
}
@@ -3,16 +3,13 @@
* that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.gradle.model;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
package org.jetbrains.kotlin.gradle.model
/**
* Entry point for Kotlin Android Extensions models.
* Represents the description of Android only features. Provided by 'kotlin-android-extensions' plugin.
*/
public interface KotlinAndroidExtension {
interface KotlinAndroidExtension {
/**
* Return a number representing the version of this API.
@@ -20,28 +17,26 @@ public interface KotlinAndroidExtension {
*
* @return the version of this model.
*/
long getModelVersion();
val modelVersion: Long
/**
* Returns the module (Gradle project) name.
*
* @return the module name.
*/
@NotNull
String getName();
val name: String
/**
* Indicate the use of experimental features.
*
* @return if experimental features are used.
*/
boolean isExperimental();
val isExperimental: Boolean
/**
* Return the default cache implementation.
*
* @return the default cache implementation.
*/
@Nullable
String getDefaultCacheImplementation();
}
val defaultCacheImplementation: String?
}
@@ -3,30 +3,26 @@
* that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.gradle.model;
import org.jetbrains.annotations.NotNull;
import java.util.Collection;
package org.jetbrains.kotlin.gradle.model
/**
* Entry point for the model of Kotlin Projects.
* Plugins 'kotlin', 'kotlin-platform-jvm', 'kotlin2js', 'kotlin-platform-js' and 'kotlin-platform-common' can produce this model.
*/
public interface KotlinProject {
interface KotlinProject {
/**
* Possible Kotlin project types.
*/
enum ProjectType {
enum class ProjectType {
/** Indicator of platform plugin id 'kotlin-platform-jvm' or 'kotlin'. */
/** Indicator of platform plugin id 'kotlin-platform-jvm' or 'kotlin'. */
PLATFORM_JVM,
/** Indicator of platform plugin id 'kotlin-platform-js' or 'kotlin2js'. */
/** Indicator of platform plugin id 'kotlin-platform-js' or 'kotlin2js'. */
PLATFORM_JS,
/** Indicator of platform plugin id 'kotlin-platform-common'. */
/** Indicator of platform plugin id 'kotlin-platform-common'. */
PLATFORM_COMMON
}
@@ -36,53 +32,47 @@ public interface KotlinProject {
*
* @return the version of this model.
*/
long getModelVersion();
val modelVersion: Long
/**
* Returns the module (Gradle project) name.
*
* @return the module name.
*/
@NotNull
String getName();
val name: String
/**
* Return the Kotlin version.
*
* @return the Kotlin version.
*/
@NotNull
String getKotlinVersion();
val kotlinVersion: String
/**
* Return the type of the platform plugin applied.
*
* @return the type of the platform plugin applied. Possible values are defined in the enum.
*/
@NotNull
ProjectType getProjectType();
val projectType: ProjectType
/**
* Return all source sets used by Kotlin.
*
* @return all source sets.
*/
@NotNull
Collection<SourceSet> getSourceSets();
val sourceSets: Collection<SourceSet>
/**
* Return all modules (Gradle projects) registered as 'expectedBy' dependency.
*
* @return expectedBy dependencies.
*/
@NotNull
Collection<String> getExpectedByDependencies();
val expectedByDependencies: Collection<String>
/**
* Return an object containing a descriptor of the experimental features.
*
* @return experimental features.
*/
@NotNull
ExperimentalFeatures getExperimentalFeatures();
}
val experimentalFeatures: ExperimentalFeatures
}
@@ -3,17 +3,13 @@
* that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.gradle.model;
import org.jetbrains.annotations.NotNull;
import java.util.List;
package org.jetbrains.kotlin.gradle.model
/**
* Entry point for Kotlin No Arg models.
* Represents the description of annotations interpreted by 'kotlin-noarg' plugin.
*/
public interface NoArg {
interface NoArg {
/**
* Return a number representing the version of this API.
@@ -21,31 +17,28 @@ public interface NoArg {
*
* @return the version of this model.
*/
long getModelVersion();
val modelVersion: Long
/**
* Returns the module (Gradle project) name.
*
* @return the module name.
*/
@NotNull
String getName();
val name: String
/**
* Return the list of annotations.
*
* @return the list of annotations.
*/
@NotNull
List<String> getAnnotations();
val annotations: List<String>
/**
* Return the list of presets.
*
* @return the list of presets.
*/
@NotNull
List<String> getPresets();
val presets: List<String>
/**
* Return if should invoke initializers.
@@ -53,5 +46,5 @@ public interface NoArg {
*
* @return if initializers should be invoked.
*/
boolean isInvokeInitializers();
}
val isInvokeInitializers: Boolean
}
@@ -3,17 +3,13 @@
* that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.gradle.model;
import org.jetbrains.annotations.NotNull;
import java.util.List;
package org.jetbrains.kotlin.gradle.model
/**
* Entry point for Kotlin Sam With Receiver models.
* Represents the description of annotations interpreted by 'kotlin-sam-with-receiver' plugin.
*/
public interface SamWithReceiver {
interface SamWithReceiver {
/**
* Return a number representing the version of this API.
@@ -21,29 +17,26 @@ public interface SamWithReceiver {
*
* @return the version of this model.
*/
long getModelVersion();
val modelVersion: Long
/**
* Returns the module (Gradle project) name.
*
* @return the module name.
*/
@NotNull
String getName();
val name: String
/**
* Return the list of annotations.
*
* @return the list of annotations.
*/
@NotNull
List<String> getAnnotations();
val annotations: List<String>
/**
* Return the list of presets.
*
* @return the list of presets.
*/
@NotNull
List<String> getPresets();
}
val presets: List<String>
}
@@ -3,23 +3,20 @@
* that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.gradle.model;
package org.jetbrains.kotlin.gradle.model
import org.jetbrains.annotations.NotNull;
import java.io.File;
import java.util.Collection;
import java.io.File
/**
* Represents a source set for a given Kotlin Gradle project.
* @see KotlinProject
*/
public interface SourceSet {
interface SourceSet {
/**
* Possible source set types.
*/
enum SourceSetType {
enum class SourceSetType {
PRODUCTION,
TEST
}
@@ -29,62 +26,54 @@ public interface SourceSet {
*
* @return the source set name.
*/
@NotNull
String getName();
val name: String
/**
* Return the type of the source set.
*
* @return the type of the source set.
*/
@NotNull
SourceSetType getType();
val type: SourceSetType
/**
* Return the names of all friend source sets.
*
* @return friend source sets.
*/
@NotNull
Collection<String> getFriendSourceSets();
val friendSourceSets: Collection<String>
/**
* Return all Kotlin sources directories.
*
* @return all Kotlin sources directories.
*/
@NotNull
Collection<File> getSourceDirectories();
val sourceDirectories: Collection<File>
/**
* Return all Kotlin resources directories.
*
* @return all Kotlin resources directories.
*/
@NotNull
Collection<File> getResourcesDirectories();
val resourcesDirectories: Collection<File>
/**
* Return the classes output directory.
*
* @return the classes output directory.
*/
@NotNull
File getClassesOutputDirectory();
val classesOutputDirectory: File
/**
* Return the resources output directory.
*
* @return the resources output directory.
*/
@NotNull
File getResourcesOutputDirectory();
val resourcesOutputDirectory: File
/**
* Return an object containing all compiler arguments for this source set.
*
* @return compiler arguments for this source set.
*/
@NotNull
CompilerArguments getCompilerArguments();
}
val compilerArguments: CompilerArguments
}
@@ -13,23 +13,11 @@ import java.io.Serializable
* Implementation of the [CompilerArguments] interface.
*/
data class CompilerArgumentsImpl(
private val myCurrentArguments: List<String>,
private val myDefaultArguments: List<String>,
private val myCompilerClasspath: List<File>
override val currentArguments: List<String>,
override val defaultArguments: List<String>,
override val compileClasspath: List<File>
) : CompilerArguments, Serializable {
override fun getCurrentArguments(): List<String> {
return myCurrentArguments
}
override fun getDefaultArguments(): List<String> {
return myDefaultArguments
}
override fun getCompileClasspath(): List<File> {
return myCompilerClasspath
}
companion object {
private const val serialVersionUID = 1L
}
@@ -12,13 +12,9 @@ import java.io.Serializable
* Implementation of the [ExperimentalFeatures] interface.
*/
data class ExperimentalFeaturesImpl(
private val myCoroutines: String?
override val coroutines: String?
) : ExperimentalFeatures, Serializable {
override fun getCoroutines(): String? {
return myCoroutines
}
companion object {
private const val serialVersionUID = 1L
}
@@ -13,21 +13,11 @@ import java.io.Serializable
* Implementation of the [Kapt] interface.
*/
data class KaptImpl(
private val myName: String,
private val kaptSourceSets: Collection<KaptSourceSet>
override val name: String,
override val kaptSourceSets: Collection<KaptSourceSet>
) : Kapt, Serializable {
override fun getModelVersion(): Long {
return serialVersionUID
}
override fun getName(): String {
return myName
}
override fun getKaptSourceSets(): Collection<KaptSourceSet> {
return kaptSourceSets
}
override val modelVersion = serialVersionUID
companion object {
private const val serialVersionUID = 1L
@@ -13,30 +13,14 @@ import java.io.Serializable
* Implementation of the [KaptSourceSet] interface.
*/
data class KaptSourceSetImpl(
private val myName: String,
private val myType: KaptSourceSet.KaptSourceSetType,
private val myGeneratedSourcesDirectory: File,
private val myGeneratedKotlinSourcesDirectory: File,
private val myGeneratedClassesDirectory: File
override val name: String,
override val type: KaptSourceSet.KaptSourceSetType,
override val generatedSourcesDirectory: File,
override val generatedKotlinSourcesDirectory: File,
override val generatedClassesDirectory: File
) : KaptSourceSet, Serializable {
override fun getName(): String {
return myName
}
override fun getType(): KaptSourceSet.KaptSourceSetType {
return myType
}
override fun getGeneratedSourcesDirectory(): File {
return myGeneratedSourcesDirectory
}
override fun getGeneratedKotlinSourcesDirectory(): File {
return myGeneratedKotlinSourcesDirectory
}
override fun getGeneratedClassesDirectory(): File {
return myGeneratedClassesDirectory
companion object {
private const val serialVersionUID = 1L
}
}
@@ -12,26 +12,12 @@ import java.io.Serializable
* Implementation of the [KotlinAndroidExtension] interface.
*/
data class KotlinAndroidExtensionImpl(
private val myName: String,
private val myIsExperimental: Boolean,
private val myDefaultCacheImplementation: String?
override val name: String,
override val isExperimental: Boolean,
override val defaultCacheImplementation: String?
) : KotlinAndroidExtension, Serializable {
override fun getModelVersion(): Long {
return serialVersionUID
}
override fun getName(): String {
return myName
}
override fun isExperimental(): Boolean {
return myIsExperimental
}
override fun getDefaultCacheImplementation(): String? {
return myDefaultCacheImplementation
}
override val modelVersion = serialVersionUID
companion object {
private const val serialVersionUID = 1L
@@ -14,41 +14,15 @@ import java.io.Serializable
* Implementation of the [KotlinProject] interface.
*/
data class KotlinProjectImpl(
private val myName: String,
private val myKotlinVersion: String,
private val myProjectType: KotlinProject.ProjectType,
private val mySourceSets: Collection<SourceSet>,
private val myExpectedByDependencies: Collection<String>,
private val myExperimentalFeatures: ExperimentalFeatures
override val name: String,
override val kotlinVersion: String,
override val projectType: KotlinProject.ProjectType,
override val sourceSets: Collection<SourceSet>,
override val expectedByDependencies: Collection<String>,
override val experimentalFeatures: ExperimentalFeatures
) : KotlinProject, Serializable {
override fun getModelVersion(): Long {
return serialVersionUID
}
override fun getName(): String {
return myName
}
override fun getKotlinVersion(): String {
return myKotlinVersion
}
override fun getProjectType(): KotlinProject.ProjectType {
return myProjectType
}
override fun getSourceSets(): Collection<SourceSet> {
return mySourceSets
}
override fun getExpectedByDependencies(): Collection<String> {
return myExpectedByDependencies
}
override fun getExperimentalFeatures(): ExperimentalFeatures {
return myExperimentalFeatures
}
override val modelVersion = serialVersionUID
companion object {
private const val serialVersionUID = 1L
@@ -14,48 +14,16 @@ import java.io.Serializable
* Implementation of the [SourceSet] interface.
*/
data class SourceSetImpl(
private val myName: String,
private val myType: SourceSet.SourceSetType,
private val myFriendSourceSets: Collection<String>,
private val mySourceDirectories: Collection<File>,
private val myResourcesDirectories: Collection<File>,
private val myClassesOutputDirectory: File,
private val myResourcesOutputDirectory: File,
private val myCompilerArguments: CompilerArguments
override val name: String,
override val type: SourceSet.SourceSetType,
override val friendSourceSets: Collection<String>,
override val sourceDirectories: Collection<File>,
override val resourcesDirectories: Collection<File>,
override val classesOutputDirectory: File,
override val resourcesOutputDirectory: File,
override val compilerArguments: CompilerArguments
) : SourceSet, Serializable {
override fun getName(): String {
return myName
}
override fun getType(): SourceSet.SourceSetType {
return myType
}
override fun getFriendSourceSets(): Collection<String> {
return myFriendSourceSets
}
override fun getSourceDirectories(): Collection<File> {
return mySourceDirectories
}
override fun getResourcesDirectories(): Collection<File> {
return myResourcesDirectories
}
override fun getClassesOutputDirectory(): File {
return myClassesOutputDirectory
}
override fun getResourcesOutputDirectory(): File {
return myResourcesOutputDirectory
}
override fun getCompilerArguments(): CompilerArguments {
return myCompilerArguments
}
companion object {
private const val serialVersionUID = 1L
}
@@ -12,31 +12,13 @@ import java.io.Serializable
* Implementation of the [NoArg] interface.
*/
data class NoArgImpl(
private val myName: String,
private val myAnnotations: List<String>,
private val myPresets: List<String>,
private val myInvokeInitializers: Boolean
override val name: String,
override val annotations: List<String>,
override val presets: List<String>,
override val isInvokeInitializers: Boolean
) : NoArg, Serializable {
override fun getModelVersion(): Long {
return serialVersionUID
}
override fun getName(): String {
return myName
}
override fun getAnnotations(): List<String> {
return myAnnotations
}
override fun getPresets(): List<String> {
return myPresets
}
override fun isInvokeInitializers(): Boolean {
return myInvokeInitializers
}
override val modelVersion = serialVersionUID
companion object {
private const val serialVersionUID = 1L
@@ -12,26 +12,12 @@ import java.io.Serializable
* Implementation of the [SamWithReceiver] interface.
*/
data class SamWithReceiverImpl(
private val myName: String,
private val myAnnotations: List<String>,
private val myPresets: List<String>
override val name: String,
override val annotations: List<String>,
override val presets: List<String>
) : SamWithReceiver, Serializable {
override fun getModelVersion(): Long {
return serialVersionUID
}
override fun getName(): String {
return myName
}
override fun getAnnotations(): List<String> {
return myAnnotations
}
override fun getPresets(): List<String> {
return myPresets
}
override val modelVersion = serialVersionUID
companion object {
private const val serialVersionUID = 1L