我正在寻找蟒蛇世界中相当于超级罐的东西.
它必须是跨平台分发,因此我不必为多个目标构建.也就是说,我应该可以在所有平台上运行它,如下所示:
python package.ext
您可以假设该包是纯python(没有本机代码). 有什么能满足这些要求吗?
我知道以下选项,每个选项都有不足之处:
.whl包需要pip安装..egg包含所有包依赖项..zip文件,但AFAICT,创建这样一个zip的最佳工具是pex(https://github.com/pantsbuild/pex),我认为不支持Windows我有以下 gradle 构建配置:
plugins {
id 'com.github.johnrengelman.shadow' version '1.2.3'
}
group 'abc'
version '1.0-SNAPSHOT'
apply plugin: 'java'
apply plugin: 'application'
mainClassName = "abc.Driver"
repositories {
mavenCentral()
}
dependencies {
compile (group: 'org.apache.hadoop', name: 'hadoop-client', version: '2.6.0')
}
sourceSets {
main {
java {
srcDir './src'
}
}
}
jar {
manifest {
attributes(
'Class-Path': configurations.compile.collect { it.getName() }.join(' '),
'Main-Class': mainClassName
)
}
}
task fatJar(type: Jar) {
manifest {
attributes 'Implementation-Title': 'Gradle Jar File Example',
'Implementation-Version': version,
'Main-Class': mainClassName …Run Code Online (Sandbox Code Playgroud) 所以我目前有这个代码:
(ns contact-form.core
(:gen-class))
(def foo "Hello World!")
(defn some-func [a-symbol]
(println (str a-symbol "'s value is: " (eval a-symbol))))
(defn -main [& args]
(some-func 'foo))
Run Code Online (Sandbox Code Playgroud)
我这样做之后C-c C-k在Emacs,我得到以下的输出:
contact-form.core> (-main)
foo's value is: Hello World!
nil
Run Code Online (Sandbox Code Playgroud)
但是当我执行lein uberjar并运行生成的jar文件时,我收到一个错误:
Exception in thread "main" java.lang.RuntimeException: Unable to resolve symbol: foo in this context, compiling:(NO_SOURCE_PATH:0)
at clojure.lang.Compiler.analyze(Compiler.java:6235)
at clojure.lang.Compiler.analyze(Compiler.java:6177)
at clojure.lang.Compiler.eval(Compiler.java:6469)
at clojure.lang.Compiler.eval(Compiler.java:6431)
at clojure.core$eval.invoke(core.clj:2795)
at contact_form.core$some_func.invoke(core.clj:7)
at contact_form.core$_main.doInvoke(core.clj:10)
at clojure.lang.RestFn.invoke(RestFn.java:397)
at clojure.lang.AFn.applyToHelper(AFn.java:159)
at clojure.lang.RestFn.applyTo(RestFn.java:132)
at contact_form.core.main(Unknown Source)
Caused …Run Code Online (Sandbox Code Playgroud) 我使用lein uberjar创建一个独立的应用程序jar.
执行时
java -jar dataloader-0.1.0-SNAPSHOT-standalone.jar,
Run Code Online (Sandbox Code Playgroud)
它崩溃了:
Caused by: java.lang.IllegalArgumentException: Not a file:
jar:file:dataloader-0.1.0-SNAPSHOT-standalone.jar!/configuration.json
Run Code Online (Sandbox Code Playgroud)
我通过以下方式加载文件:
(ns dataloader.configuration
(:gen-class)
(:require [cheshire.core :refer :all]
[clojure.java.io :as io]))
(def data-file
(io/file
(io/resource "configuration.json")))
Run Code Online (Sandbox Code Playgroud)
project.clj
(defproject dataloader "0.1.0-SNAPSHOT"
:description "Used for loading stage data into local vagrantbox"
:url "http://example.com/FIXME"
:license {:name "Eclipse Public License"
:url "http://www.eclipse.org/legal/epl-v10.html"}
:resource-paths ["resources"]
:dependencies [[org.clojure/clojure "1.6.0"]
[clojurewerkz/elastisch "2.1.0"]
[org.clojure/java.jdbc "0.3.7"]
[mysql/mysql-connector-java "5.1.32"]
[clj-http "2.0.0"]
[org.clojure/data.json "0.2.6"]
[org.clojure/data.codec "0.1.0"]
[cheshire "5.5.0"]]
:main ^:skip-aot dataloader.core
:target-path "target/%s"
:profiles {:uberjar {:aot :all}}) …Run Code Online (Sandbox Code Playgroud) I have question. How to make fat jar for JavaFX app using Ant? I know that in Internet is a few tutrials, but it concerns Java apps, not JavaFX apps. I conlude that is difference, because i tried to follow this tutorials, and it works for Java apps, but in JavaFX apps with fxml files after attempt run app, it returns NullPointerException: location is required (and yes, i tried modificate path to fxml files, and use ClassLoader, it dosesn't help). …
我正在尝试隐藏依赖项(构建 uber jar)并在其他项目中导入。在 uber jar 中我可以看到类,但是当我尝试导入阴影文件夹/包时不显示。下面是我的 pom.xmls
带有阴影依赖项和 uber jar 的 Test1
<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>test</groupId>
<artifactId>test</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<properties>
<jdk.version>1.8</jdk.version>
<jodatime.version>2.5</jodatime.version>
</properties>
<dependencies>
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>${jodatime.version}</version>
</dependency>
</dependencies>
<build>
<finalName>test</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-eclipse-plugin</artifactId>
<version>3.1.0</version>
<configuration>
<downloadSources>true</downloadSources>
<downloadJavadocs>false</downloadJavadocs>
</configuration>
</plugin>
<!-- Set a compiler level -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<configuration>
<source>${jdk.version}</source>
<target>${jdk.version}</target>
</configuration>
</plugin>
<!-- Maven Shade Plugin -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.1.0</version>
<executions>
<!-- Run shade goal on package phase -->
<execution>
<phase>package</phase> …Run Code Online (Sandbox Code Playgroud) 下面是一个简单的Clojure应用程序示例lein new mw:
(ns mw.core
(:gen-class))
(def fs (atom {}))
(defmacro op []
(swap! fs assoc :macro-f "somevalue"))
(op)
(defn -main [& args]
(println @fs))
Run Code Online (Sandbox Code Playgroud)
在project.clj我有
:profiles {:uberjar {:aot [mw.core]}}
:main mw.core
Run Code Online (Sandbox Code Playgroud)
在REPL中运行时,评估@fs返回值{:macro-f somevalue}.但是,运行一个uberjar收益率{}.如果我改为op定义defn而不是defmacro,那么fs当从uberjar运行时再次有适当的内容.这是为什么?
我隐约意识到这与AOT编译有关,并且宏编译在编译阶段之前发生,但显然我对这些事情的理解是缺乏的.
我在尝试部署使用非常好的mixfix库的应用程序时遇到了这个问题,其中mixfix运算符是使用全局原子定义的.我花了很长时间才将问题与上面提到的例子隔离开来.
任何帮助将不胜感激.
谢谢!
我在{project_home} / src / test / groovy /中进行了一些功能测试
我希望能够使用gradle任务:
使用{project_home} / src / test / groovy /下的所有.groovy文件(包括所有依赖项)制作一个jar文件
能够运行此jar文件来代替运行单个groovy文件
我遇到的所有示例都有一个main方法,而我没有main()
所以我试图使用“项目的” build.gradle并附加
task fatJar(type: Jar) {
baseName = project.name + '-all'
from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } }
with jar
}
Run Code Online (Sandbox Code Playgroud)
跑了 $gradle clean fatJar
但是编译失败:
:Tests:EndToEndFunctionalTests:fatJar FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':Tests:EndToEndFunctionalTests:fatJar'.
> archive contains more than 65535 entries.
To build this archive, please enable the …Run Code Online (Sandbox Code Playgroud) 我正在构建一个简单的Web应用程序,该应用程序依赖于几个预编译的jar,并且要在Heroku上进行部署。我将罐子放到一个resources文件夹中,并在其中添加了以下几行project.clj:
:resource-paths ["resources/jsesh-6.5.5.jar"
"resources/jseshGlyphs-6.5.5.jar"
"resources/java-cup-11b-runtime.jar"
"resources/java-cup-11b.jar"
"resources/qenherkhopeshefUtils-6.5.5.jar"]
Run Code Online (Sandbox Code Playgroud)
现在,我可以使用运行项目了lein run -m hieroglyphs.web;但是,当我编译所有内容lein uberjar并尝试
java -cp ./target/hieroglyphs-standalone.jar clojure.main -m hieroglyphs.web
Run Code Online (Sandbox Code Playgroud)
程序启动,但是java.lang.NoClassDefFoundError当尝试访问这些jar中定义的类之一时,崩溃并显示为:
java.lang.NoClassDefFoundError: jsesh/mdcDisplayer/preferences/DrawingSpecification
Run Code Online (Sandbox Code Playgroud)
我是否应该做些额外的事情,以便编译后可以访问jar中定义的类?
所有代码都可以在这里找到:https : //github.com/macleginn/jsesh-web
如何重命名和移动使用 SBT 程序集插件生成的 uberjar?
addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.14.6")
Run Code Online (Sandbox Code Playgroud)
我的 assemblyMergeStrategy(用于 META-INF 删除):
assemblyMergeStrategy in assembly := {
case PathList("META-INF", xs @ _*) => MergeStrategy.discard
case x => MergeStrategy.first
}
Run Code Online (Sandbox Code Playgroud)
它会生成类似以下内容的内容:
target/scala-2.12/my-project-assembly-0.1.jar
Run Code Online (Sandbox Code Playgroud)
我希望能够使用一致的名称(不需要单独的脚本)自动重命名(并在另一个目录中生成)。