Skip to content

Commit

Permalink
Better split and structure the annotation processing stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
andreaTP committed Oct 19, 2024
1 parent 2b3a897 commit 1bec3ef
Show file tree
Hide file tree
Showing 34 changed files with 372 additions and 67 deletions.
1 change: 0 additions & 1 deletion aot-maven-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
<dependency>
<groupId>com.github.javaparser</groupId>
<artifactId>javaparser-core</artifactId>
<version>${javaparser.version}</version>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
Expand Down
2 changes: 1 addition & 1 deletion bom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<dependencies>
<dependency>
<groupId>com.dylibso.chicory</groupId>
<artifactId>function-annotations</artifactId>
<artifactId>host-module-annotations</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@

<parent>
<groupId>com.dylibso.chicory</groupId>
<artifactId>chicory</artifactId>
<artifactId>host-module-parent</artifactId>
<version>999-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>function-annotations</artifactId>
<artifactId>host-module-annotations</artifactId>
<packaging>jar</packaging>
<name>Chicory - Function annotations</name>
<description>Experimental annotations for host functions</description>
<name>Chicory - Host Module annotations</name>
<description>Experimental annotations for host modules</description>

</project>
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.dylibso.chicory.function.annotations;
package com.dylibso.chicory.hostmodule.annotations;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.dylibso.chicory.function.annotations;
package com.dylibso.chicory.hostmodule.annotations;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.dylibso.chicory.function.annotations;
package com.dylibso.chicory.hostmodule.annotations;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.dylibso.chicory.function.annotations;
package com.dylibso.chicory.hostmodule.annotations;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
Expand Down
99 changes: 99 additions & 0 deletions host-module/it/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>com.dylibso.chicory</groupId>
<artifactId>host-module-parent</artifactId>
<version>999-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>host-module-it</artifactId>
<packaging>jar</packaging>
<name>Chicory - Host Module - IT</name>
<description>Integration tests for the Chicory annotations</description>

<dependencies>
<dependency>
<groupId>com.dylibso.chicory</groupId>
<artifactId>host-module-processor</artifactId>
</dependency>
</dependencies>

<build>
<plugins>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<configuration>
<ignoredUnusedDeclaredDependencies combine.children="append">
<dependency>com.dylibso.chicory:host-module-processor</dependency>
</ignoredUnusedDeclaredDependencies>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>${maven-failsafe-plugin.version}</version>
<configuration>
<systemPropertyVariables>
<itDir>${project.basedir}</itDir>
<chicoryVersion>${project.version}</chicoryVersion>
</systemPropertyVariables>
</configuration>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-invoker-plugin</artifactId>
<version>${maven-invoker-plugin.version}</version>
<configuration>
<cloneProjectsTo>${project.build.directory}/it</cloneProjectsTo>
<cloneClean>true</cloneClean>
<settingsFile>src/it/settings.xml</settingsFile>
<postBuildHookScript>verify</postBuildHookScript>
<addTestClassPath>true</addTestClassPath>
<skipInvocation>${skipTests}</skipInvocation>
<streamLogs>true</streamLogs>
<invokerPropertiesFile>invoker.properties</invokerPropertiesFile>
<scriptVariables>
<version>${project.version}</version>
<artifactId>${project.artifactId}</artifactId>
<groupId>${project.groupId}</groupId>
</scriptVariables>
</configuration>
<executions>
<execution>
<id>integration-tests</id>
<goals>
<goal>install</goal>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>

<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>templating-maven-plugin</artifactId>
<version>3.0.0</version>
<executions>
<execution>
<id>filtering-java-templates</id>
<goals>
<goal>filter-sources</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
35 changes: 35 additions & 0 deletions host-module/it/src/it/settings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?xml version="1.0" encoding="UTF-8"?>
<settings>
<profiles>
<profile>
<id>it-repo</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<repositories>
<repository>
<id>local.central</id>
<url>@localRepositoryUrl@</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>local.central</id>
<url>@localRepositoryUrl@</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>
</settings>
1 change: 1 addition & 0 deletions host-module/it/src/it/with-imports/invoker.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
invoker.goals=test
73 changes: 73 additions & 0 deletions host-module/it/src/it/with-imports/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
<?xml version="1.0" encoding="UTF-8"?>
<project>

<modelVersion>4.0.0</modelVersion>
<groupId>com.dylibso.chicory</groupId>

<artifactId>with-imports-chicory-it</artifactId>
<version>0.0-SNAPSHOT</version>
<packaging>jar</packaging>

<properties>
<maven.compiler.release>@maven.compiler.release@</maven.compiler.release>
</properties>

<dependencies>
<dependency>
<groupId>com.dylibso.chicory</groupId>
<artifactId>host-module-annotations</artifactId>
<version>@project.version@</version>
</dependency>
<dependency>
<groupId>com.dylibso.chicory</groupId>
<artifactId>runtime</artifactId>
<version>@project.version@</version>
</dependency>
<dependency>
<groupId>com.dylibso.chicory</groupId>
<artifactId>host-module-processor</artifactId>
<version>@project.version@</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.dylibso.chicory</groupId>
<artifactId>wasm-corpus</artifactId>
<version>@project.version@</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>@junit.version@</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>@junit.version@</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>@maven-compiler-plugin.version@</version>
<configuration>
<release>${maven.compiler.release}</release>
<annotationProcessorPaths>
<path>
<groupId>com.dylibso.chicory</groupId>
<artifactId>host-module-processor</artifactId>
<version>@project.version@</version>
</path>
</annotationProcessorPaths>
</configuration>
</plugin>
</plugins>
</build>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
package chicory.test;

import static org.junit.jupiter.api.Assertions.assertEquals;

import com.dylibso.chicory.hostmodule.annotations.HostModule;
import com.dylibso.chicory.hostmodule.annotations.WasmExport;
import com.dylibso.chicory.runtime.ExternalValues;
import com.dylibso.chicory.runtime.Instance;
import com.dylibso.chicory.wasm.Parser;
import java.util.concurrent.atomic.AtomicInteger;
import org.junit.jupiter.api.Test;

class WithImportsTest {
public final AtomicInteger count = new AtomicInteger();

@HostModule("console")
class TestModule {
private static final String EXPECTED = "Hello, World!";
private final Instance instance;

public TestModule() {
instance =
Instance.builder(
Parser.parse(
WithImportsTest.class.getResourceAsStream(
"/compiled/host-function.wat.wasm")))
.withExternalValues(
new ExternalValues(
TestModule_ModuleFactory.toHostFunctions(this)))
.build();
}

public void logIt() {
instance.export("logIt").apply();
}

@WasmExport
public void log(int len, int offset) {
var message = instance.memory().readString(offset, len);

if (EXPECTED.equals(message)) {
count.incrementAndGet();
}
}
}

@Test
public void withImportsModule() {
// Arrange
var withImportsModule = new TestModule();

// Act
withImportsModule.logIt();

// Assert
assertEquals(10, count.get());
}
}
22 changes: 22 additions & 0 deletions host-module/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>com.dylibso.chicory</groupId>
<artifactId>chicory</artifactId>
<version>999-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>host-module-parent</artifactId>
<packaging>pom</packaging>
<name>Chicory - Host Module - Parent</name>
<description>Parent module for the Host Module machinery</description>

<modules>
<module>annotations</module>
<module>it</module>
<module>processor</module>
</modules>

</project>
10 changes: 5 additions & 5 deletions function-processor/pom.xml → host-module/processor/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,19 @@

<parent>
<groupId>com.dylibso.chicory</groupId>
<artifactId>chicory</artifactId>
<artifactId>host-module-parent</artifactId>
<version>999-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>function-processor</artifactId>
<artifactId>host-module-processor</artifactId>
<packaging>jar</packaging>
<name>Chicory - Function annotation processor</name>
<description>Experimental annotation processor for host functions</description>
<name>Chicory - Host Module annotation processor</name>
<description>Experimental annotation processor for host modules</description>

<dependencies>
<dependency>
<groupId>com.dylibso.chicory</groupId>
<artifactId>function-annotations</artifactId>
<artifactId>host-module-annotations</artifactId>
</dependency>
<dependency>
<groupId>com.github.javaparser</groupId>
Expand Down
Loading

0 comments on commit 1bec3ef

Please sign in to comment.