I do as follow:
in POM.XML
==========
...
<dependency>
<groupId>${my.junit.groupId}</groupId>
<artifactId>${my.junit.artifactId}</artifactId>
<version>${my.junit.version}</version>
</dependency>
...
in "settings.xml"
============
...
<activeProfiles>
<activeProfile>profiles.xml</activeProfile>
</activeProfiles>
...
in "profiles.xml"
============
<profiles>
<profile>
<id>wei.junit.groupId</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<wei.junit.groupId>junit</wei.junit.groupId>
</properties>
</profile>
<profile>
<id>wei.junit.artifactId</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<wei.junit.artifactId>junit</wei.junit.artifactId>
</properties>
</profile>
<profile>
<id>wei.junit.version</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<wei.junit.version>3.8.1</wei.junit.version>
</properties>
</profile>
</profiles>
Then I call maven command as follow:
mvn -s "settings.xml" eclipse:eclipse
But I got error as follow. Where have I done wrong?
=====================================
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[ERROR] FATAL ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Error building POM (may not be this project's POM).
Project ID: com.wei.chen.app:TestXml
POM Location: E:\Projekte\TestXml\pom.xml
Validation Messages:
[0] 'dependencies.dependency.artifactId' with value
'${wei.junit.artifactId
}' does not match a valid id pattern.
[1] 'dependencies.dependency.groupId' with value '${wei.junit.groupId}' doe
s not match a valid id pattern.
Reason: Failed to validate POM for project com.wei.chen.app:TestXml at E:\Projek
te\TestXml\pom.xml
[INFO] ------------------------------------------------------------------------
[INFO] Trace
org.apache.maven.reactor.MavenExecutionException: Failed to validate POM for pro
ject com.wei.chen.app:TestXml at E:\Projekte\TestXml\pom.xml
at org.apache.maven.DefaultMaven.getProjects(DefaultMaven.java:378)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:290)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:125)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:280)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
Caused by: org.apache.maven.project.InvalidProjectModelException: Failed to vali
date POM for project com.wei.chen.app:TestXml at E:\Projekte\TestXml\pom.xml
at org.apache.maven.project.DefaultMavenProjectBuilder.processProjectLog
ic(DefaultMavenProjectBuilder.java:998)
at org.apache.maven.project.DefaultMavenProjectBuilder.buildInternal(Def
aultMavenProjectBuilder.java:801)
at org.apache.maven.project.DefaultMavenProjectBuilder.buildFromSourceFi
leInternal(DefaultMavenProjectBuilder.java:479)
at org.apache.maven.project.DefaultMavenProjectBuilder.build(DefaultMave
nProjectBuilder.java:200)
at org.apache.maven.DefaultMaven.getProject(DefaultMaven.java:553)
at org.apache.maven.DefaultMaven.collectProjects(DefaultMaven.java:467)
at org.apache.maven.DefaultMaven.getProjects(DefaultMaven.java:364)
... 11 more
[INFO] ------------------------------------------------------------------------
[INFO] Total time: < 1 second
[INFO] Finished at: Thu Jan 03 09:05:34 CET 2008
[INFO] Final Memory: 1M/2M
[INFO] ------------------------------------------------------------------------
E:\Projekte\TestXml>
****************************
This is already well documented. Please go do some reading.
+
http://maven.apache.org/guides/introduction/introduction-to-profiles.html
+ Better Builds With Maven ebook, section 3.8 "Using Profiles".
+ And many other places.
Wayne
On 1/2/08, Jeff MAURY <[EMAIL PROTECTED]> wrote:
> You can leave the profiles in settings.xml and activate them with the
-P
> option of the maven command line.
>
> Jeff
>
>
> On Jan 2, 2008 4:23 PM, Thomas Chang <[EMAIL PROTECTED]> wrote:
>
> > Hi all,
> >
> > Notmally the "settings.xml" has the element of <profiles> and
> > <activeProfiles>. Now I want to take these out of the
"settings.xml" and
> > put them into another file. How to do so?
> >
> > Regards
> >
> > Thomas
---------------------------------
Heute schon einen Blick in die Zukunft von E-Mails wagen? Versuchen Sie“s mit
dem neuen Yahoo! Mail.