如何使用武装熊常见口齿来制作罐子? [英] How do I create a jar using armed bear common lisp?

查看:54
本文介绍了如何使用武装熊常见口齿来制作罐子?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否有可能使用武装熊常见的lisp创建jar文件,如果可以的话该怎么做.

因此,换句话说,我有以下代码(格式t"Hello,World!〜%"))我可以在武装熊的普通lisp中运行它.我想知道如何创建一个执行该代码的jar.

谢谢

肖恩.

解决方案

文档说(在第3.3节中,对于pdf表示抱歉)-

3.3.2已实现的JSR-223接口

JSR-223定义了三个主要接口,其中两个( Invocable Compilable )是可选的.ABCL实现所有三个接口- ScriptEngine 和两个可选接口-几乎完全地.

通过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.0http://maven.apache.org/xsd/maven-4.0.0.xsd">< modelVersion> 4.0.0</modelVersion>< groupId> com.stackoverflow.example</groupId>< artifactId> ColbertNightmare</artifactId>< version> 1.0.0</version>< packaging> jar</packaging>< name>斯蒂芬·科尔伯特的噩梦-武装的熊</name><依赖关系><依赖关系>< 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><配置>< 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><配置>< descriptorRefs>< descriptorRef>具有依赖关系的</descriptorRef></descriptorRefs>< archive><清单>< addClasspath> true</addClasspath>< mainClass> com.stackoverflow.example.Main</mainClass></manifest></archive></configuration><执行><执行>< id> make-assembly</id>< phase>包装</phase><目标>< goal>单</goal></goals></execution></executions></plugin></plugins></build></project> 

第二步:我们需要遵循Maven标准目录结构.

我们将为入口点提供一个Java类.在包含 pom.xml 的文件夹中,

  mkdir -p src/main/java/com/stackoverflow/example 

如果您使用的是Windows,则需要(相反)

  mkdir src \ main \ java \ com \ stackoverflow \ example 

第三步:编写Java代码(在我们刚刚创建的文件夹中)

创建一个 Main.java 文件,该文件在您的LISP代码中包含(请注意,我已修复了一个额外的)错误)

  package com.stackoverflow.example;导入javax.script.ScriptException;导入org.armedbear.lisp.scripting.AbclScriptEngine;导入org.armedbear.lisp.scripting.AbclScriptEngineFactory;公共班级主要{公共静态void main(String [] args){AbclScriptEngine scriptEngine =(AbclScriptEngine)新的AbclScriptEngineFactory().getScriptEngine();尝试 {scriptEngine.eval((格式t \" Hello,World!〜%\)");} catch(ScriptException e){e.printStackTrace();}}} 

第四步:让我们构建和打包我们的应用程序.

在包含 pom.xml 的文件夹中,

  mvn软件包 

第五步:运行它

  $ java -jar target/ColbertNightmare-jar-with-dependencies.jar你好,世界! 

结论

可以使用类似上述的方法来创建使用ABCL的可执行jar.另外,斯蒂芬·科尔伯特(Stephen Colbert)就熊(在他们武装之前)警告过我们.我认为它们现在是一个更大的威胁.

I was wondering if it's possible to create a jar file using armed bear common lisp and if so how to do it.

So in other words, I have this following code (format t "Hello, World!~%")) I can run it in armed bear common lisp. I was wondering how I could create a jar that executes that code.–

Thanks,

Shaun.

解决方案

The documentation says (in section 3.3, sorry for the 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.

Creating an executable jar with ABCL in five easy steps

Step one: Creating a fat jar containing Armed Bear.

I'm going to use maven because it's what I know. Let's create a pom.xml file.

<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.stackoverflow.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.stackoverflow.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>    

Step two: We need to follow the maven standard directory structure.

We will have one Java class for an entry point. In the folder containing pom.xml,

mkdir -p src/main/java/com/stackoverflow/example

If you're on Windows, you need to (instead)

mkdir src\main\java\com\stackoverflow\example

Step three: Write the Java code (in the folder we just created)

Create a Main.java file containing (note I fixed an extra ) bug in your LISP code)

package com.stackoverflow.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();
        }
    }
}

Step four: Let's build and package our application.

In the folder containing the pom.xml,

mvn package

Step five: Run it

$ java -jar target/ColbertNightmare-jar-with-dependencies.jar
Hello, World!

Conclusion

Something like the above can be used to create an executable jar that uses ABCL. Also, Stephen Colbert warned us about bears (before they were armed). I think they're an even bigger threat now.

这篇关于如何使用武装熊常见口齿来制作罐子?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆