tags:

views:

139

answers:

3

I've added a jar to the 'Referenced Libraries' section in Eclipse, which now allows me to see objects from this jar when coding. However when I build with maven, I keep getting The import ____ cannot be resolved errors.

How do I fix this? Do I have to add in the pom.xml? I'm trying use smartgwt.jar.

Also - What would be the 'proper' way to do it?

+1  A: 

You should manage your dependencies either through Eclipse OR through maven. Maven has a nice utility to create Eclipse project files, and there's a plugin to manage the pom file in Eclipse.

To specifically solve you problem, you need to find the artifactId and groupId (and possibly the version as well) for the jar you want. Then add this to the pom file. Then maven will build correctly.

CWF
+2  A: 

As the other answer suggests, you should use eclipse or maven. Maven has a useful eclipse:eclipse target that can be used to generate an eclipse project that can be imported in eclipse.

I found this example on http://code.google.com/p/smartgwt/issues/detail?id=12 Should be worth a try.

Basically, update your pom.xml with

<pluginRepositories>
    <pluginRepository>
        <id>gwt-maven-plugins</id>
        <url>http://gwt-maven.googlecode.com/svn/trunk/mavenrepo/&lt;/url&gt;
    </pluginRepository>
</pluginRepositories>    
<repositories>        
    <repository>
        <id>gwt-maven</id>
        <url>http://gwt-maven.googlecode.com/svn/trunk/mavenrepo/&lt;/url&gt;
    </repository>
    <repository>
        <id>smartclient</id>
        <name>smartclient.com</name>
        <url>http://www.smartclient.com/maven2&lt;/url&gt;
   </repository>
</repositories>

And add the dependency:

<dependency>
    <groupId>com.smartgwt</groupId>
    <artifactId>smartgwt</artifactId>
    <version>2.0</version>
</dependency>
belgarat
@belgarat: Correct answer for specifying the right repository :)
day_trader
+2  A: 

Maven doesn't have any knowledge of things that are not declared in the pom.xml so, yes, you have to declare smartgwt in the POM. Actually, the common way to work with Maven and IDEs is to add things in the POM and to generate or derive things at the IDE level from the POM. In the case of Eclipse, this can be done using the maven-eclipse-plugin or M2Eclipse (the later would be my recommendation here and supports bi-directional actions).

Having all that said, the fact is that smartgwt isn't distributed in Maven central repository so you'll have to add its repository (where to find it) and the dependency.

<project>
  ...
  <repositories>
    <repository>
      <id>SmartGWT</id>
      <url>http://www.smartclient.com/maven2&lt;/url&gt;
    </repository>
  </repositories>
  ...
  <dependencies>
    <dependency>
      <groupId>com.smartgwt</groupId>
      <artifactId>smartgwt</artifactId>
      <version>2.1</version><!-- or whatever version you're using -->
    </dependency>
    ...
  </dependencies>
</project>

The smartgwt project somehow provides some (outdated) documentation in HowToEclipseGWTMaven.

Pascal Thivent