-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds support for adding Smithy source files to Scala project jars.
- Loading branch information
Showing
9 changed files
with
105 additions
and
1 deletion.
There are no files selected for viewing
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,16 @@ | ||
# Example Project - Scala Project | ||
|
||
This is an example Gradle Smithy project. In addition to serving as documentation, | ||
this project is run as an integration test for the plugin. | ||
|
||
This project demonstrates using the Smithy Gradle Plugin with a Scala project. | ||
The Jar created by the Scala plugin will include the Smithy models built by the | ||
`smithyBuild` task. | ||
|
||
## Using the example as a starting point | ||
|
||
Since this sample is run as an integration test, by default it is only configured | ||
to use a locally published version of the plugin. To use this as a starting point | ||
for your own project, uncomment the lines in `settings.gradle.kts` that configure | ||
Gradle to use public sources. | ||
|
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,15 @@ | ||
// This project adds smithy models to a JAR created by a Kotlin project | ||
|
||
plugins { | ||
scala | ||
id("software.amazon.smithy.gradle.smithy-jar").version("0.8.0") | ||
} | ||
|
||
dependencies { | ||
implementation("org.scala-lang:scala-library:2.13.11") | ||
} | ||
|
||
repositories { | ||
mavenLocal() | ||
mavenCentral() | ||
} |
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,5 @@ | ||
namespace smithy.example | ||
|
||
structure Baz { | ||
foo: String | ||
} |
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,9 @@ | ||
rootProject.name = "scala-project" | ||
|
||
pluginManagement { | ||
repositories { | ||
mavenLocal() | ||
gradlePluginPortal() | ||
mavenCentral() | ||
} | ||
} |
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,6 @@ | ||
{ | ||
"version": "1.0", | ||
"projections": { | ||
"foo": {} | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
examples/jar-plugin/scala-project/src/main/scala/example/Main.scala
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,9 @@ | ||
package example | ||
|
||
object Main { | ||
def main(args: Array[String]): Unit = { | ||
println(greeting()) | ||
} | ||
|
||
def greeting(): String = "Hello, world!" | ||
} |
33 changes: 33 additions & 0 deletions
33
smithy-jar-plugin/src/it/java/software/amazon/smithy/gradle/ScalaProjectTest.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,33 @@ | ||
package software.amazon.smithy.gradle; | ||
|
||
import org.gradle.testkit.runner.BuildResult; | ||
import org.gradle.testkit.runner.GradleRunner; | ||
import org.junit.jupiter.api.Test; | ||
|
||
public class ScalaProjectTest { | ||
@Test | ||
public void testScalaProject() { | ||
Utils.withCopy("jar-plugin/scala-project", buildDir -> { | ||
BuildResult result = GradleRunner.create() | ||
.forwardOutput() | ||
.withProjectDir(buildDir) | ||
.withArguments("clean", "build", "--stacktrace") | ||
.build(); | ||
|
||
Utils.assertSmithyBuildTaskRan(result); | ||
Utils.assertValidationRan(result); | ||
Utils.assertArtifactsCreated(buildDir, | ||
"build/smithyprojections/scala-project/source/build-info/smithy-build-info.json", | ||
"build/smithyprojections/scala-project/source/model/model.json", | ||
"build/smithyprojections/scala-project/source/sources/main.smithy", | ||
"build/smithyprojections/scala-project/source/sources/manifest", | ||
"build/libs/scala-project.jar"); | ||
Utils.assertJarContains(buildDir, | ||
"build/libs/scala-project.jar", | ||
"META-INF/smithy/manifest", | ||
"META-INF/smithy/main.smithy", | ||
"example/Main.class" | ||
); | ||
}); | ||
} | ||
} |
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