You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by laredotornado <la...@gmail.com> on 2009/12/03 23:56:22 UTC

Building using different files based on a build flag?

Hi,

I'm using Maven 2.2 on Mac 10.5.6.  I'm building a web application for JBoss
5.1 AS.  I was wondering how I would include a different properties file
based on the value someone specified in the "mvn" build command.  For
example, if someone entered

mvn -Denv=dev jboss:redeploy

I would want to include a different file in my WAR than if they specified

mvn -Denv=test jboss:redeploy

.  Here is how I currently have my pom.xml set up, which builds the same
regardless of environment ...

  <build>
    <sourceDirectory>src/main/java</sourceDirectory>
    <resources>
      <resource>
        <directory>src/main/resources</directory>
        <filtering>false</filtering>
        <includes>
          <include>**/*.xml</include>
          <include>**/*.properties</include>
        </includes>
      </resource>
  </build>

Any ideas how I can adjust the build process based on a command line
parameter?  Thanks, - Dave
-- 
View this message in context: http://old.nabble.com/Building-using-different-files-based-on-a-build-flag--tp26634795p26634795.html
Sent from the Maven - Users mailing list archive at Nabble.com.


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


Re: Building using different files based on a build flag?

Posted by Wayne Fay <wa...@gmail.com>.
> ps - What made me think there was a 1.0 version was the page you sent to me
> -- http://maven.apache.org/enforcer/enforcer-rules/requireProperty.html,
> specifically the "<version>1.0</version>".  I didn't realize I shouldn't
> take the example literally.

Probably the documentation should be fixed/updated to include a
correct version tag in the examples. I assume the author of that page
expected there would be a 1.0 release, eventually making this example
valid, but obviously it is confusing to some people. If you'd like,
you can file a bug in JIRA so the documentation is updated.

In the future, you can use www.mvnrepository.com to check for versions
of artifacts, or simply hit Central directly with a web browser and
navigate to the plugin directory to look at all available versions:
http://repo1.maven.org/maven2/org/apache/maven/plugins/maven-enforcer-plugin/

Wayne

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


Re: Building using different files based on a build flag?

Posted by laredotornado <la...@gmail.com>.
Thanks.  Everything works perfectly now.  Really appreciate the help, - Dave

ps - What made me think there was a 1.0 version was the page you sent to me
-- http://maven.apache.org/enforcer/enforcer-rules/requireProperty.html,
specifically the "<version>1.0</version>".  I didn't realize I shouldn't
take the example literally.
 


Wayne Fay wrote:
> 
>> Reason: Unable to download the artifact from any repository
>>  org.apache.maven.plugins:maven-enforcer-plugin:pom:1.0
> 
> What makes you think there is a 1.0 version of this plugin?
> http://mvnrepository.com/artifact/org.apache.maven.plugins/maven-enforcer-plugin
> 
> Wayne
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
> 
> 
> 

-- 
View this message in context: http://old.nabble.com/Building-using-different-files-based-on-a-build-flag--tp26634795p26678714.html
Sent from the Maven - Users mailing list archive at Nabble.com.


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


Re: Building using different files based on a build flag?

Posted by Wayne Fay <wa...@gmail.com>.
> Reason: Unable to download the artifact from any repository
>  org.apache.maven.plugins:maven-enforcer-plugin:pom:1.0

What makes you think there is a 1.0 version of this plugin?
http://mvnrepository.com/artifact/org.apache.maven.plugins/maven-enforcer-plugin

Wayne

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


Re: Building using different files based on a build flag?

Posted by laredotornado <la...@gmail.com>.
Sweet!  This looks like the answer to my problems, except that when I include
the plugin in my pom.xml, I'm not able to download it.  What repository
should I be using?  Here is what I get ...

mvn clean install jboss:redeploy
[INFO] Scanning for projects...
Downloading:
http://repo1.maven.org/maven2/org/apache/maven/plugins/maven-enforcer-plugin/1.0/maven-enforcer-plugin-1.0.pom
[INFO] Unable to find resource
'org.apache.maven.plugins:maven-enforcer-plugin:pom:1.0' in repository
central (http://repo1.maven.org/maven2)
Downloading:
http://repo1.maven.org/maven2/org/apache/maven/plugins/maven-enforcer-plugin/1.0/maven-enforcer-plugin-1.0.pom
[INFO] Unable to find resource
'org.apache.maven.plugins:maven-enforcer-plugin:pom:1.0' in repository
maven2 (http://repo1.maven.org/maven2)
Downloading:
http://repository.jboss.com/maven2/org/apache/maven/plugins/maven-enforcer-plugin/1.0/maven-enforcer-plugin-1.0.pom
[INFO] Unable to find resource
'org.apache.maven.plugins:maven-enforcer-plugin:pom:1.0' in repository jboss
(http://repository.jboss.com/maven2)
Downloading:
http://mirrors.ibiblio.org/pub/mirrors/maven2/org/apache/maven/plugins/maven-enforcer-plugin/1.0/maven-enforcer-plugin-1.0.pom
[INFO] Unable to find resource
'org.apache.maven.plugins:maven-enforcer-plugin:pom:1.0' in repository
ibiblio (http://mirrors.ibiblio.org/pub/mirrors/maven2)
Downloading:
http://repo1.maven.org/maven2/org/apache/maven/plugins/maven-enforcer-plugin/1.0/maven-enforcer-plugin-1.0.pom
[INFO] Unable to find resource
'org.apache.maven.plugins:maven-enforcer-plugin:pom:1.0' in repository
central (http://repo1.maven.org/maven2)
[INFO]
------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO]
------------------------------------------------------------------------
[INFO] Failed to resolve artifact.

GroupId: org.apache.maven.plugins
ArtifactId: maven-enforcer-plugin
Version: 1.0

Reason: Unable to download the artifact from any repository

  org.apache.maven.plugins:maven-enforcer-plugin:pom:1.0

from the specified remote repositories:
  maven2 (http://repo1.maven.org/maven2),
  central (http://repo1.maven.org/maven2),
  Codehaus Snapshots (http://snapshots.repository.codehaus.org/),
  jboss (http://repository.jboss.com/maven2),
  ibiblio (http://mirrors.ibiblio.org/pub/mirrors/maven2)


Thanks, - Dave



Wayne Fay wrote:
> 
>> If someone doesn't specify "-Denv=" in the build command, how can you
>> warn
>> them that they must include this parameter rather than the build "failing
>> spectacularly".
> 
> The enforcer plugin can help with that:
> http://maven.apache.org/enforcer/enforcer-rules/requireProperty.html
> 
> Wayne
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
> 
> 
> 

-- 
View this message in context: http://old.nabble.com/Building-using-different-files-based-on-a-build-flag--tp26634795p26645812.html
Sent from the Maven - Users mailing list archive at Nabble.com.


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


Re: Building using different files based on a build flag?

Posted by Wayne Fay <wa...@gmail.com>.
> If someone doesn't specify "-Denv=" in the build command, how can you warn
> them that they must include this parameter rather than the build "failing
> spectacularly".

The enforcer plugin can help with that:
http://maven.apache.org/enforcer/enforcer-rules/requireProperty.html

Wayne

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


Re: Building using different files based on a build flag?

Posted by laredotornado <la...@gmail.com>.
I found this documentation related to profiles --
http://maven.apache.org/guides/introduction/introduction-to-profiles.html
and it was very helpful.  It left me with one lingering question.

If someone doesn't specify "-Denv=" in the build command, how can you warn
them that they must include this parameter rather than the build "failing
spectacularly".

Thanks, - 



Wayne Fay wrote:
> 
>> Any ideas how I can adjust the build process based on a command line
>> parameter?  Thanks, - Dave
> 
> The answer to this question is always Use Profiles. They are well
> documented in various places.
> 
> Wayne
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
> 
> 
> 

-- 
View this message in context: http://old.nabble.com/Building-using-different-files-based-on-a-build-flag--tp26634795p26635918.html
Sent from the Maven - Users mailing list archive at Nabble.com.


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


Re: Building using different files based on a build flag?

Posted by Wayne Fay <wa...@gmail.com>.
> Any ideas how I can adjust the build process based on a command line
> parameter?  Thanks, - Dave

The answer to this question is always Use Profiles. They are well
documented in various places.

Wayne

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