如何使用 armed bear common lisp 创建一个 jar?
How do I create a jar using armed bear common lisp?
我想知道是否可以使用 armed bear common lisp 创建一个 jar 文件,如果可以如何创建。
所以换句话说,我有以下代码(格式 t "Hello, World!~%"))我可以 运行 它在 armed bear common lisp 中。我想知道如何创建一个执行该代码的 jar。–
谢谢,
肖恩。
documentation 说(在第 3.3 节中,对 pdf 表示抱歉)-
3.3.2 Implemented JSR-223 interfaces
JSR-223 defines three main interfaces, of which two (Invocable
and Compilable
) are optional.
ABCL implements all the three interfaces - ScriptEngine
and the two optional ones - almost
completely.
使用 ABCL 通过五个简单步骤创建可执行 jar
第一步:创建一个装有 Armed Bear 的脂肪罐。
我打算使用 maven,因为这是我所知道的。让我们创建一个 pom.xml
文件。
<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>
<groupId>com.Whosebug.example</groupId>
<artifactId>ColbertNightmare</artifactId>
<version>1.0.0</version>
<packaging>jar</packaging>
<name>Stephen Colbert's Nightmare - Armed Bears</name>
<dependencies>
<dependency>
<groupId>org.abcl</groupId>
<artifactId>abcl</artifactId>
<version>1.6.0</version>
</dependency>
</dependencies>
<build>
<finalName>ColbertNightmare</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.2.0</version>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<mainClass>com.Whosebug.example.Main</mainClass>
</manifest>
</archive>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
第二步:我们需要遵循maven标准的目录结构。
我们将有一个 Java class 作为入口点。在包含 pom.xml
、
的文件夹中
mkdir -p src/main/java/com/Whosebug/example
如果您在 Windows,则需要(改为)
mkdir src\main\java\com\Whosebug\example
第三步:编写Java代码(在我们刚刚创建的文件夹中)
创建一个 Main.java
文件,其中包含(注意我修复了您 LISP 代码中的一个额外 )
错误)
package com.Whosebug.example;
import javax.script.ScriptException;
import org.armedbear.lisp.scripting.AbclScriptEngine;
import org.armedbear.lisp.scripting.AbclScriptEngineFactory;
public class Main {
public static void main(String[] args) {
AbclScriptEngine scriptEngine = (AbclScriptEngine) new AbclScriptEngineFactory()
.getScriptEngine();
try {
scriptEngine.eval("(format t \"Hello, World!~%\")");
} catch (ScriptException e) {
e.printStackTrace();
}
}
}
第四步:让我们构建并打包我们的应用程序。
在包含 pom.xml
、
的文件夹中
mvn package
第五步:运行它
$ java -jar target/ColbertNightmare-jar-with-dependencies.jar
Hello, World!
结论
类似上面的内容可用于创建使用 ABCL 的可执行 jar。此外,Stephen Colbert 警告我们注意熊(在它们武装起来之前)。我认为他们现在是一个更大的威胁。
我想知道是否可以使用 armed bear common lisp 创建一个 jar 文件,如果可以如何创建。
所以换句话说,我有以下代码(格式 t "Hello, World!~%"))我可以 运行 它在 armed bear common lisp 中。我想知道如何创建一个执行该代码的 jar。–
谢谢,
肖恩。
documentation 说(在第 3.3 节中,对 pdf 表示抱歉)-
3.3.2 Implemented JSR-223 interfaces
JSR-223 defines three main interfaces, of which two (
Invocable
andCompilable
) are optional. ABCL implements all the three interfaces -ScriptEngine
and the two optional ones - almost completely.
使用 ABCL 通过五个简单步骤创建可执行 jar
第一步:创建一个装有 Armed Bear 的脂肪罐。我打算使用 maven,因为这是我所知道的。让我们创建一个 pom.xml
文件。
<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>
<groupId>com.Whosebug.example</groupId>
<artifactId>ColbertNightmare</artifactId>
<version>1.0.0</version>
<packaging>jar</packaging>
<name>Stephen Colbert's Nightmare - Armed Bears</name>
<dependencies>
<dependency>
<groupId>org.abcl</groupId>
<artifactId>abcl</artifactId>
<version>1.6.0</version>
</dependency>
</dependencies>
<build>
<finalName>ColbertNightmare</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.2.0</version>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<mainClass>com.Whosebug.example.Main</mainClass>
</manifest>
</archive>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
第二步:我们需要遵循maven标准的目录结构。
我们将有一个 Java class 作为入口点。在包含 pom.xml
、
mkdir -p src/main/java/com/Whosebug/example
如果您在 Windows,则需要(改为)
mkdir src\main\java\com\Whosebug\example
第三步:编写Java代码(在我们刚刚创建的文件夹中)
创建一个 Main.java
文件,其中包含(注意我修复了您 LISP 代码中的一个额外 )
错误)
package com.Whosebug.example;
import javax.script.ScriptException;
import org.armedbear.lisp.scripting.AbclScriptEngine;
import org.armedbear.lisp.scripting.AbclScriptEngineFactory;
public class Main {
public static void main(String[] args) {
AbclScriptEngine scriptEngine = (AbclScriptEngine) new AbclScriptEngineFactory()
.getScriptEngine();
try {
scriptEngine.eval("(format t \"Hello, World!~%\")");
} catch (ScriptException e) {
e.printStackTrace();
}
}
}
第四步:让我们构建并打包我们的应用程序。
在包含 pom.xml
、
mvn package
第五步:运行它
$ java -jar target/ColbertNightmare-jar-with-dependencies.jar
Hello, World!
结论
类似上面的内容可用于创建使用 ABCL 的可执行 jar。此外,Stephen Colbert 警告我们注意熊(在它们武装起来之前)。我认为他们现在是一个更大的威胁。