Daniel, I saw your post on the Maven User Wiki and in short, what you want to do is not possible in M2. You can set properties in the pom itself using <property> (or in a profile), but you can't set values in an external myproj.properties file and expect Maven to pull things from there into the pom.
This was available in M1 and the dev team decided that it was a bad idea, and so in M2 the pom itself is the "one true source" of this kind of information. You could perhaps create your own plugin to parse a properties file and insert the values into the project object, but I'm not sure how well (or if) it would work. You can probably use the buildnumber plugin as a starting point for you own plugin. Wayne On 1/24/08, Allen, Daniel <[EMAIL PROTECTED]> wrote: > That's exactly the kind of thing I was looking for; thanks! > > Now, to figure out how to set my own, from a file. > > -----Original Message----- > From: Matthew Tordoff [mailto:[EMAIL PROTECTED] > Sent: Thursday, January 24, 2008 12:10 PM > To: Maven Users List > Subject: RE: Questions: Automatically-set tokens in Maven 2 & loading > properties from files > > Hi Dan, > > This is a pretty good list of the 'tokens' or properties that are > available in Maven2: > > http://docs.codehaus.org/display/MAVENUSER/MavenPropertiesGuide > > Matt > > -----Original Message----- > From: Allen, Daniel [mailto:[EMAIL PROTECTED] > Sent: 24 January 2008 13:07 > To: [email protected] > Subject: Questions: Automatically-set tokens in Maven 2 & loading > properties from files > > I'm new to Maven, and have a couple questions that I've not been able to > answer from the documentation on the site so far, so I thought I'd put > them out here. > > -What I'm trying to do > Basically, I have the Maven 1 maven.xml file copied below (which, as you > can see, actually does a lot of its work via Ant call-throughs), and > have been assigned to convert the project to Maven 2. I've pasted the > contents of maven.xml below, at the bottom of the message. Basically, > the idea was to have 3 goals: live1, live2 (identical except for server > names--we run the app on a small cluster), and dev. Each has its own > property file, which is loaded into Maven's properties, and then used to > fill in various tokens in config files. It seems like "goals" are gone > in Maven 2, so I'm trying to replace that idea with different profiles, > but I'm encountering a couple of problems in the conversion. > > -Questions > First, is there a comprehensive list of the tokens that are > automatically set in Maven 2? I'm talking about things like ${basedir}, > which is the only one I've been able to uncover so far, that maven > assigns values to without needed to read them from a file somewhere. I'm > loooking especially for a Maven 2 equivalent to ${maven.war.webapp.dir}, > which apparently was set in the Maven 1 war plugin, but not in the Maven > 2 version. I assume it's still there, but I don't see anything to > indicate what it's called now. > > Second, as I mentioned, the old goals loaded their particular properties > files into Maven. This is where things like ${email.reports} come from > in the copy/paste below. It seems to use ant:run to load the files that > way, which apparently brings the properties into Maven (not Ant)? That > seems strange and unintuitive, but that's the impression I get. The same > peculiar behavior does not appear to happen when I use Maven2's ant:run > to perform the same task. So, is there a way to get Maven to read a > standard Java properties file and make those available for ${} tokens? > Note that I cannot use <filter>, because I need those substitutions > available in pom.xml > > Thanks, > Dan Allen > > > > > -The file I'm trying to convert > <?xml version="1.0" encoding="UTF-8"?> > <!-- Old Maven 1 maven.xml file. Works, but I'm trying to convert to > Maven 2. --> <project default="dev" > xmlns:j="jelly:core" > xmlns:util="jelly:util" > xmlns:ant="jelly:ant"> > > <!-- > Setup the log4j.properties by copying the correct one to > log4j.properties in target directory > and replacing the path token > --> > <preGoal name="java:jar-resources"> > <ant:echo message="${maven.war.webapp.dir}" /> > <ant:echo message="${maven.src.dir}" /> > <ant:filter token="tomcat.home" value="${tomcat.home}" /> > <ant:copy file="${maven.src.dir}/conf/${log4j.properties.file}" > > tofile="${maven.war.webapp.dir}/WEB-INF/classes/log4j.properties" > overwrite="true" filtering="true" /> > <ant:copy > file="${maven.src.dir}/conf/hibernate/${hibernate.properties.file}" > > tofile="${maven.war.webapp.dir}/WEB-INF/classes/hibernate.properties" > overwrite="true" filtering="true" /> > > <ant:filter token="email.business" value="${email.business}" /> > <ant:filter token="spreadsheet.storage" > value="${spreadsheet.storage}" /> > <ant:filter token="email.reports" value="${email.reports}" /> > <ant:filter token="host.url" value="${host.url}" /> > <ant:filter token="email.alerts.system" > value="${email.alerts.system}" /> > <ant:filter token="daemon.rv" value="${daemon.rv}" /> > > <ant:copy file="${maven.src.dir}/webapp/WEB-INF/web.xml" > tofile="${maven.war.webapp.dir}/WEB-INF/web.xml" > overwrite="true" filtering="true" /> > > </preGoal> > > <!-- > Export the SQL for Hibernate tables > --> > <postGoal name="war:webapp"> > <attainGoal name="hibernate:schema-export" /> > </postGoal> > > <!-- > Configures Tomcat (server.xml and Context insurancederiv.xml) > --> > <goal name="configureDevTomcat" prereqs="war:init"> <!-- war:init > sets maven.war.webapp.dir --> > > <ant:filter token="target.home" value="${maven.war.webapp.dir}" > /> > > <ant:copy file="context.xml" > > tofile="${tomcat.home}/conf/Catalina/${host}/insurancederiv.xml" > overwrite="true" filtering="true" /> > > <ant:filter token="host" value="${host}" /> > > <ant:copy file="server.xml" > tofile="${tomcat.home}/conf/server.xml" > overwrite="true" filtering="true" /> > > </goal> > > <!-- > Development target > --> > <goal name="dev"> > <j:set var="log4j.properties.file" value="log4j.dev.properties" > /> > <j:set var="hibernate.properties.file" > value="hibernate.properties.dev" /> > > <ant:property file="build.dev.properties" /> > > <attainGoal name="war:webapp" /> > <attainGoal name="configureDevTomcat" /> > </goal> > > <!-- > Live server target > --> > <goal name="live" > > > <ant:fail unless="build.properties.file" message="This target > should be run via live1 or live2, not directly" /> > > <ant:echo message="Now undeploy the web app via the > manager" /> > > <attainGoal name="clean" /> > <attainGoal name="war:init" /> <!-- Sets up maven.war.* > properties --> > > <j:set var="log4j.properties.file" value="log4j.live.properties" > /> > <j:set var="hibernate.properties.file" > value="hibernate.properties.live" /> > > <ant:property file="${build.properties.file}" /> > > <ant:filter token="target.home" > value="${tomcat.home}/webapps/${pom.artifactId}" /> > > <ant:copy file="context.xml" > tofile="${maven.war.webapp.dir}/META-INF/context.xml" > overwrite="true" filtering="true" /> > > <attainGoal name="war:webapp" /> > <attainGoal name="war:war" /> > > </goal> > > <goal name="live2"> > > <j:set var="build.properties.file" > value="build.live2.properties" /> > <attainGoal name="live" /> > > </goal> > > <goal name="live1"> > > <j:set var="build.properties.file" > value="build.live1.properties" /> > <attainGoal name="live" /> > > </goal> > > </project> > > -- > This message may contain confidential, proprietary, or legally > privileged information. No confidentiality or privilege is waived by any > transmission to an unintended recipient. If you are not an intended > recipient, please notify the sender and delete this message immediately. > Any views expressed in this message are those of the sender, not those > of any entity within the KBC Financial Products group of companies > (together referred to as "KBC FP"). > > This message does not create any obligation, contractual or otherwise, > on the part of KBC FP. It is not an offer (or solicitation of an offer) > of, or a recommendation to buy or sell, any financial product. Any > prices or other values included in this message are indicative only, and > do not necessarily represent current market prices, prices at which KBC > FP would enter into a transaction, or prices at which similar > transactions may be carried on KBC FP's own books. The information > contained in this message is provided "as is", without representations > or warranties, express or implied, of any kind. Past performance is not > indicative of future returns. > > > > > The content of this e-mail is confidential and may be privileged. It may > be read, copied and used only by the intended recipient and may not be > disclosed, copied or distributed. If you received this email in error, > please contact the sender immediately by return e-mail or by telephoning > +44 20 7260 2000, delete it and do not disclose its contents to any > person. You should take full responsibility for checking this email for > viruses. Markit reserves the right to monitor all e-mail communications > through its network. > Markit and its affiliated companies make no warranty as to the accuracy > or completeness of any information contained in this message and hereby > exclude any liability of any kind for the information contained herein. > Any opinions expressed in this message are those of the author and do > not necessarily reflect the opinions of Markit. > For full details about Markit, its offerings and legal terms and > conditions, please see Markit's website at http://www.markit.com > <http://www.markit.com/> . > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > > -- > This message may contain confidential, proprietary, or legally privileged > information. No confidentiality or privilege is waived by any transmission > to an unintended recipient. If you are not an intended recipient, please > notify the sender and delete this message immediately. Any views expressed > in this message are those of the sender, not those of any entity within the > KBC Financial Products group of companies (together referred to as "KBC > FP"). > > This message does not create any obligation, contractual or otherwise, on > the part of KBC FP. It is not an offer (or solicitation of an offer) of, or > a recommendation to buy or sell, any financial product. Any prices or other > values included in this message are indicative only, and do not necessarily > represent current market prices, prices at which KBC FP would enter into a > transaction, or prices at which similar transactions may be carried on KBC > FP's own books. The information contained in this message is provided "as > is", without representations or warranties, express or implied, of any kind. > Past performance is not indicative of future returns. > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
