Cernunnos Manual


Cernunnos & Maven

Using Cernunnos is easier with Apache Maven. Cernunnos depends on several popular, third-party APIs; the details surrounding which libraries are required and which versions are compatible may change from release to release of Cernunnos. Maven saves you the trouble of keeping up with these changes, as well as tracking these libraries down in the first place.

Adding Cernunnos to Your Maven Project

Use XML like the following to add a dependency on Cernunnos to the pom.xml file of your Maven project:

          
            <repository> 
              <id>jasig-repository</id>  
              <name>JA-SIG Maven2 Repository</name>  
              <url>http://developer.ja-sig.org/maven2</url> 
            </repository> ... 
            <dependency> 
              <groupId>com.googlecode.cernunnos</groupId>  
              <artifactId>cernunnos</artifactId>  
              <version>${cernunnos.version}</version>  
              <scope>compile</scope> 
            </dependency>
          
        

At the time of this writing, Cernunnos is not available from Maven's central repository. But thanks to the vision and generosity of the leadership at JA-SIG, Cernunnos artifacts are hosted within the JA-SIG Maven repository. You must, therefore, reference the JA-SIG repository in your pom.xml file (as shown above). Additionally, you must either define the ${cernunnos.version} variable, or replace that expression with a valid version of Cernunnos.

Creating a New Project from Scratch

If you need to create a new Maven webapp project, there is a better way. Navigate your command prompt to an empty directory and issue the following Maven command:

mvn archetype:create \ -DarchetypeGroupId=com.googlecode.cernunnos \ -DarchetypeArtifactId=cernunnos-webapp \ -DarchetypeVersion=<cernunnos.version> \ -DgroupId=<your.groupId> \ -DartifactId=<your.artifactId>

This operation will spawn a new, basic webapp project with the JA-SIG repository and Cernunnos dependency pre-configured. Several other useful and appropriate webapp settings will be pre-configured as well.

Defining a Servlet

Issue the following command to define a new Servlet in your Maven webapp project (requires Cernunnos command line tool):

>crn define-servlet.crn <servlet.name>

This tool will create a new Java Servlet -- with the name you specify -- based on the implementation class org.danann.cernunnos.runtime.web.CernunnosServlet. Check out this article for information on developing Java Portlets and Servlets with Cernunnos.

Defining a Portlet

Defining Java Portlets works just like Servlets. Use the following command:

>crn define-portlet.crn <portlet.name>

Defining a User Attribute

You can also define user attributes for Portlet applications. Use the following command:

>crn define-user-attribute.crn <attribute.name>

NOTE: you don't have to create your project with the cernunnos-webapp archetype to use these tools. Any Maven webapp project that uses the src/main/webapp/ convention for web resources should work.