Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to apply a patch to a Java project?

Tags:

eclipse

patch

The patch is for nutch 0.9: http://cvs.tty.org/~butch/blog/nutch_0.9_OR.patch

How should I apply the patch correctly?

OS is windows XP

More specifically, I'm using eclipse to debug a nutch project.

Here is my trial:

D:\nutch-0.9.bak>patch -p0 < nutch_0.9_OR.patch
Hmm...  Looks like an ed script to me...
(Patch is indented 5 spaces.)
The text leading up to this was:
--------------------------
|diff -rBNu src.orig/java/org/apache/nutch/analysis/NutchAnalysisConstants.java src/java/org/apache/nutch/analysis/NutchAnalysisConstants.java
|--- src.orig/java/org/apache/nutch/analysis/NutchAnalysisConstants.java        2009-03-10 11:34:01.000000000 -0700
|+++ src/java/org/apache/nutch/analysis/NutchAnalysisConstants.java     2009-03-10 14:11:55.000000000 -0700
|@@ -4,30 +4,34 @@
| public interface NutchAnalysisConstants {
|
|   int EOF = 0;
|-  int WORD = 1;
|-  int ACRONYM = 2;
|-  int SIGRAM = 3;
|-  int IRREGULAR_WORD = 4;
|-  int C_PLUS_PLUS = 5;
|-  int C_SHARP = 6;
|-  int PLUS = 7;
|-  int MINUS = 8;
|-  int QUOTE = 9;
|-  int COLON = 10;
|-  int SLASH = 11;
|-  int DOT = 12;
|-  int ATSIGN = 13;
|-  int APOSTROPHE = 14;
|-  int WHITE = 15;
|-  int WORD_PUNCT = 16;
|-  int LETTER = 17;
|-  int CJK = 18;
|-  int DIGIT = 19;
|+  int QOR = 1;
|+  int WORD = 2;
|+  int ACRONYM = 3;
|+  int SIGRAM = 4;
|+  int IRREGULAR_WORD = 5;
|+  int C_PLUS_PLUS = 6;
|+  int C_SHARP = 7;
|+  int PLUS = 8;
|+  int MINUS = 9;
|+  int QUOTE = 10;
|+  int COLON = 11;
|+  int SLASH = 12;
|+  int LPAREN = 13;
|+  int RPAREN = 14;
|+  int DOT = 15;
|+  int ATSIGN = 16;
|+  int APOSTROPHE = 17;
|+  int WHITE = 18;
|+  int WORD_PUNCT = 19;
|+  int LETTER = 20;
|+  int CJK = 21;
|+  int DIGIT = 22;
|
|   int DEFAULT = 0;
|
|   String[] tokenImage = {
|     "<EOF>",
|+    "\"OR\"",
|     "<WORD>",
|     "<ACRONYM>",
|     "<SIGRAM>",
|@@ -39,6 +43,8 @@
|     "\"\\\"\"",
|     "\":\"",
|     "\"/\"",
|+    "\"(\"",
|+    "\")\"",
|     "\".\"",
|     "\"@\"",
|     "\"\\\'\"",
|diff -rBNu src.orig/java/org/apache/nutch/analysis/NutchAnalysis.java src/java/org/apache/nutch/analysis/NutchAnalysis.java
|--- src.orig/java/org/apache/nutch/analysis/NutchAnalysis.java 2009-03-10 11:34:01.000000000 -0700
|+++ src/java/org/apache/nutch/analysis/NutchAnalysis.java      2009-03-10 14:11:55.000000000 -0700
|@@ -56,7 +56,11 @@
|           queryString, (analyzer != null) ? analyzer : new NutchDocumentAnalyzer(conf));
|     parser.queryString = queryString;
|     parser.queryFilters = new QueryFilters(conf);
|-    return parser.parse(conf);
|+    try {
|+      return parser.parse(conf);
|+    } catch (ParseException pe) {
|+      throw new IOException("Parse exception: " + pe);
|+    }
|   }
|
|   /** For debugging. */
|@@ -77,44 +81,60 @@
|   String field;
|   boolean stop;
|   boolean prohibited;
|+  boolean required;
|     nonOpOrTerm();
|     label_1:
--------------------------
File to patch:
like image 299
omg Avatar asked Jun 12 '09 11:06

omg


2 Answers

Since you mentioned Eclipse - right-click on the project, go to Team -> Apply patch.

like image 82
Robert Munteanu Avatar answered Oct 12 '22 08:10

Robert Munteanu


You should use right click on project, Team/Apply patch.

The third step of the wizard (review patch) contains a Patch Content section where the modified source files are listed.

like image 43
Zoltán Ujhelyi Avatar answered Oct 12 '22 08:10

Zoltán Ujhelyi