• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

tell maven to selectively choose dir/files

 
Ranch Hand
Posts: 170
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
suppose in my src/ folder I have some environment specific files/folder, when I run maven on different env, I want to just pick files under that env folder and compile.  How can maven do that in pom.xml ?  
 
Sheriff
Posts: 7125
184
Eclipse IDE Postgres Database VI Editor Chrome Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm not sure.  It might be easier to use Ant or Gradle for this task.  Or maybe someone with more Maven knowledge will answer.
 
Saloon Keeper
Posts: 15510
363
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I find it extremely suspicious that your compilation depends on the environment you're on. Can you explain why you want to do this, maybe we can suggest a method that fits within Maven's philosophy.
 
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Linwood,
A common way is to use operating system specific Maven profiles. This is good for things like having a different directory location for tools based on your OS. I think this is what you are asking.

If you want to run one build and generate artifacts by OS, you'd use classifiers so you could create multiple artifacts.

 
Linwood Hayes
Ranch Hand
Posts: 170
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Stephan van Hulst wrote:I find it extremely suspicious that your compilation depends on the environment you're on. Can you explain why you want to do this, maybe we can suggest a method that fits within Maven's philosophy.



for example, if I have some properties files that are different per environment.  
 
Linwood Hayes
Ranch Hand
Posts: 170
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Linwood Hayes wrote:

Stephan van Hulst wrote:I find it extremely suspicious that your compilation depends on the environment you're on. Can you explain why you want to do this, maybe we can suggest a method that fits within Maven's philosophy.



for example, if I have some properties files that are different per environment.  



properties files may be one thing, but what if I have java code that I want it to execute different things based on different environment ? To make it simple, I can create few similar classes , each for one environment but with some similarities.  When running against one environment I don't need to compile the other similar codes.
 
Stephan van Hulst
Saloon Keeper
Posts: 15510
363
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Like Jeanne said, the best way is to use profiles.
 
Saloon Keeper
Posts: 27764
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Profiles are a feature that should be used very sparingly. I have used them, for example, to make a POM that could build a WAR for either the Tomcat or IBM iSeries WebSphere servers, since Tomcat doesn't have the full JEE stack and therefore needed extra libraries in the product WAR. But in general, you should be able to hand a cleaned Maven project to anyone anywhere on the planet, and armed with nothing more that the basic Maven system, a JDK and a live Internet connection and be able to build a fully-functional product from a single command.

I don't recall anything about how to filter source directories. That kind of stuff is what I historically did with Ant. Usually I have conditional dependencies in my profiles.

For details on Maven profiles, see https://maven.apache.org/guides/introduction/introduction-to-profiles.html And note that the first paragraph in the topic is a warning about making projects non-portable.
 
Police line, do not cross. Well, this tiny ad can go through:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic