NetBeans Forums
| View previous topic :: View next topic |
| Author |
Message |
marteno_rodia
Joined: 08 Aug 2009 Posts: 7 Location: Warsaw, PL
|
Posted: Sun Nov 27, 2011 9:11 am Post subject: maven doesn't resolve properties (with $) |
|
|
Hello, I'm a little new to Maven, and people who usually support me in using it don't use Netbeans. I'm using Netbeans 7.0.1 and a slight modification of Maven 3.0.3 (pointed by: Tools->Options->Misc->Maven->Maven Home).
During last days, our project team started to use Maven properties in POM files. Maven builds projects just fine, but Netbeans IDE shows many errors. I think it the IDE can't resolve properties (defined in Maven's settings.xml file or parent's POM file) because it tries to download version of a project ${something-dep-versions-parent-pom.version} instead of resolving it to 1.0.0, which the external Maven does.
I experienced a similar problem (errors in IDE and successful builds) after migration to Netbeans 7 from 6.9 and to Maven 3 from 2.2.1. Then I copied M2_HOME/conf/settings.xml file to directory USER/.m2, which was completely a satisfactory solution. The file is still residing in .m2 directory now, but the problem has returned.
Any suggestions? Is the feature of resolving properties really so exotic to maven 3.0.3?
More general question is: why does Netbeans seem to use two completely different versions of Maven? The first one for building projects, and the second one for displaying its contents, and an external Maven can be used in the first case only. Am I right? |
|
| Back to top |
|
 |
Monezz
Joined: 18 Feb 2009 Posts: 254
|
Posted: Sun Nov 27, 2011 1:51 pm Post subject: maven doesn't resolve properties (with $) |
|
|
| Quote: | Any suggestions? Is the feature of resolving properties really so exotic to maven 3.0.3?
| I am using properties without any problems with netbeans and the
buildin maven 3.
If a property is not recognized, you should be able to see the error
in the pom editor in netbeans.
Perhaps there is something wrong with your project structure? (child
modules not in a sub directory of the parent, etc)
maven is a bit more lenient towards "misconfigured" projects then the
internal compiler/processor.
Usually when you are able to build from the command line, maven gives
compatibility warnings which you should be able to resolve.
If none of the options work, please provide a sample project where the
problem appears so we can help you solve the problem.
Cheers,
Timon |
|
| Back to top |
|
 |
marteno_rodia
Joined: 08 Aug 2009 Posts: 7 Location: Warsaw, PL
|
Posted: Thu Dec 01, 2011 9:09 pm Post subject: |
|
|
Thank you for your reply. I think it is a good clue but as I said I'm not very skilled at Maven, so excuse my basic questions. What do you mean by "project structure"? All the software modules (Maven projects) consisted in our "big project" are on the central Maven repository. While I'm working on a single module, I don't have any explicit working copy (downloaded through e.g. SVN) of the parent project or dependency projects (of course, Maven downloads them in the background to the local repository).
The parent declaration in child's POM is as follows:
| Code: |
<parent>
<groupId>groupId</groupId>
<artifactId>parent-project-name</artifactId>
<version>${parent-project-name.version}</version>
</parent>
|
The property is defined in the settings.xml file:
| Code: |
<properties>
<parent-project-name.version>1.0.0</parent-project-name.version>
</properties>
|
Can you see any problems with it? Reproducing the problem in an example project might be difficult, but I can try in the next step. |
|
| Back to top |
|
 |
marteno_rodia
Joined: 08 Aug 2009 Posts: 7 Location: Warsaw, PL
|
Posted: Thu Dec 01, 2011 9:23 pm Post subject: |
|
|
I forgot to add that Netbeans-internal Maven tells me that the error is in the line:
| Code: | | <version>${parent-project-name.version}</version> |
Error message says: Use current parent version - 1.0.0
Generally, I can see the error <misconfigured Maven project> and only when I explicitly use the parent version 1.0.0 in the POM, I can see the compilation errors in the IDE. Project builds successfully in both cases. |
|
| Back to top |
|
 |
Milos Kleint Posted via mailing list.
|
Posted: Fri Dec 02, 2011 1:08 pm Post subject: maven doesn't resolve properties (with $) |
|
|
having the parent version defined in settings and thus variable parent
structure is more or less an anti-pattern. You should have just one,
well-defined parent and any changes in behaviour should be handled by
profiles, not different parent poms.
Milos
On Thu, Dec 1, 2011 at 10:09 PM, marteno_rodia <address-removed> wrote:
| Quote: | Thank you for your reply. I think it is a good clue but as I said I'm not very skilled at Maven, so excuse my basic questions. What do you mean by "project structure"? All the software modules (Maven projects) consisted in our "big project" are on the central Maven repository. While I'm working on a single module, I don't have any explicit working copy (downloaded through e.g. SVN) of the parent project or dependency projects (of course, Maven downloads them in the background to the local repository).
The parent declaration in child's POM is as follows:
Code:
<parent>
<groupId>groupId</groupId>
<artifactId>parent-project-name</artifactId>
<version>${parent-project-name.version}</version>
</parent>
The property is defined in the settings.xml file:
Code:
<properties>
<parent-project-name.version>1.0.0</parent-project-name.version>
</properties>
Can you see any problems with it? Reproducing the problem in an example project might be difficult, but I can try in the next step.
|
|
|
| Back to top |
|
 |
marteno_rodia
Joined: 08 Aug 2009 Posts: 7 Location: Warsaw, PL
|
Posted: Fri Dec 02, 2011 1:11 pm Post subject: |
|
|
| Thank you for your reply. I'm afraid using the parent through the property was not my decision and I can't change it. |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You can attach files in this forum You can download files in this forum
|
|