[Arakhnę-Dev] [196] * Bug fix: regex patterns are fixed to match the classnames.

[ Thread Index | Date Index | More arakhne.org/dev Archives ]


Revision: 196
Author:   galland
Date:     2011-01-04 00:49:51 +0100 (Tue, 04 Jan 2011)
Log Message:
-----------
* Bug fix: regex patterns are fixed to match the classnames.

Modified Paths:
--------------
    trunk/maven-javadoc-tag-replacer/src/main/java/org/arakhne/maven/javadoc_tag_replacer/ReplaceMojo.java

Property Changed:
----------------
    trunk/maven-javadoc-tag-replacer/

Property changes on: trunk/maven-javadoc-tag-replacer
___________________________________________________________________
Modified: svn:ignore
   - .classpath
..project
..settings
target

   + .classpath
..project
..settings
target
..metadata


Modified: trunk/maven-javadoc-tag-replacer/src/main/java/org/arakhne/maven/javadoc_tag_replacer/ReplaceMojo.java
===================================================================
--- trunk/maven-javadoc-tag-replacer/src/main/java/org/arakhne/maven/javadoc_tag_replacer/ReplaceMojo.java	2011-01-03 20:49:44 UTC (rev 195)
+++ trunk/maven-javadoc-tag-replacer/src/main/java/org/arakhne/maven/javadoc_tag_replacer/ReplaceMojo.java	2011-01-03 23:49:51 UTC (rev 196)
@@ -110,7 +110,7 @@
 			+"src"+File.separator //$NON-NLS-1$
 			+"main"+File.separator //$NON-NLS-1$
 			+"java"+File.separator  //$NON-NLS-1$
-			+"(.*)$";  //$NON-NLS-1$
+			+"(.*)\\.java$";  //$NON-NLS-1$
 		Pattern p = Pattern.compile(pattern);
     	for(File file : javaFiles) {
     		Matcher matcher = p.matcher(file.getAbsolutePath());
@@ -169,20 +169,37 @@
     }
     
     private ExtendedArtifact searchArtifact(File file) {
-		String pattern = "^(.+)"+File.separator //$NON-NLS-1$
+    	getLog().info("Retreiving module for "+file.getAbsolutePath()); //$NON-NLS-1$
+
+    	String pattern = "^(.+)"+File.separator //$NON-NLS-1$
 				+"site"+File.separator //$NON-NLS-1$
 				+"apidocs"+File.separator //$NON-NLS-1$
-				+".*\\.html$";  //$NON-NLS-1$
+				+"(.+"+File.separator //$NON-NLS-1$
+				+".+?)(\\..+)?\\.html$";  //$NON-NLS-1$
 		Pattern p = Pattern.compile(pattern);
 		Matcher matcher = p.matcher(file.getAbsolutePath());
 		if (matcher.find()) {
-			File outDirectory = new File(matcher.group(1));
-			String pomPath = outDirectory.getParent();
+			String classname = matcher.group(2);
+			classname = classname.replaceAll(File.separator+"class[-]use", "");  //$NON-NLS-1$//$NON-NLS-2$
+			String pomPath = this.javaFileMap.get(classname);
+			if (pomPath!=null) {
+				ExtendedArtifact a = this.currentArtifact.get(pomPath);
+				if (a!=null) {
+			    	getLog().info("Found: "+a.toString()); //$NON-NLS-1$
+					return a;
+				}
+			}
+			pomPath = new File(matcher.group(1)).getParent();
 			ExtendedArtifact a = this.currentArtifact.get(pomPath);
 			if (a!=null) {
+		    	getLog().info("Found: "+a.toString()); //$NON-NLS-1$
 				return a;
 			}
+			getLog().info("Not Found: no pom description found"); //$NON-NLS-1$
 		}
+		else {
+			getLog().info("Not Found: regex is not matching"); //$NON-NLS-1$
+		}
     	return null;
     }
     


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/