Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 860297
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T08:47:44+00:00 2026-05-15T08:47:44+00:00

We use MySQL in production, and Derby for unit tests. Our pom.xml copies Derby

  • 0

We use MySQL in production, and Derby for unit tests. Our pom.xml copies Derby version of persistence.xml before tests, and replaces it with the MySQL version in prepare-package phase:

 <plugin>
  <artifactId>maven-antrun-plugin</artifactId>
  <version>1.3</version>
  <executions>
   <execution>
    <id>copy-test-persistence</id>
    <phase>process-test-resources</phase>
    <configuration>
     <tasks>
      <!--replace the "proper" persistence.xml with the "test" version-->
      <copy
       file="${project.build.testOutputDirectory}/META-INF/persistence.xml.test"
       tofile="${project.build.outputDirectory}/META-INF/persistence.xml"
       overwrite="true" verbose="true" failonerror="true" />
     </tasks>
    </configuration>
    <goals>
     <goal>run</goal>
    </goals>
   </execution>
   <execution>
    <id>restore-persistence</id>
    <phase>prepare-package</phase>
    <configuration>
     <tasks>
      <!--restore the "proper" persistence.xml-->
      <copy
       file="${project.build.outputDirectory}/META-INF/persistence.xml.production"
       tofile="${project.build.outputDirectory}/META-INF/persistence.xml"
       overwrite="true" verbose="true" failonerror="true" />
     </tasks>
    </configuration>
    <goals>
     <goal>run</goal>
    </goals>
   </execution>
  </executions>
 </plugin>

The problem is, that if I execute mvn jetty:run it will execute the test persistence.xml file copy task before starting jetty. I want it to be run using the deployment version. How can I fix this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T08:47:45+00:00Added an answer on May 15, 2026 at 8:47 am

    The jetty:run goal invokes the execution of the lifecycle phase test-compile prior to executing itself. So skipping tests execution won’t change anything.

    What you need to do is to bind the copy-test-persistence execution to a lifecycle phase posterior to test-compile but prior to test. And there aren’t dozen of candidates but only one: process-test-classes.

    That’s conceptually maybe not ideal, but it’s the least worse option, and it will work:

     <plugin>
      <artifactId>maven-antrun-plugin</artifactId>
      <version>1.3</version>
      <executions>
       <execution>
        <id>copy-test-persistence</id>
        <phase>process-test-classes</phase>
        <configuration>
         <tasks>
          <!--replace the "proper" persistence.xml with the "test" version-->
          <copy
           file="${project.build.testOutputDirectory}/META-INF/persistence.xml.test"
           tofile="${project.build.outputDirectory}/META-INF/persistence.xml"
           overwrite="true" verbose="true" failonerror="true" />
         </tasks>
        </configuration>
        <goals>
         <goal>run</goal>
        </goals>
       </execution>
       ...
      </executions>
     </plugin>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In my django project, I use mysql db for production, and sqlite for tests.
I want to use GenerationType.IDENTITY for primary keys in my production MySQL system. But
Locally I use sqllite3 as a database, but in production I use MySQL. When
So in rails I use sqlite3 for development and mysql for production. Sqlite3 and
We currently use a Dell Equalogic SAN to snapshot our MySQL databases and copy
I want to develop on sql server database and use MySql for production. I've
MySQL 6.0 is for production. Can I use it for database storage of a
I want to use Mysql on my local and PostgreSQL on production server. How
I use MySQL 5.5.16. I'm trying to check if a certain column exists in
We use MYSQL InnoDB engine for insert and update operations, in order to improve

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.