views:

342

answers:

1

I created a grails 1.2.0 project using the acegi plugin 0.5.2 which works very well.

To integrate the project into our companies build infrastructure I need to build it via maven. So I converted it to a maven project using the grails maven integration which worked quite well too.

There is one problem: I have a Java class CustomUserDetails that implements the GrailsUser interface. When maven tries to compile the project it can not find the GrailsUser interface class which is part of the acegi plugin.

Am I missing something or is there a problem with the grails maven integration that causes plugin classes missing from the classpath?

UPDATE: here is the pom.xml of my project:

<?xml version="1.0" encoding="UTF-8"?><project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"&gt;
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.troii</groupId>
  <artifactId>testapp</artifactId>
  <packaging>war</packaging>
  <version>1.0-SNAPSHOT</version>

  <dependencies>
    <dependency>
      <groupId>org.grails</groupId>
      <artifactId>grails-crud</artifactId>
      <version>1.2.0</version>
    </dependency>
    <dependency>
      <groupId>org.grails</groupId>
      <artifactId>grails-gorm</artifactId>
      <version>1.2.0</version>
    </dependency>

    <!-- Grails defaults to Ehache for the second-level Hibernate cache. -->
    <dependency>
      <groupId>org.hibernate</groupId>
      <artifactId>hibernate-ehcache</artifactId>
      <version>3.3.1.GA</version>
    </dependency>
    <dependency>
      <groupId>javassist</groupId>
      <artifactId>javassist</artifactId>
      <version>3.11.0.GA</version>
    </dependency>

    <dependency>
      <groupId>net.sf.ehcache</groupId>
      <artifactId>ehcache-core</artifactId>
      <version>1.7.1</version>
      <exclusions>
          <exclusion>
              <artifactId>jms</artifactId>
          </exclusion>
          <exclusion>
              <artifactId>servlet-api</artifactId>
          </exclusion>

          <!-- We have JCL-over-SLF4J instead. -->
          <exclusion>
              <artifactId>commons-logging</artifactId>
          </exclusion>
      </exclusions>
    </dependency>

    <!-- For ease of development and testing, we include the HSQLDB database. -->
    <dependency>
      <groupId>hsqldb</groupId>
      <artifactId>hsqldb</artifactId>
      <version>1.8.0.10</version>
    </dependency>

    <!-- Use Log4J for logging. This artifact also pulls in the Log4J JAR. -->
    <dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>slf4j-log4j12</artifactId>
      <version>1.5.8</version>
      <scope>runtime</scope>
    </dependency>

    <dependency>
      <groupId>javax.servlet</groupId>
      <artifactId>jstl</artifactId>
      <version>1.2</version>
    </dependency>
  </dependencies>

  <repositories>
    <!-- Required to get hold of JTA -->
    <repository>
      <id>maven2-repository.dev.java.net</id>
      <name>Java.net Repository for Maven</name>
      <url>http://download.java.net/maven/2/&lt;/url&gt;
      <layout>default</layout>
    </repository>
    <repository>
      <id>Codehaus Snapshots</id>
      <url>http://snapshots.repository.codehaus.org&lt;/url&gt;
      <snapshots>
        <enabled>true</enabled>
      </snapshots>
      <releases>
        <enabled>false</enabled>
      </releases>
    </repository>
  </repositories>

  <pluginRepositories>
    <pluginRepository>
      <id>Codehaus Snapshots</id>
      <url>http://snapshots.repository.codehaus.org&lt;/url&gt;
      <snapshots>
        <enabled>true</enabled>
      </snapshots>
      <releases>
        <enabled>false</enabled>
      </releases>
    </pluginRepository>
  </pluginRepositories>

  <build>
    <pluginManagement />
    <plugins>
      <plugin>
        <groupId>org.grails</groupId>
        <artifactId>grails-maven-plugin</artifactId>
        <version>1.2.0</version>
        <extensions>true</extensions>
        <executions>
          <execution>
            <goals>
              <goal>init</goal>
              <goal>maven-clean</goal>
              <goal>validate</goal>
              <goal>config-directories</goal>
              <goal>maven-compile</goal>
              <goal>maven-test</goal>
              <goal>maven-war</goal>
              <goal>maven-functional-test</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <artifactId>maven-compiler-plugin</artifactId>
        <configuration>
          <source>1.5</source>
          <target>1.5</target>
        </configuration>
      </plugin>
    </plugins>
  </build>
  <profiles>
    <profile>
      <id>tools</id>
      <activation>
        <property>
          <name>java.vendor</name>
          <value>Sun Microsystems Inc.</value>
        </property>
      </activation>
      <dependencies>
        <dependency>
          <groupId>com.sun</groupId>
          <artifactId>tools</artifactId>
          <version>${java.version}</version>
          <scope>system</scope>
          <systemPath>${java.home}/../lib/tools.jar</systemPath>
        </dependency>
      </dependencies>
    </profile>
  </profiles>
</project>
A: 

I think what is going on is you are expecting the plugin classpath to be available to when compiling you project source code. Plugins have their own classloader, so your classes won't see stuff in there.

Instead define a project dependency to a library which contains the GrailsUser interface and make sure the scope of that dependency is compile (the default).

Peter Lynch
yes, I though that something like this is the reason, I was not sure if this is a bug or if I need to do something different.Do you know if there is a maven artifact containing the classes of the acegi plugin?
Thomas Einwaller
Does something like this work?mvn grails:install-plugin -DpluginName=acegimvn initializeMore info here: http://www.grails.org/Maven+IntegrationI have not tested above
Peter Lynch
no, this installs the grails plugin but makes no changes to the maven dependencies
Thomas Einwaller