• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Altering files created in target directory?

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have an application built with maven that produces a war file(maven-war-plugin). The war file contains a dependency that i need to modify at runtime, so I have used maven-antrun-plugin to run an ant task to explode the dependency from the target folder, modify it, put it back together and keep it in the target directory.

The problem with this is that the modification happens after the war has been packaged and therefore the modifications i make are not picked up.

I tried to alter the order they are run using the below, however when I do that it gets an error because the target folder has not been created yet??? Is there anyway to modify artifacts in the target folder before the war file is packaged? If not can someone suggest an alternative.

The dependency is pulled from a repo.


 
Saloon Keeper
Posts: 12154
258
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to CodeRanch, Ian!

You must configure the war:exploded goal to specify the source and target locations.
 
Ian Allan
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Stephan van Hulst wrote:Welcome to CodeRanch, Ian!

You must configure the war:exploded goal to specify the source and target locations.



Hi Stephan, thanks for the advice - do you happen to have an example of that? Before I split the maven-war-plugin into different tasks it automatically created the TARGET files in {project.base}/target without it being defined. Is this not the case anymore?
 
Stephan van Hulst
Saloon Keeper
Posts: 12154
258
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not sure why you're disabling the default-war execution in the first place. It does the same thing as your custom-war execution.

Why don't you just run your ant script in the prepare-package phase?
 
Stephan van Hulst
Saloon Keeper
Posts: 12154
258
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also, I don't understand why you're using war:exploded if your ant script already explodes the dependency.
 
Stephan van Hulst
Saloon Keeper
Posts: 12154
258
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Isn't it easier to make a separate project for the dependency by the way? This project is responsible for creating the updated war. Then all you have to do is declare a dependency on this project from your main project.
 
Ian Allan
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am new to maven so maybe I am going about it the wrong way.

The project I have pulls down multiple jars etc and builds a .war, these jars end up in the {project.base}/target directory. This was all done using the standard maven-war-plugin.

Now I have just introduced a maven ant script that pulls the jar from the above directory, puts it in a tmp folder, modifies it and then places it back in target. This was done after the war was built so it wasn't picking it up.

After some research it seemed the best way to modify resources that will be used by the war was to explode it and then run the ant script and then package. Which is what i am trying to do in my code snippet above.

Unfortunately i have to modify it at runtime due to a locked down environment. So using the code i have is there anyway I can get this to work?
 
Stephan van Hulst
Saloon Keeper
Posts: 12154
258
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Ian Allan wrote:Unfortunately i have to modify it at runtime due to a locked down environment.


That makes no sense to me. Runtime of what?
 
Ian Allan
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Stephan van Hulst wrote:

Ian Allan wrote:Unfortunately i have to modify it at runtime due to a locked down environment.


That makes no sense to me. Runtime of what?



I need to modify the concerned jar during the maven build phase. I can't create any new versions of it.

When is the target directory created - is it after war exploded or after package?
 
I don't get it. A whale wearing overalls? How does that even work? It's like a tiny ad wearing overalls.
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic