Guten abend allerseits
Ich bin gerade dabei, meinem Projekt den letzten schliff zu geben. Dazu gehörte unter anderem auch, die javadoc zu vervollständigen und Maven2 vollends zu integrieren
Zuerst kurz die verwendeten Tools/Frameworks/IDE's etc
Maven 2.1.0
SpringFramework 2.5
Eclipse Galileo
Java 6
Tomcat6/Jetty6
Es handelt sich um eine Webapplikation welche mit dem springframework realisiert wurde. Ich habe unteranderem verschiedene Validatoren implementiert, welche alle von org.springframework.validation.Validator ableiten, zudem einige Controller (ableitend von: org.springframework.web.servlet.mvc.Controller) und FormController (org.springframework.web.servlet.mvc.SimpleFormController).
Soweit so gut, keine Probleme. Um mir allerdings die Sache ein wenig zu verkürzen, habe ich die Standardmethoden der Klassen per /** {@inheritDoc} */ gekennzeichnet. Die Methoden sind namentlich:
im Validator: public boolean supports(Class clazz) und public void validate(Object target, Errors errors)
im Controller: public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) throws Exception
und im FormController: protected ModelAndView showForm(HttpServletRequest request, HttpServletResponse response, BindException errors) throws Exception, protected Object formBackingObject(HttpServletRequest request) throws Exception und protected ModelAndView onSubmit(HttpServletRequest request, HttpServletResponse response, Object obj, BindException errors) throws Exception
Wenn ich nun per mvn javadoc:javadoc die Doku generieren lassen will, existiert bei diesen Methoden zwar ein Eintrag, dass die Javadoc sonst wo definiert wurde, allerdings nicht der inhalt von diesen klassen.
Ich habe danach ein bisschen nachgeforscht, und kam auf die option sourcepath. Ich habs allerdings nicht hingekriegt, das zum laufen zu bringen. Zudem fehlt im Repository (Lokal wie auf Global) das Javadoc.jar der Dependencies.
Meine Frage ist nun, ob es irgendwie möglich ist, die Javadoc dieser Dependencies direkt in meine hineinzuladen, also sozusagen das javadoc-plugin zuerst über die Dependencies laufen zu lassen. Gibts da irgendwas direktes?
Im Anhang mein pom.xml und einer der Validatoren
TechnologyValidator
Auszug aus pom.xml (build) (Javadoc Plugin ab Zeile 107)
[JAVA=38]
<build>
<plugins>
<!-- Maven COMPILER plugin -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.0.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
<!-- Maven WAR plugin -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.0.2</version>
<configuration>
<warName>${project.name}</warName>
<archive>
<manifestEntries>
<classPath>WEB-INF/lib</classPath>
</manifestEntries>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>2.0-beta-9</version>
</plugin>
<!-- Maven RELEASE Plugin -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>2.0-beta-9</version>
<configuration>
<tagBase>
file:///${localRepository}/ch/clx/azubi/ApprenticePortal
</tagBase>
</configuration>
</plugin>
<!-- Maven SCM Plugin -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-scm-plugin</artifactId>
<version>1.2</version>
<configuration>
<connectionType>developerConnection</connectionType>
<basedir />
<message>Auto checkin by Maven2</message>
<goals>package</goals>
</configuration>
</plugin>
<!-- Maven RESOURCE plugin -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<configuration>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
<!-- Maven JAVADOC plugin -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.5</version>
<configuration>
<!-- sourcepath>${localRepository}\**\*.jar</sourcepath-->
<encoding>UTF-8</encoding>
<localRepository>${localRepository}</localRepository>
</configuration>
</plugin>
<!-- Maven DEPENDENCY plugin -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.1</version>
</plugin>
</plugins>
</build>
[/code]
Ich bin gerade dabei, meinem Projekt den letzten schliff zu geben. Dazu gehörte unter anderem auch, die javadoc zu vervollständigen und Maven2 vollends zu integrieren
Zuerst kurz die verwendeten Tools/Frameworks/IDE's etc
Maven 2.1.0
SpringFramework 2.5
Eclipse Galileo
Java 6
Tomcat6/Jetty6
Es handelt sich um eine Webapplikation welche mit dem springframework realisiert wurde. Ich habe unteranderem verschiedene Validatoren implementiert, welche alle von org.springframework.validation.Validator ableiten, zudem einige Controller (ableitend von: org.springframework.web.servlet.mvc.Controller) und FormController (org.springframework.web.servlet.mvc.SimpleFormController).
Soweit so gut, keine Probleme. Um mir allerdings die Sache ein wenig zu verkürzen, habe ich die Standardmethoden der Klassen per /** {@inheritDoc} */ gekennzeichnet. Die Methoden sind namentlich:
im Validator: public boolean supports(Class clazz) und public void validate(Object target, Errors errors)
im Controller: public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) throws Exception
und im FormController: protected ModelAndView showForm(HttpServletRequest request, HttpServletResponse response, BindException errors) throws Exception, protected Object formBackingObject(HttpServletRequest request) throws Exception und protected ModelAndView onSubmit(HttpServletRequest request, HttpServletResponse response, Object obj, BindException errors) throws Exception
Wenn ich nun per mvn javadoc:javadoc die Doku generieren lassen will, existiert bei diesen Methoden zwar ein Eintrag, dass die Javadoc sonst wo definiert wurde, allerdings nicht der inhalt von diesen klassen.
Ich habe danach ein bisschen nachgeforscht, und kam auf die option sourcepath. Ich habs allerdings nicht hingekriegt, das zum laufen zu bringen. Zudem fehlt im Repository (Lokal wie auf Global) das Javadoc.jar der Dependencies.
Meine Frage ist nun, ob es irgendwie möglich ist, die Javadoc dieser Dependencies direkt in meine hineinzuladen, also sozusagen das javadoc-plugin zuerst über die Dependencies laufen zu lassen. Gibts da irgendwas direktes?
Im Anhang mein pom.xml und einer der Validatoren
TechnologyValidator
Java:
public class TechnologyAddValidator extends Validator{
private int minLengthName = DEFAULT_TEXT_MIN_LENGTH, maxLengthName = DEFAULT_TEXT_MAX_LENGTH, minLengthIdent = DEFAULT_IDENT_MIN_LENGTH,
maxLengthIdent = DEFAULT_IDENT_MAX_LENGTH, minLengthUrl = DEFAULT_URL_MIN_LENGTH, maxLengthUrl = DEFAULT_URL_MAX_LENGTH;
private TechnologyService technologyService;
/**
* {@inheritDoc}
*/
@SuppressWarnings("unchecked")
@Override
public boolean supports(Class clazz) {
return TechnologyForm.class.isAssignableFrom(clazz);
}
/**
* {@inheritDoc}
*/
@Override
public void validate(Object target, Errors errors) {
int prevErrors = errors.getErrorCount();
TechnologyForm technologyForm = (TechnologyForm) target;
logger.info("Validation TechnologyForm or subclasses");
ValidationUtils.rejectIfEmptyOrWhitespace(errors, "name", "error.required");
ValidationUtils.rejectIfEmptyOrWhitespace(errors, "ident", "error.required");
ValidationUtils.rejectIfEmptyOrWhitespace(errors, "url", "error.required");
if (technologyForm != null) {
if (technologyForm.getName().length() > maxLengthName) {
errors.rejectValue("name", "error.too-long", new Object[] { maxLengthName }, "Name too long");
} else if (technologyForm.getName().length() < minLengthName) {
errors.rejectValue("name", "error.too-short", new Object[] { minLengthName }, "Name too short");
}
if (technologyForm.getIdent().length() > maxLengthIdent) {
errors.rejectValue("ident", "error.too-long", new Object[] { maxLengthIdent }, "Ident too long");
} else if (technologyForm.getIdent().length() < minLengthIdent) {
errors.rejectValue("ident", "error.too-short", new Object[] { minLengthIdent }, "Ident too short");
}
if (technologyForm.getUrl().length() > maxLengthUrl) {
errors.rejectValue("url", "error.too-long", new Object[] { maxLengthUrl }, "URL too long");
} else if (technologyForm.getUrl().length() < minLengthUrl) {
errors.rejectValue("url", "error.too-short", new Object[] { minLengthUrl }, "URL too short");
}
if (!new UrlValidator().isValid(technologyForm.getUrl())) {
boolean added = false;
if (!technologyForm.getUrl().startsWith("http")) {
technologyForm.setUrl("http://" + technologyForm.getUrl());
added = true;
}
if (!new UrlValidator().isValid(technologyForm.getUrl())) {
errors.rejectValue("url", "error.url-invalid", new Object[] {}, "URL has invalid format");
if (added) {
technologyForm.setUrl(technologyForm.getUrl().substring(6));
}
}
}
if (!technologyService.isUniqueAdd(technologyForm)) {
errors.rejectValue("ident", "error.already-exists");
}
}
if (prevErrors < errors.getErrorCount()) {
logger.info("Validated TechnologyForm had " + (errors.getErrorCount() - prevErrors) + " validation failures");
} else {
logger.info("Validated TechnologyForm is valid");
}
}
public int getMinLengthName() {
return minLengthName;
}
public int getMaxLengthName() {
return maxLengthName;
}
public int getMinLengthIdent() {
return minLengthIdent;
}
public int getMaxLengthIdent() {
return maxLengthIdent;
}
public int getMinLengthUrl() {
return minLengthUrl;
}
public int getMaxLengthUrl() {
return maxLengthUrl;
}
public void setMinLengthName(int minLengthName) {
logger.info("Set minimum length for name to: " + minLengthName);
this.minLengthName = minLengthName;
}
public void setMaxLengthName(int maxLengthName) {
logger.info("Set maximum length for name to: " + maxLengthName);
this.maxLengthName = maxLengthName;
}
public void setMinLengthIdent(int minLengthIdent) {
logger.info("Set minimum length for ident to: " + minLengthIdent);
this.minLengthIdent = minLengthIdent;
}
public void setMaxLengthIdent(int maxLengthIdent) {
logger.info("Set maximum length for ident to: " + maxLengthIdent);
this.maxLengthIdent = maxLengthIdent;
}
public void setMinLengthUrl(int minLengthUrl) {
logger.info("Set minimum length for url to: " + minLengthUrl);
this.minLengthUrl = minLengthUrl;
}
public void setMaxLengthUrl(int maxLengthUrl) {
logger.info("Set maximum length for url to: " + maxLengthUrl);
this.maxLengthUrl = maxLengthUrl;
}
public void setTechnologyService(TechnologyService technologyService) {
this.technologyService = technologyService;
}
}
Auszug aus pom.xml (build) (Javadoc Plugin ab Zeile 107)
[JAVA=38]
<build>
<plugins>
<!-- Maven COMPILER plugin -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.0.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
<!-- Maven WAR plugin -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.0.2</version>
<configuration>
<warName>${project.name}</warName>
<archive>
<manifestEntries>
<classPath>WEB-INF/lib</classPath>
</manifestEntries>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>2.0-beta-9</version>
</plugin>
<!-- Maven RELEASE Plugin -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>2.0-beta-9</version>
<configuration>
<tagBase>
file:///${localRepository}/ch/clx/azubi/ApprenticePortal
</tagBase>
</configuration>
</plugin>
<!-- Maven SCM Plugin -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-scm-plugin</artifactId>
<version>1.2</version>
<configuration>
<connectionType>developerConnection</connectionType>
<basedir />
<message>Auto checkin by Maven2</message>
<goals>package</goals>
</configuration>
</plugin>
<!-- Maven RESOURCE plugin -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<configuration>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
<!-- Maven JAVADOC plugin -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.5</version>
<configuration>
<!-- sourcepath>${localRepository}\**\*.jar</sourcepath-->
<encoding>UTF-8</encoding>
<localRepository>${localRepository}</localRepository>
</configuration>
</plugin>
<!-- Maven DEPENDENCY plugin -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.1</version>
</plugin>
</plugins>
</build>
[/code]