Skip to content

Commit

Permalink
added graalpy
Browse files Browse the repository at this point in the history
  • Loading branch information
tomasstupka committed Aug 8, 2024
1 parent 94c8c6d commit d049af3
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
2 changes: 2 additions & 0 deletions gradle/templates.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ gradle-enterprise-maven-custom-data = "1.13"
gradle-enterprise-maven-extension = "1.21.4"
gradle-jrebel-plugin = "1.1.10"
gradle-shadow-plugin = "8.1.1"
graalpy-maven-plugin = "24.2.0"
jib-gradle-plugin = "2.8.0"
jobrunr = "6.3.5"
jruby = "9.4.5.0"
Expand Down Expand Up @@ -107,6 +108,7 @@ gradle-enterprise-maven = { module = "com.gradle:gradle-enterprise-maven-extensi
gradle-enterprise-maven-custom-data = { module = "com.gradle:common-custom-user-data-maven-extension", version.ref = "gradle-enterprise-maven-custom-data" }
gradle-jrebel-plugin = { module = "gradle.plugin.org.zeroturnaround:gradle-jrebel-plugin", version.ref = "gradle-jrebel-plugin" }
gradle-shadow-plugin = { module = "gradle.plugin.com.github.johnrengelman:shadow", version.ref = "gradle-shadow-plugin" }
graalpy-maven-plugin = { module = "org.graalvm.python:graalpy-maven-plugin", version.ref = "graalpy-maven-plugin" }
jib-gradle-plugin = { module = "gradle.plugin.com.google.cloud.tools:jib-gradle-plugin", version.ref = "jib-gradle-plugin" }
jobrunr-micronaut = { module = "org.jobrunr:jobrunr-micronaut-feature", version.ref = "jobrunr" }
jruby = { module = "org.jruby:jruby", version.ref = "jruby" }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import io.micronaut.starter.application.ApplicationType;
import io.micronaut.starter.application.generator.GeneratorContext;
import io.micronaut.starter.build.BuildProperties;
import io.micronaut.starter.build.dependencies.CoordinateResolver;
import io.micronaut.starter.build.dependencies.Dependency;
import io.micronaut.starter.build.dependencies.MicronautDependencyUtils;
import io.micronaut.starter.build.maven.MavenPlugin;
Expand All @@ -31,15 +32,19 @@
@Singleton
public class MicronautGraalPyFeature implements Feature {

// XXX GP can declare only for java maven?

public static final String NAME = "micronaut-graalpy";

private static final Dependency MICRONAUT_GRAALPY_DEPENDENCY = MicronautDependencyUtils.graalLanguagesDependency()
.artifactId(NAME)
.compile()
.build();

private final CoordinateResolver coordinateResolver;

public MicronautGraalPyFeature(CoordinateResolver coordinateResolver) {
this.coordinateResolver = coordinateResolver;
}

@Override
public String getName() {
return NAME;
Expand All @@ -62,22 +67,22 @@ public boolean supports(ApplicationType applicationType) {

@Override
public String getCategory() {
// XXX GP
// XXX GP - what category
return Category.API;
}

@Override
public void apply(GeneratorContext generatorContext) {
generatorContext.addDependency(MICRONAUT_GRAALPY_DEPENDENCY);

if (generatorContext.getBuildTool() == BuildTool.MAVEN) {
BuildProperties buildProperties = generatorContext.getBuildProperties();
// XXX GP is this the right place to declare the version?
buildProperties.put("graalpy-maven-plugin.version", "24.2.0");
String graalPyMavenPluginArtefactId = "graalpy-maven-plugin";
coordinateResolver.resolve(graalPyMavenPluginArtefactId)
.ifPresent(coordinate -> buildProperties.put("graalpy.maven.plugin.version", coordinate.getVersion()));

generatorContext.addBuildPlugin(MavenPlugin.builder()
.groupId("org.graalvm.python")
.artifactId("graalpy-maven-plugin")
.artifactId(graalPyMavenPluginArtefactId)
.extension(new RockerWritable(graalPyMavenPlugin.template()))
.build());
}
Expand Down

0 comments on commit d049af3

Please sign in to comment.