StackOverflowには非常によく似た質問がいくつかありますが、機能するものを見つけるのに苦労しています。
今のところ、ビルドされたJarからlog4jを削除しようとしています。
私は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.icf.onecpd</groupId>
<artifactId>pdfgen</artifactId>
<version>1.1</version>
<packaging>jar</packaging>
<name>PDF Generator</name>
<url></url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.itextpdf</groupId>
<artifactId>itextpdf</artifactId>
<version>5.2.0</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
<scope>runtime</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<executions>
<execution>
<id>default-compile</id>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
<phase>compile</phase>
<goals>
<goal>compile</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<descriptors>
<descriptor>assembly.xml</descriptor>
</descriptors>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</plugin>
</plugins>
</build>
<scm>
<url>https://svn.tms.icfi.com/svn/HUD/onecpd/income_calculator_pdf_generator</url>
</scm>
</project>
assembly.xml:
<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd">
<dependencySets>
<dependencySet>
<excludes>
<exclude>log4j:log4j:*</exclude>
</excludes>
</dependencySet>
</dependencySets>
</assembly>
アセンブリ:単一ログ:
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building PDF Generator 1.1
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-assembly-plugin:2.2-beta-5:single (default-cli) @ pdfgen ---
[INFO] Reading assembly descriptor: assembly.xml
[INFO] META-INF/MANIFEST.MF already added, skipping
[INFO] META-INF/ already added, skipping
[INFO] META-INF/maven/ already added, skipping
[INFO] Building jar: /home/jamie/workspace_ruby2/onecpd_pdfgen/target/pdfgen-1.1-jar-with-dependencies.jar
[INFO] META-INF/MANIFEST.MF already added, skipping
[INFO] META-INF/ already added, skipping
[INFO] META-INF/maven/ already added, skipping
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 5.368s
[INFO] Finished at: Wed Mar 20 13:45:33 EDT 2013
[INFO] Final Memory: 8M/158M
[INFO] ------------------------------------------------------------------------
ただし、結果のJarには、/ org / apache /log4j/クラスが含まれることになります。
どうすればそれらを取り除くことができますか?
ありがとう!