Skip to content

Commit

Permalink
Merge pull request #120 from BlazingTwist/aya-js-pom-profiles
Browse files Browse the repository at this point in the history
Build restructure option 2 : optional execution using profiles
  • Loading branch information
nick-paul authored Dec 5, 2024
2 parents 291196d + 9273006 commit f2f7c41
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 73 deletions.
71 changes: 37 additions & 34 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -64,20 +64,6 @@
</target>
</configuration>
</execution>
<execution>
<id>release-zip</id>
<phase>verify</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target>
<property name="build-dir" value="${project.build.directory}"/>
<property name="aya.jar" value="${project.build.directory}/${project.artifactId}-${project.version}.jar"/>
<ant antfile="${project.basedir}/build-scripts/release-zip-build.xml"/>
</target>
</configuration>
</execution>
</executions>
</plugin>

Expand Down Expand Up @@ -111,6 +97,13 @@
<artifactId>json</artifactId>
<version>20231013</version>
</dependency>

<dependency>
<groupId>org.teavm</groupId>
<artifactId>teavm-jso</artifactId>
<version>0.10.2</version>
<optional>true</optional>
</dependency>
</dependencies>


Expand All @@ -125,18 +118,6 @@
<build>
<plugins>

<!-- Exclude web specific files -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.13.0</version>
<configuration>
<excludes>
<exclude>web/**</exclude>
</excludes>
</configuration>
</plugin>

<!-- Build fat JAR -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
Expand All @@ -157,6 +138,36 @@
</transformer>
</transformers>
<createDependencyReducedPom>false</createDependencyReducedPom>

<!-- exclude teaVM dependency from desktop jar -->
<artifactSet>
<excludes>
<exclude>org.teavm:teavm-classlib</exclude>
</excludes>
</artifactSet>
</configuration>
</execution>
</executions>
</plugin>

<!-- package fat JAR into a release aya.zip -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>3.1.0</version>
<executions>
<execution>
<id>release-zip</id>
<phase>package</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target>
<property name="build-dir" value="${project.build.directory}"/>
<property name="aya.jar" value="${project.build.directory}/${project.artifactId}-${project.version}.jar"/>
<ant antfile="${project.basedir}/build-scripts/release-zip-build.xml"/>
</target>
</configuration>
</execution>
</executions>
Expand Down Expand Up @@ -227,14 +238,6 @@
</plugins>
</build>

<dependencies>
<dependency>
<groupId>org.teavm</groupId>
<artifactId>teavm-jso</artifactId>
<version>0.10.2</version>
</dependency>
</dependencies>

</profile>
</profiles>

Expand Down
2 changes: 1 addition & 1 deletion src/aya/InteractiveAya.java
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ public int loop() {
// Load startup script
String[] args = AyaPrefs.getArgs();
if (args.length >= 2 && args[1].contains(".aya")) {
String startupScript = AyaPrefs.getArgs()[1];
String startupScript = AyaPrefs.getArgs()[1].replace("\\", "\\\\");
StaticBlock blk2 = Parser.compileSafeOrNull(new SourceString("\"" + startupScript + "\":F", "<ayarc loader>"), StaticData.IO);
if (blk2 != null) {
_aya.queueInput(new ExecutionRequest(makeRequestID(), blk2));
Expand Down
54 changes: 16 additions & 38 deletions src/web/AyaWeb.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,14 @@
import aya.exceptions.parser.ParserException;
import aya.ext.color.ColorInstructionStore;
import aya.ext.date.DateInstructionStore;
import aya.ext.graphics.GraphicsInstructionStore;
import aya.ext.json.JSONInstructionStore;
import aya.ext.la.LinearAlgebraInstructionStore;
import aya.io.StringOut;
import aya.io.stdin.EmptyInputWrapper;

public class AyaWeb {

private static StringOut output = new StringOut();
private static final StringOut output = new StringOut();

public static void main(String[] args) {

Expand Down Expand Up @@ -53,48 +52,27 @@ public static void main(String[] args) {
//
// Exported Functions Implementation
//
exportRunIsolated(new ExportFunctionRunIsolated() {
@Override
public String call(String s) {
StandaloneAya.runIsolated(input, StaticData.IO);
return output.flushOut() + output.flushErr();
}
exportRunIsolated(s -> {
StandaloneAya.runIsolated(s, StaticData.IO);
return output.flushOut() + output.flushErr();
});

exportAddFile(new ExportFunctionAddFile() {
@Override
public void call(String path, String content) {
((WebFilesystemIO)(StaticData.FILESYSTEM)).addFile(path, content);
}
});
exportAddFile((path, content) -> ((WebFilesystemIO)(StaticData.FILESYSTEM)).addFile(path, content));

exportListFiles(new ExportFunctionListFiles() {
@Override
public String call() {
ArrayList<String> files = fs.listFiles();
String out = "";
for (String s : files) {
out += s + ",";
}
return out;
exportListFiles(() -> String.join(",", fs.listFiles()));

exportLint(source -> {
ArrayList<ParserException> errors = StandaloneAya.lint(source);
if (errors.size() > 0) {
// TODO: The compile function stops after the first error
// if we update the parser to catch multiple errors, we will need to update this
ParserException err = errors.get(0);
return err.getSource().getIndex() + ":" + err.getSimpleMessage();
} else {
return "";
}
});

exportLint(new ExportFunctionLint() {
@Override
public String call(String source) {
ArrayList<ParserException> errors = StandaloneAya.lint(source);
if (errors.size() > 0) {
// TODO: The compile function stops after the first error
// if we update the parser to catch multiple errors, we will need to update this
ParserException err = errors.get(0);
return err.getSource().getIndex() + ":" + err.getSimpleMessage();
} else {
return "";
}
}
});

}

//
Expand Down

0 comments on commit f2f7c41

Please sign in to comment.