Developing in CAS
Why? As distributed you edit CAS 3 with Eclipse and build with Maven 2 – Best Practice for Release Engineering – Difficult edit-debug cycle Extend “edit” to include a separate debug deploy under Eclipse (without the 10 minute Maven 2 build) Understand the development cycle
You are going to need … A Java (5 or 6) from Sun An Eclipse (3.3) from eclipse.org A subversion plugin for Eclipse to checkout the project from ja-sig – Subversive is becoming part of Eclipse, but parts are still at polarion.org Now you could check out CAS3
Highly Recommended Cheap but not Free MyEclipse IDE plugin from genuitec Commercial J2EE development tool built on top of Eclipse Free trial, then $31.75 a year
Sanity Download Tomcat 6 from Apache
Developing CAS - Prepare Get Maven 2 from apache.org Unzip and move mvn (.bat or shell script) to Path Define JAVA_HOME and M2_HOME environment variables
Developing CAS - Checkout Eclipse SVN perspective Define SVN source as sig.org/svn/ sig.org/svn/ Check out the trunk or a tagged release as a Java project Ignore library errors Close Eclipse
This is the top level Maven POM cas-server-core cas-server-support-generic cas-server-support-jdbc cas-server-support-ldap cas-server-support-openid cas-server-support-radius cas-server-support-spnego cas-server-support-trusted cas-server-support-x509 cas-server-integration-jboss cas-server-webapp
Maven: cas-server-core is a “project” Eclipse: cas-server-core/src/main/java is a “src dir”
Build Path (GUI to.classpath)
.classpath file … …
Package Explorer - Libraries Libraries in the JRE Libraries from the project’s Build Path
cas-server-support-trusted/pom.xml cas-server-support-trusted jar org.jasig.cas cas-server-core ${project.version} cas casclient Jar (in M2_REPO) added to classpath for compile
cas-server-webapp/pom.xml org.jasig.cas cas-server-core ${project.version} org.jasig.cas cas-server-support-trusted ${project.version} org.jasig.cas cas-server-support-x509 ${project.version} Default is core only Add option artifacts you choose
Download Libraries “cd” to Workspace, project directory run “mvn compile” and/or “mvn install” command Dependency jar files are downloaded to.m2/respository in your home directory
mvn problems (maybe synch with.classpath) Project 'castrunk' is missing required library: 'C:\Users\...\.m2\repository\org\acegisecurity\acegi-security\1.0.5\acegi-security jar Directory of C:\Users\gilbert.YALE\.m2\repository\org\acegisecurity\acegi-security\ /20/ :24 PM 5,028 acegi-security pom 12/20/ :24 PM 40 acegi-security pom.sha1 Google for the project Download it manually and unzip it Copy the jar file to the.m2/repository directory Close, open, and refresh the CAS project Alternate: use another version (1.0.4) you have
.m2/repository
Build Path – define M2_REPO
Maven 2 Build Master POM core POM repository jars compile classpath core jar option POMs webapp POM compile dependencies more jars src jsp, html, web.xml WEB-INF/lib cas.war
Simple IDE Build Build Path libraries core src option src WebRoot Compile Preloaded jsp and xml pages webapp proj WEB-INF/classes.property files WEB-INF/lib WEB-INF/classes Build Path Source Dirs Deploy to Tomcat JBoss Glassfish Geronimo …
Possible IDE Build.classpath src/bin compile Core project.classpath src/bin compile Option project Option depends on Core.classpath Web project jsp and xml files /classes /lib /bin from each “depends on” project
MyEclipse Download and install MyEclipse – Point it to the Eclipse 3.3 previously installed – If you have just been reading along up to this point, you can install the “All-in-one” version with Java, Eclipse, and MyEclipse bundled together
cas-server-webapp - WebRoot Maven uses cas-server-webapp project as a read- only source of HTML/JSP used to create the WAR MyEclipse uses WebRoot directory as a working template for the WAR file and compiles source and copies resources to its WEB-INF/classes Copy the HTML, XML, JSP files from cas-server- webapp to WebRoot Define the cas-server-webapp WEB-INF/classes directory as a “source” (for.properties resources)
MyEclipse Web Project
Adding Web capabilities MyEclipse changes the default compiler output directory to WebRoot/WEB-INF/classes MyEclipse adds its editors and syntax filters to the project MyEclipse adds the J2EE (1.4 or 5) package of libraries to the compiler classpath There are now HTML and XML files with “errors”. [Right click the directories, select MyEclipse, Exclude from Validation]
J2EE 1.4 Libraries
Sanity Check cas-server-webapp – will be used as the source for Maven – should reflect your production environment (probably on another host) – is associated through SVN to the ja-sig source WebRoot – used by Eclipse (tell SVN to ignore it) – reflects your local test Tomcat environment
WEB-INF/classes Java files in a source directory are compiled and the class files are put in the output dir Other files (“resources”) are copied to the output dir For a Web Project, the output directory should be WebRoot/WEB-INF/classes Put JUnit class files someplace else (/test-bin)
Indirect Dependencies JAR files that are needed to run CAS but are not needed to compile it Frequently, classes referenced in the Spring configuration XML as beans Dependencies listed in the cas-server-webapp POM (quartz, ehcache, ognl, acegi-security, …) run “mvn install” in the project directory Add them to the Build Path Libraries
Right Click a Source Dir
Select one or more J2EE App Servers Exploded deployments are changed “on the fly” after save and compile.
Application Server Buttons Manually redeploy Run Application Server (Tomcat)
Start the Server