Created
January 5, 2011 11:31
-
-
Save alterisian/766206 to your computer and use it in GitHub Desktop.
Ascii Cast for Using Gradle For Building A Webapp by Victor Savkin
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original Video: http://vimeo.com/18252871 by Victor Savkin ( http://twitter.com/avix1000 ) | |
Asciicast by Ian Moss ( http://twitter.com/oceanician ) of CTI Digital: Grails team - http://www.ctisn.com | |
------------------------------------------------------------------------------------- | |
"Hi, I'm Victor Savkin." | |
"3rd Gradle screencast." | |
"Create the gradle build file" | |
"How to run the app" | |
"How to create the war" | |
"Going to use Groovy this time instead of Java." | |
------------------------------------------------------------ | |
*Terminal: | |
vim build.gradle | |
mkdir src | |
mkdir src/main | |
mkdir src/main/groovy | |
vim build.gradle | |
gradle idea | |
------------------------------------------------------------ | |
*File:build.xml | |
apply plugin: 'groovy' | |
------------------------------------------------------------ | |
*Terminal: | |
mkdir src/main/webapp | |
------------------------------------------------------------ | |
*File:build.xml | |
apply plugin: 'war' | |
apply plugin: 'idea' | |
------------------------------------------------------------ | |
2.44 - "Let's open idea" | |
*Terminal: | |
gradle idea | |
ls -al | |
*Generates-> | |
.gradle | |
build.gradle | |
src | |
webapp.iml | |
webapp.ipr | |
webapp.iws | |
------------------------------------------------------------ | |
"First of all, we will add groovy support to idea." | |
(Via right click webapp, and menu 'Add Framework Support' and select 'Groovy') | |
"We will create a simple servlet, in the package gradlescreencast." | |
*Creates class: GoodGuyServlet.groovy | |
package gradlescreencast | |
import javax.servlet.http.HttpServlet | |
import javax.servlet.http.HttpServletRequest | |
import javax.servlet.http.HttpServletResponse | |
class GoodGuyServlet extends HttpServlet { | |
protected void doGet(HttpServletRequest req, HttpServletResponse resp) { | |
String name = req.getParameter("name") | |
resp.outputStream.withWriter { | |
it << "Hi ${name}!" | |
} | |
} | |
} | |
3.44 - | |
------------------------------------------------------------ | |
4.22 - "create XML file to map" - web.xml | |
*Creates new directory 'WEB-INF' under src/webapp | |
*Creates new file 'web.xml' | |
<web-app> | |
<servlet> | |
<servlet-name>GoodGuy</servlet-name> | |
<servlet-class>gradlescreencast.GoodGuyServlet</servlet-class> | |
</servlet> | |
<servlet-mapping> | |
<servlet-name>GoodGuy</servlet-name> | |
<url-pattern>/hi</url-pattern> | |
</servlet-mapping> | |
</web-app> | |
------------------------------------------------------------ | |
create a WAR file | |
Terminal: | |
gradle war | |
------------------------------------------------------------ | |
5.08 - "It doesn't work, but this is not a suprise as didn't add in groovy library." | |
5.21 - "First of all we add in the maven central repositories." | |
5.40 - "And then the dependancy itself" | |
IDEA: edit 'build.gradle' | |
apply plugin: 'groovy' | |
apply plugin: 'war' | |
apply plugin: 'idea' | |
repositories { | |
mavenCentral() | |
} | |
dependancies { | |
groovy 'org.codehaus.groovy:groovy-all:1.7.5' | |
providedCompile 'javax.servlet:servlet-api:2.5' | |
} | |
------------------------------------------------------------ | |
6.08 - "try to create war once again" | |
Terminal: | |
gradle war | |
6.26 - "It works" | |
(see build/libs/webapp.war) | |
7.05 - "add jetty plugin to the build file" | |
vim build.gradle | |
------------------------------------------------------------ | |
Terminal: | |
try | |
gradle jettyRun | |
"open web browser to: | |
http://localhost:8080/webapp/hi?name=John | |
------------------------------------------------------------ | |
7.48 - "Conventention over Configuration allows you to not to think without lots of parameters." | |
"The configuration that is usually a nightmare with Ant or Maven looks very good and concise." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment