50
Developing CAS in Eclipse Edit and Debug

Developing CAS in Eclipse

  • Upload
    zuwena

  • View
    84

  • Download
    0

Embed Size (px)

DESCRIPTION

Developing CAS in Eclipse. Edit and Debug. Maven is Best Practice. Compile and Zip WAR file with Maven 2 Manage “dependencies” (external JARs from other software libraries or products) Run tests to validate each change cycle Build JAR, WAR, or other standard “artifacts” Edit with Eclipse - PowerPoint PPT Presentation

Citation preview

Page 1: Developing CAS in Eclipse

Developing CAS in Eclipse

Edit and Debug

Page 2: Developing CAS in Eclipse

Maven is Best Practice

• Compile and Zip WAR file with Maven 2– Manage “dependencies” (external JARs from

other software libraries or products)– Run tests to validate each change cycle– Build JAR, WAR, or other standard “artifacts”

• Edit with Eclipse– Syntax and help for Java and XML– Widely used, modularly extensible IDE

• How about simple testing with Eclipse?

Page 3: Developing CAS in Eclipse

Maven Compile

Main POM

Core project source + POM

Option project source + POM

Option project source + POM

Option project source + POM

artifact jarartifact jarartifact jarartifact jar

Page 4: Developing CAS in Eclipse

Top level Maven POMoptional projects are compiled

<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>

Options

Page 5: Developing CAS in Eclipse

Java Subproject POM <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 for Compile

Generated result

Page 6: Developing CAS in Eclipse

Maven build WAR

Main POM

webapp HTML + POM

artifact jarartifact jarartifact jarartifact jar cas.war

WEB-INF/lib

Page 7: Developing CAS in Eclipse

cas-server-webapp/pom.xmlcore required, add option JARs

<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

Addoptionartifactsyou choose

Page 8: Developing CAS in Eclipse

Eclipse “workspace”, CAS “project”Maven projects

Main POM

subproject

subproject

subproject

CAS3xx [Eclipse project]

{$home}/workspace

Page 9: Developing CAS in Eclipse

Assume You Know How

• Install current Java• Install Apache Tomcat• Install and use Maven 2.0.9

Because this is all part of the standard CAS development instructions.

Page 10: Developing CAS in Eclipse

Fork In the Road

Eclipse Web Standard Tools

• Free• Part of Eclipse project• Open source• New release each June• Independent plugins don’t

work smoothly together

MyEclipse

• $31.75 /year• Genuitec.com• Includes WST, plus Spring,

WS, Hibernate, JPA, …• A particular group of plugins

have been integrated

Page 11: Developing CAS in Eclipse

WST Debugging

Tomcatdirectory

Eclipse

CAS classes

Webproject

Servers/conf

Tomcat process

Page 12: Developing CAS in Eclipse

MyEclipse

Eclipse

CAS Project

Tomcat, JBoss, …

WebContent

WEB-INF/classes

Java Source

/webapps or /deploy

Page 13: Developing CAS in Eclipse

By any other Name

• A “project” in Eclipse or Maven is a directory with source subdirectories that can be compiled to produce a JAR file or zipped up to produce a WAR file

• A “Java Project” has source to compile. It can produce a program or a JAR library.

• A “static Web project” is a bunch of HTML, CSS, and image files that you can deploy to any Web Server. It has no Java.

Page 14: Developing CAS in Eclipse

By Any Other Name

• A “dynamic Web application project” has a WEB-INF subdirectory with a web.xml file

• A “WAR file” is a zipped up copy of the dynamic Web application, but the unzipped directory is also sometimes called a WAR too.

• A “context” is the runtime environment created by the Web server to run the code in a dynamic Web application

Page 15: Developing CAS in Eclipse

Ganymede WST

• Dynamic Web projects can only be created empty. A Java SE project cannot be converted into a dynamic Web project. The JA-SIG CAS source is an ordinary Java SE source project.

• Create an empty dynamic Web project. Copy the cas-server-webapp contents. Configure the CAS project as a “library module” for the Web project . Finally, copy external JAR dependencies into the WEB-INF/lib.

Page 16: Developing CAS in Eclipse

WST Runtime Magic

• <Context docBase="casx" path="/casx“ source="org.eclipse.jst.jee.server:casx"/>

• Get files from the dynamic Web project dir.• Get classes from the CAS compiler output

directory.• No support for Maven dependencies.

Page 17: Developing CAS in Eclipse

Create WST project

Tomcatdirectory

Eclipse

Library Project(CAS source)

dynamic webproject (WAR)

Tomcat/conf

copy from cas-server-webapp projectthe src/main/webapp files andtarget/cas-server-webapp-3.3/WEB-INF/lib jars

new dynamic Web proj

Server

Page 18: Developing CAS in Eclipse

MyEclipse

• Good News: MyEclipse can add “dynamic Web application” behavior to an existing Java (SE) project.

• Bad News: MyEclipse uses the WEB-INF/classes directory as a build work area, so the WebContent directory can’t be in cas-server-webapp

• Copy cas-server-webapp source to an new WebContent directory

Page 19: Developing CAS in Eclipse

MyEclipse Deployment

• Web application is copied to the real external {tomcat}/webapps directory and the real external server configuration is started

• Tomcat runs with normal environment, under with Eclipse debugging

• Any problems can be fixed by standard Tomcat documentation and configuration

• Application can also run under Tomcat without Eclipse

Page 20: Developing CAS in Eclipse

Download Ganymede EE from www.eclipse.org/downloads

Page 21: Developing CAS in Eclipse

Download MyEclipse 7.0 (M2 or later)

Page 22: Developing CAS in Eclipse

Common Steps

Page 23: Developing CAS in Eclipse

Add update sites

Help – Software Updates – Available Software

Page 24: Developing CAS in Eclipse

Subversion

EclipseSubversion

TeamProvider

PolarionSubversive

SVNConnectors

Windows-onlyNative Java 1.5 HL

1.5 HL Win32 binaries

Unix or WindowsSVNKit 1.2.0

Page 25: Developing CAS in Eclipse

SVN Repository Exploring

Page 26: Developing CAS in Eclipse

Checkout

• JA-SIG source repository looks like a tree of projects

• Select the trunk or a tagged release and check out as a Java (SE) project

Page 27: Developing CAS in Eclipse

Update Dependencies

Page 28: Developing CAS in Eclipse

Maven: cas-server-core is a “project”Eclipse: cas-server-core/src/main/java is a “src dir”

Page 29: Developing CAS in Eclipse

Build Path (GUI to .classpath)

Page 30: Developing CAS in Eclipse

Build Path (GUI to .classpath)

Page 31: Developing CAS in Eclipse

Package Explorer - Libraries

Page 32: Developing CAS in Eclipse

WST in Ganymede EE

Page 33: Developing CAS in Eclipse

WST New Dynamic Web Project

Page 34: Developing CAS in Eclipse

New Dynamic Web Project Wizard

Page 35: Developing CAS in Eclipse
Page 36: Developing CAS in Eclipse

Cut and Paste

• Copy (cut and paste) the Web application files (cas-server-webapp/src/main/webapp/*) from the CAS source project to the WebContent directory of the new dynamic Web project

• Click OK to replace the generated web.xml file in WEB-INF

Page 37: Developing CAS in Eclipse

WST Java EE Module Dependencies

Page 38: Developing CAS in Eclipse

Get the POM dependencies

• “cd” to Workspace, CAS source project directory

• run “mvn install” command• Refresh the Eclipse view of the project.• Go to cas-server-webapp/target/cas-server-

webapp-3.3/WEB-INF/lib• Copy all the external JAR files (exclude the

cas-server-*.jar files) to the WEB-INF/lib of the new dynamic Web project

Page 39: Developing CAS in Eclipse

Validation

• WST has validators for HTML, XML, etc.• Some CAS source files fail validation (headers,

footers, etc.)• In WST, only option is to disable validation for

the entire project.

Page 40: Developing CAS in Eclipse

MyEclipse

Page 41: Developing CAS in Eclipse

Add Web Project Capabilitiesto existing CAS project

Page 42: Developing CAS in Eclipse

MyEclipse Wizard

Page 43: Developing CAS in Eclipse

Adding Web capabilities

• MyEclipse changes the default compiler output directory to WebContent/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]

Page 44: Developing CAS in Eclipse

J2EE 1.4 Libraries

Page 45: Developing CAS in Eclipse

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

• WebContent – used by Eclipse (tell SVN to ignore it)– reflects your local test Tomcat environment

Page 46: Developing CAS in Eclipse

WEB-INF/classes

• Source directories are compiled and classes are stored here

• Data files (resources) are copied here• add “cas-server-webapp/src/main/webapp/

WEB-INF/classes” as a MyEclipse “source” directory to get *.properties files

• Put JUnit class files someplace else (/test-bin)

Page 47: Developing CAS in Eclipse
Page 48: Developing CAS in Eclipse

Select one or more J2EE App Servers

Exploded deployments are changed “on the fly” after save and compile.

Page 49: Developing CAS in Eclipse

Application Server Buttons

Manuallyredeploy

Run Application Server(Tomcat)

Page 50: Developing CAS in Eclipse

Start the Server