370 likes | 530 Views
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.
E N D
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 RecommendedCheap 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 ashttps://www.ja-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 <modules> <module>cas-server-core</module> <module>cas-server-support-generic</module> <module>cas-server-support-jdbc</module> <module>cas-server-support-ldap</module> <module>cas-server-support-openid</module> <module>cas-server-support-radius</module> <module>cas-server-support-spnego</module> <module>cas-server-support-trusted</module> <module>cas-server-support-x509</module> <module>cas-server-integration-jboss</module> <module>cas-server-webapp</module> </modules>
Maven: cas-server-core is a “project”Eclipse: cas-server-core/src/main/java is a “src dir”
.classpath file <?xml version="1.0" encoding="UTF-8"?> <classpath> <classpathentry kind="src" path="cas-server-core/src/main/java"/> <classpathentry kind="src" path="cas-server-support-openid/src/main/java"/> <classpathentry kind="src" output="test-bin" path="cas-server-core/src/test/java"/> … <classpathentry kind="var" path="M2_REPO/org/springframework/spring/2.5/spring-2.5.jar"/> <classpathentry kind="var" path="M2_REPO/org/springframework/spring-test/2.5/spring-test-2.5.jar"/> … <classpathentry kind="output" path="bin"/> </classpath>
Package Explorer - Libraries Libraries in the JRE Libraries from the project’s Build Path
cas-server-support-trusted/pom.xml <artifactId>cas-server-support-trusted</artifactId> <packaging>jar</packaging> <dependencies> <dependency> <groupId>org.jasig.cas</groupId> <artifactId>cas-server-core</artifactId> <version>${project.version}</version> </dependency> <dependency> <groupId>cas</groupId> <artifactId>casclient</artifactId> <version>2.1.1</version> </dependency> Jar (in M2_REPO) added to classpath for compile
cas-server-webapp/pom.xml <dependency> <groupId>org.jasig.cas</groupId> <artifactId>cas-server-core</artifactId> <version>${project.version}</version> </dependency> <dependency> <groupId>org.jasig.cas</groupId> <artifactId>cas-server-support-trusted</artifactId> <version>${project.version}</version> </dependency> <dependency> <groupId>org.jasig.cas</groupId> <artifactId>cas-server-support-x509</artifactId> <version>${project.version}</version> </dependency> Default is core only Add optionartifacts you choose
Download Libraries • “cd” to Workspace, project directory • run “mvn compile” and/or“mvninstall” 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-1.0.5.jar Directory of C:\Users\gilbert.YALE\.m2\repository\org\acegisecurity\acegi-security\1.0.5 12/20/2007 02:24 PM 5,028 acegi-security-1.0.5.pom 12/20/2007 02:24 PM 40 acegi-security-1.0.5.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 projectAlternate: use another version (1.0.4) you have
Maven 2 Build MasterPOM compile classpath repository jars corePOM src core jar compile dependencies optionPOMs src more jars jsp, html, web.xml webappPOM WEB-INF/lib cas.war
Simple IDE Build Build Path Source Dirs Build Path libraries core src option src Compile WebRoot webappprojWEB-INF/classes.property files Preloaded jsp and xml pages Deploy toTomcatJBossGlassfishGeronimo … WEB-INF/libWEB-INF/classes
Possible IDE Build Core project .classpath src /bin compile Option depends on Core Option project .classpath src /bin compile /bin from each“depends on”project Web project jsp and xml files .classpath /classes /lib
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)
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]
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
Select one or more J2EE App Servers Exploded deployments are changed “on the fly” after save and compile.
Application Server Buttons Run Application Server(Tomcat) Manuallyredeploy