tags:

views:

27

answers:

1

I try to compile my project with maven but i get error

C:\Projekti\KIS\Model\src\irc\kis\model\hab\entity\TipiDokumentovImpl.java:[3,48] package irc.irc2000.classCustomization.model

C:\Projekti\KIS\Model\src\irc\kis\model\hab\entity\TipiDokumentovImpl.java:[5,28] package irc.irc2000.security does not exist

becouse i import two packages from another directory

import irc.irc2000.classCustomization.model.adf.IrcEntityImpl;
import irc.irc2000.security.Uporabnik;

How can i include this classes from second directory that maven will see it when compile that project?

POM file:

<build>
        <sourceDirectory>C:\Projekti\KIS\Model\src</sourceDirectory>
        <outputDirectory>C:\Projekti\KIS\Model\classes</outputDirectory>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>2.0.2</version>
                <configuration>
                    <encoding>Cp1250</encoding>
                    <source>1.5</source>
                    <target>1.5</target>
                </configuration>
            </plugin>
            <plugin>
                <artifactId>maven-idea-plugin</artifactId>
                <version>2.1</version>
                <configuration>
                    <downloadSources>true</downloadSources>
                    <downloadJavadocs>true</downloadJavadocs>
                    <dependenciesAsLibraries>true</dependenciesAsLibraries>
                    <useFullNames>false</useFullNames>
                </configuration>
            </plugin>
        </plugins>
        <resources>
            <resource>
                <directory>C:\Projekti\KIS\Model\src</directory>
                <excludes>
                    <exclude>**/*.java</exclude>
                </excludes>
            </resource>
        </resources>
    </build>

Thx all for help

+3  A: 

You can use the Maven Build Helper plugin and its build-helper:add-source goal to Add more source directories to the POM. From the usage page:

<project>
  ...
  <build>
    <plugins>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>build-helper-maven-plugin</artifactId>
        <version>1.5</version>
        <executions>
          <execution>
            <id>add-source</id>
            <phase>generate-sources</phase>
            <goals>
              <goal>add-source</goal>
            </goals>
            <configuration>
              <sources>
                <source>some directory</source>
                ...
              </sources>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
</project>

But I almost feel guilty for giving a solution... The real good advice would be to refactor everything and make the other project a maven project (and declare it as dependency).

Pascal Thivent
@Pascal I've been watching this question to see if any option other than <dependency>
JoseK