Recent Notes
Displaying keyword search results 91 - 100
Created by Fang on August 22, 2009 21:48:12
Last update: January 10, 2010 00:29:08
The POM (Project Object Model, pom.xml ) is at the heart of all Maven builds. It tells Maven how to build your project, just like build.xml for Ant. This is a POM for a simple Hello World project:
<project xmlns="http://maven.apache.org/POM/4.0.0"...
Not much can be inferred from the POM file alone, because lots of information is implied . For example, packaging defaults to jar , which means that if nothing is specified, Maven compiles all java files under src/main/java and creates a jar .
All Maven POMs inherit from a base Super POM. To see the effective POM for your project, type mvn help:effective-pom :
C:\maven\hello-world>mvn help:effective-pom
Below is the Super POM for Maven 2.0.x.
<project>
<modelVersion>4.0.0</modelVersion>
...
Created by Fang on August 13, 2009 03:32:36
Last update: January 09, 2010 21:34:34
Maven asks you to organize your project by a standard directory layout. Although you can override the proposed structure via the project descriptor , conformance is strongly recommended. At the top level there are only two directories: src and target . The target directory is used to house all output of the build. The src directory contains all of the source material for building the project, its site and so on. The src directory contains a subdirectory for each type of resources: main for the main build artifact test for the unit test code site for your project site's documentation This is the general layout: Directory Description LICENSE.tx t Project's license README.txt Project's readme pom.xml The Maven "Project Object Model" src/main/java under which the normal...
Created by Dr. Xi on December 04, 2009 04:33:05
Last update: December 04, 2009 04:33:05
Variable Meaning $_ The default or implicit variable. @_ Within a subroutine the array @_ contains the parameters passed to that subroutine. $a, $b Special package variables when using sort() $<digit> Contains the subpattern from the corresponding set of capturing parentheses from the last pattern match, not counting patterns matched in nested blocks that have been exited already. $. Current line number for the last filehandle accessed. $/ The input record separator, newline by default. $| If set to nonzero, forces a flush right away and after every write or print on the currently selected output channel. Default is 0 (regardless of whether the channel is really buffered by the system or not; $| tells you only whether you've asked Perl explicitly to flush after...
Created by Dr. Xi on October 18, 2009 04:25:25
Last update: October 18, 2009 04:25:25
start python with python -v
import django and print version:
Type "help", "copyright", "credits" or "license" f...
Created by voodoo on October 03, 2009 21:34:35
Last update: October 03, 2009 21:34:56
One liners:
Oldest
find . -printf "%T@ %Tx %TX %p\n" | sort -n | head...
Newest
find . -printf "%T@ %Tx %TX %p\n" | sort -n -r | h...
Shell scripts:
Oldest
#!/bin/ksh
touch -t $(($(date "+%Y") + 1))$(dat...
Newest
#!/bin/ksh
touch -t 197001010000 compareTo
N...
Created by Fang on September 07, 2009 16:39:37
Last update: September 07, 2009 18:43:04
It's easiest to use the archetype plugin to start a new Maven project. I'll use struts 1 as example since it's not in the built-in archetypes for archetype:generate . Generate a simple webapp with archetype:generate :
C:\work\maven>mvn archetype:generate -DarchetypeAr... It generates a directory structure like this: struts1app struts1app/pom.xml struts1app/src... with a simple POM: <project xmlns="http://maven.apache.org/POM/4.0.0"... Create settings.xml in $HOME/.m2 , add Java.net repository for Java EE dependencies: <?xml version="1.0" encoding="UTF-8"?> <setting... Add Java EE and Struts dependencies in pom.xml . Note that the Java EE dependency has scope provided , meaning that the web app container provides the jars, therefore we don't need to bundle them with our war fie. <project xmlns="http://maven.apache.org/POM/4.0.0"... Create a directory named java under main , create the Struts form and...
Created by Fang on August 13, 2009 04:18:26
Last update: August 13, 2009 04:18:26
To start a simple "Hello World" project in maven, enter:
mvn archetype:create -DgroupId=com.example -Dartif...
in the command line. It will take a while for Maven to run. But eventually it will create the standard Maven directory structure with a "Hello World" app and a fake JUnit test.
Enter
mvn package
will build the simple App into a jar under the target directory.
Run the resulting App:
C:\maven\hello-world>java -cp target\hello-world-1...
This is the generated pom:
<project xmlns="http://maven.apache.org/POM/4.0.0"...
Created by Dr. Xi on April 30, 2007 22:17:59
Last update: August 07, 2009 03:17:41
When you delete a file from CVS, the file is not actually deleted from the repository. Instead, a new revision is created and annotated as "dead" - in other words, put in the attic.
To bring back a file from the attic, you can copy the file to your checked out directory and add it back by "cvs add". Or, you can do a CVS update with the -j (join) option:
cvs update -j 1.2 -j 1.1 file1
which will restore revision 1.1 in your checked out directory (1.2 is the "dead" revision). Use cvs commit to add it back to the repository.
Created by Dr. Xi on June 06, 2009 20:05:49
Last update: June 06, 2009 20:06:32
Use os.listdir to list the contents of a directory:
import os
# list the contents of mydir. Cur...
Created by Dr. Xi on May 05, 2009 19:59:21
Last update: May 05, 2009 19:59:21
Delete a single file:
>>> import os
>>> file = 'myfile'
>>> os.rem...
Delete a directory and contents:
>>> import shutil
>>> dir(shutil)
['Error', ...