Skip to content

Commit 033f8e7

Browse files
committed
Merge pull request iluwatar#287 from l-cortese/master
log4j.xml relocated and excluded from JAR
2 parents 2719932 + bf65168 commit 033f8e7

File tree

2 files changed

+66
-21
lines changed

2 files changed

+66
-21
lines changed

dao/pom.xml

Lines changed: 66 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,69 @@
11
<?xml version="1.0"?>
22
<project
3-
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
4-
xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
5-
<modelVersion>4.0.0</modelVersion>
6-
<parent>
7-
<groupId>com.iluwatar</groupId>
8-
<artifactId>java-design-patterns</artifactId>
9-
<version>1.8.0-SNAPSHOT</version>
10-
</parent>
11-
<artifactId>dao</artifactId>
12-
13-
<dependencies>
14-
<dependency>
15-
<groupId>junit</groupId>
16-
<artifactId>junit</artifactId>
17-
<scope>test</scope>
18-
</dependency>
19-
<dependency>
20-
<groupId>log4j</groupId>
21-
<artifactId>log4j</artifactId>
22-
</dependency>
23-
</dependencies>
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
4+
xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
5+
<modelVersion>4.0.0</modelVersion>
6+
<parent>
7+
<groupId>com.iluwatar</groupId>
8+
<artifactId>java-design-patterns</artifactId>
9+
<version>1.8.0-SNAPSHOT</version>
10+
</parent>
11+
<artifactId>dao</artifactId>
12+
13+
<dependencies>
14+
<dependency>
15+
<groupId>junit</groupId>
16+
<artifactId>junit</artifactId>
17+
<scope>test</scope>
18+
</dependency>
19+
<dependency>
20+
<groupId>log4j</groupId>
21+
<artifactId>log4j</artifactId>
22+
</dependency>
23+
</dependencies>
24+
25+
<build>
26+
27+
<!--
28+
log4j.xml file will be copied both in ${project.build.outputDirectory}
29+
and ${project.build.directory}. Thanks to Sean Patrick Floyd
30+
(http://stackoverflow.com/questions/5637532/maven-how-to-place-resource-file-together-with-jar)
31+
-->
32+
33+
<resources>
34+
<resource> <!-- regular processing for every resource file -->
35+
<directory>src/main/resources</directory>
36+
</resource>
37+
<resource> <!-- processing with a different output directory for log4j.xml -->
38+
<directory>src/main/resources</directory>
39+
<includes>
40+
<include>log4j.xml</include>
41+
</includes>
42+
<targetPath>..</targetPath> <!-- relative to target/classes i.e. ${project.build.directory} -->
43+
</resource>
44+
</resources>
45+
46+
<plugins>
47+
48+
<!--
49+
This will exclude log4j.xml file from generated JAR
50+
-->
51+
<plugin>
52+
<groupId>org.apache.maven.plugins</groupId>
53+
<artifactId>maven-jar-plugin</artifactId>
54+
<version>2.6</version>
55+
<configuration>
56+
<excludes>
57+
<exclude>log4j.xml</exclude>
58+
</excludes>
59+
<archive>
60+
<manifest>
61+
<addClasspath>true</addClasspath>
62+
</manifest>
63+
</archive>
64+
</configuration>
65+
</plugin>
66+
67+
</plugins>
68+
</build>
2469
</project>

0 commit comments

Comments
 (0)