You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Maria Cristina <ma...@gmail.com> on 2012/02/23 19:40:43 UTC

how to copy resources? how to create a zip file with the app jar, the dependent jars and the resources?

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.

Re: how to copy resources? how to create a zip file with the app jar, the dependent jars and the resources?

Posted by Dennis Lundberg <de...@apache.org>.
Hi

You might also want to take a look at appassembler-maven-plugin

http://mojo.codehaus.org/appassembler/appassembler-maven-plugin/

On Thu, Feb 23, 2012 at 7:40 PM, Maria Cristina
<ma...@gmail.com> wrote:
> 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.



-- 
Dennis Lundberg

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: how to copy resources? how to create a zip file with the app jar, the dependent jars and the resources?

Posted by Wayne Fay <wa...@gmail.com>.
> because I'd like to automate my manual steps, I'd like to use Maven to
> automate the creation of a zip file containing:

The assembly plugin is your friend.

Wayne

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org