-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Arthur McGibbon
committed
Aug 12, 2024
1 parent
cd93aa3
commit ca10fcc
Showing
17 changed files
with
760 additions
and
3 deletions.
There are no files selected for viewing
20 changes: 20 additions & 0 deletions
20
model/src/main/java/com/microsoft/java/bs/gradle/model/KotlinExtension.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT license. | ||
|
||
package com.microsoft.java.bs.gradle.model; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* The extension model for Kotlin language. | ||
*/ | ||
public interface KotlinExtension extends LanguageExtension { | ||
|
||
String getKotlinLanguageVersion(); | ||
|
||
String getKotlinApiVersion(); | ||
|
||
List<String> getKotlincOptions(); | ||
|
||
List<String> getKotlinAssociates(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
166 changes: 166 additions & 0 deletions
166
model/src/main/java/com/microsoft/java/bs/gradle/model/impl/DefaultKotlinExtension.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,166 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT license. | ||
|
||
package com.microsoft.java.bs.gradle.model.impl; | ||
|
||
import com.microsoft.java.bs.gradle.model.JavaExtension; | ||
import com.microsoft.java.bs.gradle.model.KotlinExtension; | ||
import com.microsoft.java.bs.gradle.model.ScalaExtension; | ||
|
||
import java.io.File; | ||
import java.util.List; | ||
import java.util.Objects; | ||
import java.util.Set; | ||
|
||
/** | ||
* Default implementation of {@link KotlinExtension}. | ||
*/ | ||
public class DefaultKotlinExtension implements KotlinExtension { | ||
private static final long serialVersionUID = 1L; | ||
|
||
private Set<File> sourceDirs; | ||
|
||
private Set<File> generatedSourceDirs; | ||
|
||
private String compileTaskName; | ||
|
||
private File classesDir; | ||
|
||
private String kotlinLanguageVersion; | ||
|
||
private String kotlinApiVersion; | ||
|
||
private List<String> kotlincOptions; | ||
|
||
private List<String> kotlinAssociates; | ||
|
||
@Override | ||
public Set<File> getSourceDirs() { | ||
return sourceDirs; | ||
} | ||
|
||
public void setSourceDirs(Set<File> sourceDirs) { | ||
this.sourceDirs = sourceDirs; | ||
} | ||
|
||
@Override | ||
public Set<File> getGeneratedSourceDirs() { | ||
return generatedSourceDirs; | ||
} | ||
|
||
public void setGeneratedSourceDirs(Set<File> generatedSourceDirs) { | ||
this.generatedSourceDirs = generatedSourceDirs; | ||
} | ||
|
||
@Override | ||
public String getCompileTaskName() { | ||
return compileTaskName; | ||
} | ||
|
||
public void setCompileTaskName(String compileTaskName) { | ||
this.compileTaskName = compileTaskName; | ||
} | ||
|
||
@Override | ||
public File getClassesDir() { | ||
return classesDir; | ||
} | ||
|
||
public void setClassesDir(File classesDir) { | ||
this.classesDir = classesDir; | ||
} | ||
|
||
@Override | ||
public String getKotlinLanguageVersion() { | ||
return kotlinLanguageVersion; | ||
} | ||
|
||
public void setKotlinLanguageVersion(String kotlinLanguageVersion) { | ||
this.kotlinLanguageVersion = kotlinLanguageVersion; | ||
} | ||
|
||
@Override | ||
public String getKotlinApiVersion() { | ||
return kotlinApiVersion; | ||
} | ||
|
||
public void setKotlinApiVersion(String kotlinApiVersion) { | ||
this.kotlinApiVersion = kotlinApiVersion; | ||
} | ||
|
||
@Override | ||
public List<String> getKotlincOptions() { | ||
return kotlincOptions; | ||
} | ||
|
||
public void setKotlincOptions(List<String> kotlincOptions) { | ||
this.kotlincOptions = kotlincOptions; | ||
} | ||
|
||
@Override | ||
public List<String> getKotlinAssociates() { | ||
return kotlinAssociates; | ||
} | ||
|
||
public void setKotlinAssociates(List<String> kotlinAssociates) { | ||
this.kotlinAssociates = kotlinAssociates; | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(sourceDirs, generatedSourceDirs, compileTaskName, classesDir, | ||
kotlinLanguageVersion, kotlinApiVersion, kotlincOptions, kotlinAssociates); | ||
} | ||
|
||
@Override | ||
public boolean equals(Object obj) { | ||
if (this == obj) { | ||
return true; | ||
} | ||
if (obj == null) { | ||
return false; | ||
} | ||
if (getClass() != obj.getClass()) { | ||
return false; | ||
} | ||
DefaultKotlinExtension other = (DefaultKotlinExtension) obj; | ||
return Objects.equals(sourceDirs, other.sourceDirs) | ||
&& Objects.equals(generatedSourceDirs, other.generatedSourceDirs) | ||
&& Objects.equals(compileTaskName, other.compileTaskName) | ||
&& Objects.equals(classesDir, other.classesDir) | ||
&& Objects.equals(kotlinLanguageVersion, other.kotlinLanguageVersion) | ||
&& Objects.equals(kotlinApiVersion, other.kotlinApiVersion) | ||
&& Objects.equals(kotlincOptions, other.kotlincOptions) | ||
&& Objects.equals(kotlinAssociates, other.kotlinAssociates); | ||
} | ||
|
||
@Override | ||
public boolean isJavaExtension() { | ||
return false; | ||
} | ||
|
||
@Override | ||
public boolean isScalaExtension() { | ||
return false; | ||
} | ||
|
||
@Override | ||
public boolean isKotlinExtension() { | ||
return true; | ||
} | ||
|
||
@Override | ||
public JavaExtension getAsJavaExtension() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public ScalaExtension getAsScalaExtension() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public KotlinExtension getAsKotlinExtension() { | ||
return this; | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
model/src/main/java/com/microsoft/java/bs/gradle/model/impl/DefaultKotlinLanguage.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT license. | ||
|
||
package com.microsoft.java.bs.gradle.model.impl; | ||
|
||
import com.microsoft.java.bs.gradle.model.KotlinExtension; | ||
import com.microsoft.java.bs.gradle.model.LanguageExtension; | ||
import com.microsoft.java.bs.gradle.model.SupportedLanguage; | ||
|
||
import java.util.Map; | ||
|
||
/** | ||
* Default Kotlin implementation of {@link SupportedLanguage}. | ||
*/ | ||
public class DefaultKotlinLanguage implements SupportedLanguage<KotlinExtension> { | ||
|
||
@Override | ||
public String getBspName() { | ||
return "kotlin"; | ||
} | ||
|
||
@Override | ||
public String getGradleName() { | ||
return "kotlin"; | ||
} | ||
|
||
@Override | ||
public KotlinExtension getExtension(Map<String, LanguageExtension> extensions) { | ||
LanguageExtension extension = extensions.get(getBspName()); | ||
if (extension == null) { | ||
return null; | ||
} | ||
if (extension.isKotlinExtension()) { | ||
return extension.getAsKotlinExtension(); | ||
} | ||
throw new IllegalArgumentException( | ||
"LanguageExtension: " + extension + " is not a KotlinExtension." | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.