maven-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Maria Cristina <maria.cristina.ma...@gmail.com>
Subject how to copy resources? how to create a zip file with the app jar, the dependent jars and the resources?
Date Thu, 23 Feb 2012 18:40:43 GMT
Sorry for the duplicate post. I am new to Maven and need some help. This
what I currently have:

1.
my project's src/main/resources contains two packages:
the default package contains two files jndi.properties and log4j.properties
another package named company.it.app.i18n contains one file called
MessageResourceBundle.properties

2.
my pom includes:
  <build>
      <plugins>
          <plugin>
              <groupId>org.apache.maven.plugins</groupId>
              <artifactId>maven-jar-plugin</artifactId>
              <version>2.4</version>
              <configuration>
                  <archive>
                      <manifest>
                          <addClasspath>true</addClasspath>
                          <mainClass>company.it.app.MyApp</mainClass>
                      </manifest>
                      <manifestEntries>
                          <Class-Path>config/</Class-Path>
                      </manifestEntries>
                  </archive>
              </configuration>
          </plugin>
      </plugins>
  </build>


3.
my class references the resource bundle as follows:
private static final String BUNDLE_NAME =
"company.it.app.i18n.MessageResourceBundle";

4.
inside the generated executable jar file app-1.0.jar contains:

(i)
in the manifest the following class path and main class:
Class-Path: config/ log4j-1.2.7.jar (and other dependent jars)
Main-Class: company.it.app.MyApp

(ii)
config/jndi.properties
config/log4j.properties

(iii)
company\it\app\i18n\MessageResourceBundle.properties

my IDE results is successful:
clean and build works and the JUnit tests run successfully

then I do several manual steps
copy app-1.0.jar to a my destination folder named testapp
remove jndi.properties and log4j.properties from app-1.0.jar and copy to a
folder named config in folder testapp
copy log4j-1.2.7.jar (and other dependent jars) to the folder testapp

my command line result is successful:
java -jar app-1.0.jar

I'd like to make some changes to achieve the following:

because I'd like to automate my manual steps, I'd like to use Maven to
automate the creation of a zip file containing:

app-1.0.jar
lib/log4j-1.2.7.jar (and other dependent jars)
config/jndi.properties
config/log4j.properties

I've been trying and I don't know how to copy the resources to the config
folder without breaking the JUnit tests. Is it possible, if so how? How
would I create the zip with the structure?

Thanks in advance.

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message