팻 JAR이란 무엇입니까?
사람들이 뚱뚱한 JAR을 만들어 배포한다고 말하는 것을 들었습니다. 그들은 실제로 무엇을 의미합니까?
뚱뚱한 항아리는 항아리로, 프로젝트가 의존하는 모든 라이브러리의 클래스와 현재 프로젝트의 클래스를 포함합니다.
다른 빌드 시스템에서 지방 병은 다르게 생성됩니다. 예를 들어 Gradle에서 ( 명령어 )로 지방 병을 만듭니다 .
task fatJar(type: Jar) {
manifest {
attributes 'Main-Class': 'com.example.Main'
}
baseName = project.name + '-all'
from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } }
with jar
}
Maven에서는 다음과 같이 수행됩니다 (일반 항아리를 설정 한 후).
<pluginrepositories>
<pluginrepository>
<id>onejar-maven-plugin.googlecode.com</id>
<url>http://onejar-maven-plugin.googlecode.com/svn/mavenrepo</url>
</pluginrepository>
</pluginrepositories>
<!-- ... -->
<plugin>
<groupid>org.dstovall</groupid>
<artifactid>onejar-maven-plugin</artifactid>
<version>1.4.4</version>
<executions>
<execution>
<configuration>
<onejarversion>0.97</onejarversion>
<classifier>onejar</classifier>
</configuration>
<goals>
<goal>one-jar</goal>
</goals>
</execution>
</executions>
</plugin>
Fat jar 또는 uber jar는 모든 프로젝트 클래스 파일과 리소스를 모든 종속성과 함께 묶은 jar입니다. 이러한 효과를 얻는 방법에는 여러 가지가 있습니다.
- 의존성 항아리는 메인 항아리에 복사 된 다음 특수 클래스 로더 (onejar)를 사용하여로드됩니다.
- 의존성 항아리는 기본 jar 계층 구조의 최상위에서 추출됩니다 (자 속성 어셈블리가있는 maven-assembly 플러그인, 음영 목표가있는 maven-shade-plugin)
아래의 샘플 어셈블리 플러그인 구성 jar-with-dependencies :
<project>
...
<build>
...
<plugins>
<plugin>
<!-- NOTE: We don't need a groupId specification because the group is
org.apache.maven.plugins ...which is assumed by default.
-->
<artifactId>maven-assembly-plugin</artifactId>
<version>2.6</version>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<classifier
</configuration>
...
</project>
실행 가능한 jar의 경우, 뚱뚱한 jar를 생각하는 또 다른 방법은 호출하여 실행할 수있는 방법입니다.
java -jar myFatLibrary.jar
-cp
/ / --classpath
또는 jar 아이콘을 두 번 클릭 하지 않아도 됩니다.
다른 이름은 단지 Java 앱을 패키징하는 방법입니다.
스키니 – 문자 그대로 코드 편집기에 입력 한 비트 만 포함하고 다른 비트는 포함하지 않습니다.
Thin – 위의 모든 PLUS와 앱의 앱 직접 종속성 (DB 드라이버, 유틸리티 라이브러리 등)을 모두 포함합니다.
Hollow – The inverse of Thin – Contains only the bits needed to run your app but does NOT contain the app itself. Basically a pre-packaged “app server” to which you can later deploy your app, in the same style as traditional Java EE app servers, but with important differences.
Fat/Uber – Contains the bit you literally write yourself PLUS the direct dependencies of your app PLUS the bits needed to run your app “on its own”.
Source: Article from Dzone
A fat jar simply contains same classes as a classical jar + classes from all of their runtime dependencies.
With Jeka ( https://jeka.dev) you can achieve it programmatically :
JkPathTreeSet.of(Paths.get("classes")).andZips(
Paths.get("bouncycastle-pgp-152.jar"),
Paths.get("classgraph-4.8.41.jar"),
Paths.get("ivy-2.4.0.jar")
).zipTo(Paths.get("fat.jar"));
or just by parametring Java plugin :
javaPlugin.getProject().getMaker().defineMainArtifactAsFatJar(true);
참고URL : https://stackoverflow.com/questions/19150811/what-is-a-fat-jar
'programing tip' 카테고리의 다른 글
조각에서 대화 상자를 표시 하시겠습니까? (0) | 2020.07.24 |
---|---|
"제목"속성의 툴팁 표시 속도 변경 (0) | 2020.07.24 |
src AND 컨텐츠가 포함 된 스크립트 태그는 무엇을 의미합니까? (0) | 2020.07.24 |
안전하지 않은 응답 또는 연결 거부로 인해 Ajax 호출이 실패했는지 판별 (0) | 2020.07.24 |
C #에서는 디스크에서 쓰지 않고 문자열에서 TextReader 개체를 만드는 방법 (0) | 2020.07.23 |