I'm using Eclipse and Maven on this project. I need to keep the log4j.properties
file available for change after the code is packaged into a JAR file therefore I can't put that file in src/main/resources
as mentioned in this post.
I found this post saying that I could add arguments to my Java call but I really wanted to do that by configuration (if possible, of course).
This reply to the first mentioned post was the closest solution I could find. It shows how to make properties files exported along with the JAR package file.
However I can't make it work when I put the properties file in a folder called CONF
. Anyone can tell what I'm doing wrong? Check below my project structure and a portion of my pom.xml.
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<targetPath>${basedir}/target</targetPath>
<includes>
<include>conf/log4j.properties</include>
<include>conf/configuracoes.properties</include>
<include>conf/aws.properties</include>
</includes>
</resource>
</resources>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.2</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.2</version>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<archive>
<manifest>
<mainClass>br.com.aplicacao.ProgramLauncher</mainClass>
</manifest>
<manifestEntries>
<Class-Path>./conf</Class-Path>
</manifestEntries>
</archive>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
</build>