Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Generate a binary archive as part of generating a release

Remove tapestry-component-report (no longer built or used)
Add some missing licenses

TAP5-1790

git-svn-id: https://svn.apache.org/repos/asf/tapestry/tapestry5/trunk@1293355 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information...
commit d11943a51d170b4c57569c11b62b630b361e116a 1 parent bcb7605
@hlship hlship authored
View
9 NOTICE.txt
@@ -1,5 +1,12 @@
This product includes software developed by
The Apache Software Foundation (http://www.apache.org/).
-Please refer to the NOTICE.txt for each sub-module to
+Please refer to the NOTICE.txt in each sub-module to
identify further dependencies.
+
+The Maven central repository is the prefered method to download Tapestry
+and its dependencies. The binary archive includes just basic
+dependencies for tapestry-core; using other modules (such as
+tapestry-hibernate or any of the others) requires downloading
+additional dependencies. Please refer to the Maven POM for each module
+to identify its dependencies.
View
62 build.gradle
@@ -90,10 +90,19 @@ configurations {
if (doSign) {
published.extendsFrom signatures
}
+ binaries // additional dependencies included in the binary archive
}
dependencies {
javadoc project(":tapestry-javadoc")
+
+ // From tapestry-ioc:
+ binaries "javax.inject:javax.inject:1"
+ binaries "org.slf4j:slf4j-api:1.6.1"
+ binaries "log4j:log4j:1.2.14"
+ binaries "org.slf4j:slf4j-log4j12:1.6.1"
+ binaries "commons-codec:commons-codec:1.5"
+ binaries "org.antlr:antlr-runtime:3.3", { transitive = false }
}
subprojects {
@@ -313,6 +322,41 @@ task zippedJavadoc(type: Zip) {
into "apidocs"
}
+task zippedBinaries(type:Zip) {
+ description "Zip archive of binaries of each sub-project"
+ // TODO: Plus dependencies?
+ group "Release artifact"
+
+ destinationDir buildDir
+ baseName "apache-tapestry"
+ version project.version
+ classifier "bin"
+
+ // This is via some experimentation
+ from subprojects*.configurations*.archives.artifacts*.file*.findAll {
+ ! (it.name.endsWith(".asc") || it.name.startsWith("quickstart"))
+ }
+
+ from configurations.binaries
+
+ // Pick up various licenses and notices
+
+ from (projectDir) {
+ include "*.txt"
+ }
+
+ subprojects.each { sub ->
+ from (sub.projectDir) {
+ include "*.txt"
+ into sub.name
+ }
+ }
+
+
+
+}
+
+
if (canDeploy) {
@@ -323,21 +367,21 @@ if (canDeploy) {
}
- task generateMD5Checksums(type: GenMD5) {
- group "Release artifact"
- description "Creates MD5 checksums for archives of source and JavaDoc"
- source configurations.archives
- outputDir "$buildDir/md5"
- }
-
artifacts {
- archives zippedJavadoc, zippedSources
+ archives zippedJavadoc, zippedSources, zippedBinaries
}
configurations {
upload.extendsFrom archives, signatures
}
+ task generateMD5Checksums(type: GenMD5) {
+ group "Release artifact"
+ description "Creates MD5 checksums for archives of source and JavaDoc"
+ source tasks.withType(Zip)
+ outputDir "$buildDir/md5"
+ }
+
if (doSign) {
signing {
sign configurations.archives
@@ -348,7 +392,7 @@ if (canDeploy) {
group "Release artifact"
description "Uploads top-level artifacts to people.apache.org, along with MD5 checksums and PGP signatures (if signing is enabled)"
- source files(generateMD5Checksums, configurations.upload.allArtifacts.files)
+ source files(generateMD5Checksums, configurations.uploads.allArtifacts.files)
host "people.apache.org"
userName deployUsername()
View
202 tapestry-component-report/LICENSE.txt
@@ -1,202 +0,0 @@
-
- Apache License
- Version 2.0, January 2004
- http://www.apache.org/licenses/
-
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
- 1. Definitions.
-
- "License" shall mean the terms and conditions for use, reproduction,
- and distribution as defined by Sections 1 through 9 of this document.
-
- "Licensor" shall mean the copyright owner or entity authorized by
- the copyright owner that is granting the License.
-
- "Legal Entity" shall mean the union of the acting entity and all
- other entities that control, are controlled by, or are under common
- control with that entity. For the purposes of this definition,
- "control" means (i) the power, direct or indirect, to cause the
- direction or management of such entity, whether by contract or
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
- outstanding shares, or (iii) beneficial ownership of such entity.
-
- "You" (or "Your") shall mean an individual or Legal Entity
- exercising permissions granted by this License.
-
- "Source" form shall mean the preferred form for making modifications,
- including but not limited to software source code, documentation
- source, and configuration files.
-
- "Object" form shall mean any form resulting from mechanical
- transformation or translation of a Source form, including but
- not limited to compiled object code, generated documentation,
- and conversions to other media types.
-
- "Work" shall mean the work of authorship, whether in Source or
- Object form, made available under the License, as indicated by a
- copyright notice that is included in or attached to the work
- (an example is provided in the Appendix below).
-
- "Derivative Works" shall mean any work, whether in Source or Object
- form, that is based on (or derived from) the Work and for which the
- editorial revisions, annotations, elaborations, or other modifications
- represent, as a whole, an original work of authorship. For the purposes
- of this License, Derivative Works shall not include works that remain
- separable from, or merely link (or bind by name) to the interfaces of,
- the Work and Derivative Works thereof.
-
- "Contribution" shall mean any work of authorship, including
- the original version of the Work and any modifications or additions
- to that Work or Derivative Works thereof, that is intentionally
- submitted to Licensor for inclusion in the Work by the copyright owner
- or by an individual or Legal Entity authorized to submit on behalf of
- the copyright owner. For the purposes of this definition, "submitted"
- means any form of electronic, verbal, or written communication sent
- to the Licensor or its representatives, including but not limited to
- communication on electronic mailing lists, source code control systems,
- and issue tracking systems that are managed by, or on behalf of, the
- Licensor for the purpose of discussing and improving the Work, but
- excluding communication that is conspicuously marked or otherwise
- designated in writing by the copyright owner as "Not a Contribution."
-
- "Contributor" shall mean Licensor and any individual or Legal Entity
- on behalf of whom a Contribution has been received by Licensor and
- subsequently incorporated within the Work.
-
- 2. Grant of Copyright License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- copyright license to reproduce, prepare Derivative Works of,
- publicly display, publicly perform, sublicense, and distribute the
- Work and such Derivative Works in Source or Object form.
-
- 3. Grant of Patent License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- (except as stated in this section) patent license to make, have made,
- use, offer to sell, sell, import, and otherwise transfer the Work,
- where such license applies only to those patent claims licensable
- by such Contributor that are necessarily infringed by their
- Contribution(s) alone or by combination of their Contribution(s)
- with the Work to which such Contribution(s) was submitted. If You
- institute patent litigation against any entity (including a
- cross-claim or counterclaim in a lawsuit) alleging that the Work
- or a Contribution incorporated within the Work constitutes direct
- or contributory patent infringement, then any patent licenses
- granted to You under this License for that Work shall terminate
- as of the date such litigation is filed.
-
- 4. Redistribution. You may reproduce and distribute copies of the
- Work or Derivative Works thereof in any medium, with or without
- modifications, and in Source or Object form, provided that You
- meet the following conditions:
-
- (a) You must give any other recipients of the Work or
- Derivative Works a copy of this License; and
-
- (b) You must cause any modified files to carry prominent notices
- stating that You changed the files; and
-
- (c) You must retain, in the Source form of any Derivative Works
- that You distribute, all copyright, patent, trademark, and
- attribution notices from the Source form of the Work,
- excluding those notices that do not pertain to any part of
- the Derivative Works; and
-
- (d) If the Work includes a "NOTICE" text file as part of its
- distribution, then any Derivative Works that You distribute must
- include a readable copy of the attribution notices contained
- within such NOTICE file, excluding those notices that do not
- pertain to any part of the Derivative Works, in at least one
- of the following places: within a NOTICE text file distributed
- as part of the Derivative Works; within the Source form or
- documentation, if provided along with the Derivative Works; or,
- within a display generated by the Derivative Works, if and
- wherever such third-party notices normally appear. The contents
- of the NOTICE file are for informational purposes only and
- do not modify the License. You may add Your own attribution
- notices within Derivative Works that You distribute, alongside
- or as an addendum to the NOTICE text from the Work, provided
- that such additional attribution notices cannot be construed
- as modifying the License.
-
- You may add Your own copyright statement to Your modifications and
- may provide additional or different license terms and conditions
- for use, reproduction, or distribution of Your modifications, or
- for any such Derivative Works as a whole, provided Your use,
- reproduction, and distribution of the Work otherwise complies with
- the conditions stated in this License.
-
- 5. Submission of Contributions. Unless You explicitly state otherwise,
- any Contribution intentionally submitted for inclusion in the Work
- by You to the Licensor shall be under the terms and conditions of
- this License, without any additional terms or conditions.
- Notwithstanding the above, nothing herein shall supersede or modify
- the terms of any separate license agreement you may have executed
- with Licensor regarding such Contributions.
-
- 6. Trademarks. This License does not grant permission to use the trade
- names, trademarks, service marks, or product names of the Licensor,
- except as required for reasonable and customary use in describing the
- origin of the Work and reproducing the content of the NOTICE file.
-
- 7. Disclaimer of Warranty. Unless required by applicable law or
- agreed to in writing, Licensor provides the Work (and each
- Contributor provides its Contributions) on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- implied, including, without limitation, any warranties or conditions
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- PARTICULAR PURPOSE. You are solely responsible for determining the
- appropriateness of using or redistributing the Work and assume any
- risks associated with Your exercise of permissions under this License.
-
- 8. Limitation of Liability. In no event and under no legal theory,
- whether in tort (including negligence), contract, or otherwise,
- unless required by applicable law (such as deliberate and grossly
- negligent acts) or agreed to in writing, shall any Contributor be
- liable to You for damages, including any direct, indirect, special,
- incidental, or consequential damages of any character arising as a
- result of this License or out of the use or inability to use the
- Work (including but not limited to damages for loss of goodwill,
- work stoppage, computer failure or malfunction, or any and all
- other commercial damages or losses), even if such Contributor
- has been advised of the possibility of such damages.
-
- 9. Accepting Warranty or Additional Liability. While redistributing
- the Work or Derivative Works thereof, You may choose to offer,
- and charge a fee for, acceptance of support, warranty, indemnity,
- or other liability obligations and/or rights consistent with this
- License. However, in accepting such obligations, You may act only
- on Your own behalf and on Your sole responsibility, not on behalf
- of any other Contributor, and only if You agree to indemnify,
- defend, and hold each Contributor harmless for any liability
- incurred by, or claims asserted against, such Contributor by reason
- of your accepting any such warranty or additional liability.
-
- END OF TERMS AND CONDITIONS
-
- APPENDIX: How to apply the Apache License to your work.
-
- To apply the Apache License to your work, attach the following
- boilerplate notice, with the fields enclosed by brackets "[]"
- replaced with your own identifying information. (Don't include
- the brackets!) The text should be enclosed in the appropriate
- comment syntax for the file format. We also recommend that a
- file or class name and description of purpose be included on the
- same "printed page" as the copyright notice for easier
- identification within third-party archives.
-
- Copyright [yyyy] [name of copyright owner]
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
View
2  tapestry-component-report/NOTICE.txt
@@ -1,2 +0,0 @@
-This product includes software developed by
-The Apache Software Foundation (http://www.apache.org/).
View
103 tapestry-component-report/src/main/java/org/apache/tapestry/mojo/ClassDescription.java
@@ -1,103 +0,0 @@
-// Copyright 2007, 2009 The Apache Software Foundation
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package org.apache.tapestry.mojo;
-
-import org.apache.tapestry5.ioc.internal.util.CollectionFactory;
-
-import java.util.Map;
-
-public class ClassDescription
-{
- private final String superClassName;
-
- private final String className;
-
- private final String description;
-
- private final boolean supportsInformalParameters;
-
- private final Map<String, ParameterDescription> parameters = CollectionFactory.newCaseInsensitiveMap();
-
- private final Map<String, String> publishedParameters = CollectionFactory.newCaseInsensitiveMap();
-
- private final Map<String, String> events = CollectionFactory.newCaseInsensitiveMap();
-
- private final String since;
-
- private final boolean deprecated;
-
- public ClassDescription(String className, String superClassName, String description,
- boolean supportsInformalParameters, String since, boolean deprecated)
- {
- this.className = className;
- this.superClassName = superClassName;
- this.description = description;
- this.supportsInformalParameters = supportsInformalParameters;
- this.since = since;
- this.deprecated = deprecated;
- }
-
- public String getClassName()
- {
- return className;
- }
-
- public String getDescription()
- {
- return description;
- }
-
- public Map<String, ParameterDescription> getParameters()
- {
- return parameters;
- }
-
- public String getSuperClassName()
- {
- return superClassName;
- }
-
- public boolean isSupportsInformalParameters()
- {
- return supportsInformalParameters;
- }
-
- public String getSince()
- {
- return since;
- }
-
- public boolean isDeprecated()
- {
- return deprecated;
- }
-
- /**
- * Case insensitive map, keyed on parameter name, value is class name of component from which the parameter is
- * published.
- */
- public Map<String, String> getPublishedParameters()
- {
- return publishedParameters;
- }
-
- /**
- * Case insentive map, keyes on event name, value is optional description (often blank).
- */
- public Map<String, String> getEvents()
- {
- return events;
- }
-}
View
1,127 tapestry-component-report/src/main/java/org/apache/tapestry/mojo/ComponentReport.java
@@ -1,1127 +0,0 @@
-// Copyright 2007, 2008, 2009 The Apache Software Foundation
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package org.apache.tapestry.mojo;
-
-import java.io.BufferedInputStream;
-import java.io.BufferedOutputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.io.PrintWriter;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
-import java.util.Locale;
-import java.util.Map;
-import java.util.Set;
-import java.util.StringTokenizer;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-import nu.xom.Attribute;
-import nu.xom.Builder;
-import nu.xom.Document;
-import nu.xom.Element;
-import nu.xom.Elements;
-import nu.xom.Node;
-import nu.xom.Nodes;
-import nu.xom.ParsingException;
-
-import org.apache.commons.lang.StringEscapeUtils;
-import org.apache.commons.lang.StringUtils;
-import org.apache.commons.lang.SystemUtils;
-import org.apache.maven.artifact.Artifact;
-import org.apache.maven.artifact.repository.ArtifactRepository;
-import org.apache.maven.doxia.sink.Sink;
-import org.apache.maven.doxia.siterenderer.Renderer;
-import org.apache.maven.model.Resource;
-import org.apache.maven.project.MavenProject;
-import org.apache.maven.reporting.AbstractMavenReport;
-import org.apache.maven.reporting.MavenReportException;
-import org.apache.tapestry5.ioc.internal.util.CollectionFactory;
-import org.apache.tapestry5.ioc.internal.util.InternalUtils;
-import org.codehaus.plexus.util.cli.CommandLineException;
-import org.codehaus.plexus.util.cli.CommandLineUtils;
-import org.codehaus.plexus.util.cli.Commandline;
-import org.codehaus.plexus.util.cli.DefaultConsumer;
-
-/**
- * The component report generates documentation about components and parameters within the current project.
- *
- * @goal component-report
- * @requiresDependencyResolution compile
- * @execute phase="generate-sources"
- */
-@SuppressWarnings({ "unchecked" })
-public class ComponentReport extends AbstractMavenReport
-{
- /**
- * Subdirectory containing the component reference pages and index.
- */
- private static final String REFERENCE_DIR = "ref";
-
- private final static String[] PARAMETER_HEADERS = { "Name", "Type", "Flags", "Default", "Default Prefix",
- "Since", "Description" };
-
- private static final Pattern TAPESTRY5_PATTERN = Pattern.compile("(org\\.apache\\.tapestry5[#_\\w\\.]*)");
-
- private static final char QUOTE = '"';
-
- /**
- * Identifies the root packages of the library.
- *
- * @parameter
- * @required
- */
- private List<String> rootPackages;
-
- /**
- * The Maven Project Object
- *
- * @parameter expression="${project}"
- * @required
- * @readonly
- */
- private MavenProject project;
-
- /**
- * Generates the site report
- *
- * @component
- */
- private Renderer siteRenderer;
-
- /**
- * Location of the generated site.
- *
- * @parameter default-value="${project.reporting.outputDirectory}"
- * @required
- */
- private String outputDirectory;
-
- /**
- * @parameter expression="${project.build.directory}/generated-site/xdoc"
- * @required
- */
- private File generatedDocsDirectory;
-
- /**
- * @parameter expression="${project.build.directory}/generated-site/resources"
- * @required
- */
- private File generatedResourcesDirectory;
-
- /**
- * Working directory for temporary files.
- *
- * @parameter default-value="target"
- * @required
- */
- private String workDirectory;
-
- /**
- * Relative path from the generated report to the API documentation (Javadoc). Defaults to "apidocs" but will often
- * be changed to "../apidocs" when documentation is created at the project level.
- *
- * @parameter default-value="apidocs"
- * @required
- */
- private String apidocs;
-
- /**
- * Where to find tapestry javadocs. This is used for generating documentation links for each parameter type.
- * <p/>
- * By default, this is set to "http://tapestry.apache.org/tapestry5/apidocs". A relative path can also be supplied
- * (a sensible value would be 'apidocs') and is resolved from the documentation root.
- *
- * @parameter default-value="http://tapestry.apache.org/tapestry5/apidocs"
- */
- private String tapestryJavadoc;
-
- @Override
- protected String getOutputDirectory()
- {
- return outputDirectory;
- }
-
- @Override
- protected MavenProject getProject()
- {
- return project;
- }
-
- @Override
- protected Renderer getSiteRenderer()
- {
- return siteRenderer;
- }
-
- public String getDescription(Locale locale)
- {
- return "Tapestry component parameter reference documentation";
- }
-
- public String getName(Locale locale)
- {
- return "Component Reference";
- }
-
-
- public String getOutputName()
- {
- return REFERENCE_DIR + "/index";
- }
-
-
- private final static Set<String> SUPPORTED_SUBPACKAGES = CollectionFactory.newSet("base", "components", "mixins",
- "pages");
-
- /**
- * Generates the report; this consist of the index page
- *
- * @param locale
- * @throws MavenReportException
- */
- @Override
- protected void executeReport(Locale locale) throws MavenReportException
- {
- Map<String, ClassDescription> descriptions = runJavadoc();
-
- getLog().info("Generating reference pages ...");
-
- try
- {
- File refDir = new File(generatedDocsDirectory, REFERENCE_DIR);
-
- refDir.mkdirs();
-
-
- List<File> docSearchPath = createDocSearchPath();
-
- Sink sink = getSink();
-
- sink.head();
- sink.title();
- sink.text("Component Reference");
- sink.title_();
- sink.head_();
-
- String currentSubpackage = null;
-
- for (String rootPackage: rootPackages)
- {
- sink.section1();
- sink.sectionTitle1();
- sink.text("Component Reference: "+rootPackage);
- sink.sectionTitle1_();
-
-
- for (String className : InternalUtils.sortedKeys(descriptions))
- {
- ClassDescription classDescription = descriptions.get(className);
-
- String subpackage = extractSubpackage(className, rootPackage);
-
- if (!SUPPORTED_SUBPACKAGES.contains(subpackage)) continue;
-
-
- if (!subpackage.equals(currentSubpackage))
- {
- if (currentSubpackage != null)
- {
- sink.list_();
- sink.section2_();
- }
-
- sink.section2();
- sink.sectionTitle2();
- sink.text(StringUtils.capitalize(subpackage));
- sink.sectionTitle2_();
-
-
- sink.list();
-
- currentSubpackage = subpackage;
- }
-
-
- sink.listItem();
-
- if(classDescription.isDeprecated())
- {
- sink.rawText("<del>");
- }
-
- sink.link(toHtml(toPath(className)));
-
- sink.text(className);
- sink.link_();
-
- if(classDescription.isDeprecated())
- {
- sink.rawText("</del>");
- }
-
- writeClassDescription(descriptions, refDir, docSearchPath, className);
-
-
- sink.listItem_();
- }
-
- if (currentSubpackage != null)
- {
- sink.list_();
- sink.section2_();
- currentSubpackage = null;
- }
- }
- }
- catch (Exception ex)
- {
- throw new MavenReportException(ex.getMessage(), ex);
- }
- }
-
- private String toPath(String className)
- {
- return className.replace('.', '/');
- }
-
- private String toHtml(String filename)
- {
- int pos = filename.lastIndexOf("#");
- if (pos < 0)
- return filename + ".html";
- else
- {
- return filename.substring(0, pos) + ".html" + filename.substring(pos);
- }
- }
-
- private String extractSimpleName(String className)
- {
- int dotx = className.lastIndexOf(".");
-
- return className.substring(dotx + 1);
- }
-
- private String extractSubpackage(String className, String rootPackage)
- {
- if(className.startsWith(rootPackage))
- {
- int dotx = className.indexOf(".", rootPackage.length() + 1);
-
- // For classes directly in the root package.
-
- if (dotx < 1) return "";
-
- return className.substring(rootPackage.length() + 1, dotx);
- }
-
- return "";
- }
-
- protected List<File> createDocSearchPath()
- {
- List<File> result = CollectionFactory.newList();
-
- for (String sourceRoot : (List<String>) project.getCompileSourceRoots())
- {
- result.add(new File(sourceRoot));
- }
-
-
- for (Resource r : (List<Resource>) project.getResources())
- {
- String dir = r.getDirectory();
-
- result.add(new File(dir));
- }
-
- return result;
- }
-
- private void writeClassDescription(Map<String, ClassDescription> descriptions, File refDir,
- List<File> docSearchPath, String className) throws Exception
- {
-
- int dotx = className.lastIndexOf('.');
- String packageName = className.substring(0, dotx);
- File outputDir = new File(refDir, toPath(packageName));
- outputDir.mkdirs();
-
- File outputFile = new File(refDir, toPath(className) + ".xml");
-
-
- Element root = new Element("document");
-
- ClassDescription cd = descriptions.get(className);
-
- Map<String, ParameterDescription> parameters = CollectionFactory.newMap(cd.getParameters());
- List<String> parents = CollectionFactory.newList();
-
- String current = cd.getSuperClassName();
-
- Map<String, String> events = CollectionFactory.newCaseInsensitiveMap(cd.getEvents());
-
- while (true)
- {
- ClassDescription superDescription = descriptions.get(current);
-
- if (superDescription == null) break;
-
- parents.add(current);
- parameters.putAll(superDescription.getParameters());
- events.putAll(superDescription.getEvents());
-
- current = superDescription.getSuperClassName();
- }
-
- // Now, mix in the published parameters.
-
- for (Map.Entry<String, String> entry : cd.getPublishedParameters().entrySet())
- {
- String name = entry.getKey();
- String embeddedClassName = entry.getValue();
-
- // TODO: Don't handle the case where the @Component.type attribute was used!
-
- ParameterDescription pd = locatePublishedParameterDescription(name, embeddedClassName, descriptions);
-
- parameters.put(name, pd);
- }
-
-
- Collections.reverse(parents);
-
- // XOM is pretty verbose; it really needs a builder/fluent interface.
-
- Element properties = addChild(root, "properties");
- addChild(properties, "title", String.format("Component Reference: %s", className));
-
- Element body = new Element("body");
- root.appendChild(body);
-
-
- Element section = null;
-
- if(cd.isDeprecated())
- {
- section = addChild(body, "section");
- addChild(addChild(section, "h2"), "del", className);
- }
- else
- {
- section = addSection(body, className);
- }
-
-
- StringBuilder javadocURL = new StringBuilder(200);
-
- int depth = packageName.split("\\.").length;
-
-
- for (int i = 0; i < depth; i++)
- {
- javadocURL.append("../");
- }
-
- String pathToRefRoot = javadocURL.toString();
-
- javadocURL.append("../");
-
- String javadocHref = tapestryJavadoc.contains("://") ?
- tapestryJavadoc : javadocURL.toString() + tapestryJavadoc;
-
- javadocURL.append(apidocs).append("/").append(toHtml(toPath(className)));
-
- addChildWithJavadocs(section, "p", cd.getDescription(), javadocHref);
-
- addLink(addChild(section, "p"), javadocURL.toString(), "[JavaDoc]");
-
- if (!parents.isEmpty())
- {
- section = addSection(body, "Component Inheritance");
- Element container = section;
-
- for (String name : parents)
- {
-
- Element ul = addChild(container, "ul");
-
- Element li = addChild(ul, "li");
-
- addLink(li, toHtml(name), name);
-
- container = li;
- }
-
- addChild(addChild(container, "ul"), "li", className);
- }
-
- if (!"".equals(cd.getSince()))
- {
- section = addSection(body, "Available since");
-
- addChild(section, "p", cd.getSince());
- }
-
-
- if (!parameters.isEmpty())
- {
- section = addSection(body, "Component Parameters");
-
- Element table = new Element("table");
-
- section.appendChild(table);
-
- Element headerRow = new Element("tr");
- table.appendChild(headerRow);
-
- for (String header : PARAMETER_HEADERS)
- addChild(headerRow, "th", header);
-
- List<String> flags = CollectionFactory.newList();
-
- for (String name : InternalUtils.sortedKeys(parameters))
- {
- ParameterDescription pd = parameters.get(name);
-
- flags.clear();
-
- if (pd.getRequired()) flags.add("Required");
-
- if (!pd.getCache()) flags.add("NOT Cached");
-
- if (!pd.getAllowNull()) flags.add("NOT Allow Null");
-
- Element row = new Element("tr");
- table.appendChild(row);
-
- Element nameTd = addChild(row, "td");
- if(pd.isDeprecated())
- {
- addChild(nameTd, "del", pd.getName());
- }
- else
- {
- nameTd.appendChild(pd.getName());
- }
- addChildWithJavadocs(row, "td", pd.getType(), javadocHref);
- addChild(row, "td", InternalUtils.join(flags));
- addChild(row, "td", pd.getDefaultValue());
- addChild(row, "td", pd.getDefaultPrefix());
- addChild(row, "td", pd.getSince());
- addChildWithJavadocs(row, "td", pd.getDescription(), javadocHref);
- }
- }
-
- if (cd.isSupportsInformalParameters())
- addChild(section, "p", "Informal parameters: supported");
-
-
- if (!events.isEmpty())
- {
- section = addSection(body, "Component Events");
-
- Element ul = addChild(section, "ul");
-
- for (String name : InternalUtils.sortedKeys(events))
- {
- String value = events.get(name);
-
- String text = value.length() > 0 ? name + ": " + value : name;
-
- addChild(ul, "li", text);
- }
- }
-
- addExternalDocumentation(body, docSearchPath, className);
-
- addChild(body, "hr");
-
- addLink(addChild(body, "p"), pathToRefRoot + "index.html", "Back to index");
-
- Document document = new Document(root);
-
-
- getLog().info(String.format("Writing %s", outputFile));
-
- FileOutputStream fos = new FileOutputStream(outputFile);
-
- BufferedOutputStream bos = new BufferedOutputStream(fos);
-
- PrintWriter writer = new PrintWriter(bos);
-
- writer.print(document.toXML());
-
- writer.close();
- }
-
- private ParameterDescription locatePublishedParameterDescription(String name, String componentClassName,
- Map<String, ClassDescription> descriptions)
- {
- String current = componentClassName;
-
- while (current != null)
- {
- ClassDescription cd = descriptions.get(componentClassName);
-
- if (cd == null) break;
-
- String indirectClassName = cd.getPublishedParameters().get(name);
-
- if (indirectClassName != null)
- {
- current = indirectClassName;
- continue;
- }
-
- ParameterDescription pd = cd.getParameters().get(name);
-
- if (pd != null) return pd;
-
- current = cd.getSuperClassName();
- }
-
- throw new IllegalArgumentException(
- String.format("Published parameter '%s' (from embedded component class %s) does not exist.",
- name, componentClassName));
- }
-
- private void addExternalDocumentation(Element body, List<File> docSearchPath, String className)
- throws ParsingException, IOException
- {
- String classNamePath = toPath(className);
-
- String pathExtension = classNamePath + ".xdoc";
-
- for (File path : docSearchPath)
- {
- File file = new File(path, pathExtension);
-
- getLog().debug(String.format("Checking for %s", file));
-
- if (!file.exists()) continue;
-
- getLog().info(String.format("Reading extra documentation from %s", file));
-
- Builder builder = new Builder();
-
- Document doc = builder.build(file);
-
- // Transfer the nodes inside document/body into our body
-
- Element incomingBody = doc.getRootElement().getFirstChildElement("body");
-
- for (int i = 0; i < incomingBody.getChildCount(); i++)
- {
- Node incoming = incomingBody.getChild(i).copy();
-
- body.appendChild(incoming);
- }
-
- Nodes nodes = doc.query("//img/@src");
-
- int lastslashx = classNamePath.lastIndexOf('/');
- String packagePath = classNamePath.substring(0, lastslashx);
-
- File generatedRefRoot = new File(generatedResourcesDirectory, REFERENCE_DIR);
- File generatedPackageRoot = new File(generatedRefRoot, packagePath);
-
- for (int i = 0; i < nodes.size(); i++)
- {
- Node src = nodes.get(i);
-
- String srcPath = src.getValue();
-
- File imgFile = new File(path, packagePath + "/" + srcPath);
- File imgTargetFile = new File(generatedPackageRoot, srcPath);
-
- copy(imgFile, imgTargetFile);
- }
-
-
- return;
- }
- }
-
- private void copy(File sourceFile, File targetFile) throws IOException
- {
- getLog().info(String.format("Copying image file %s to %s", sourceFile, targetFile));
-
- targetFile.getParentFile().mkdirs();
-
- byte[] buffer = new byte[20000];
-
- InputStream in = new BufferedInputStream(new FileInputStream(sourceFile));
- OutputStream out = new BufferedOutputStream(new FileOutputStream(targetFile));
-
- while (true)
- {
- int length = in.read(buffer);
-
- if (length < 0) break;
-
- out.write(buffer, 0, length);
- }
-
- in.close();
- out.close();
- }
-
-
- protected Map<String, ClassDescription> runJavadoc() throws MavenReportException
- {
- getLog().info("Running JavaDoc to collect component parameter data ...");
-
- Commandline command = new Commandline();
-
- try
- {
- command.setExecutable(pathToJavadoc());
- }
- catch (IOException ex)
- {
- throw new MavenReportException("Unable to locate javadoc command: " + ex.getMessage(), ex);
- }
-
- String parametersPath = workDirectory + File.separator + "component-parameters.xml";
-
- String[] arguments = { "-private", "-o", parametersPath,
-
- "-subpackages", InternalUtils.join(rootPackages, ":"),
-
- "-doclet", ParametersDoclet.class.getName(),
-
- "-docletpath", docletPath(),
-
- "-sourcepath", sourcePath(),
-
- "-classpath", classPath() };
-
- String argumentsFile = writeArgumentsFile(arguments);
-
- command.addArguments(new String[] { "@" + argumentsFile });
-
- executeCommand(command);
-
- return readXML(parametersPath);
- }
-
- private String writeArgumentsFile(String[] arguments) throws MavenReportException
- {
- String fileName = workDirectory + "/component-report-javadoc-arguments.txt";
-
- try
- {
- PrintWriter pw = new PrintWriter(fileName);
-
- for (String arg : arguments)
- {
- pw.println(arg);
- }
-
- pw.close();
- }
- catch (IOException ex)
- {
- throw new MavenReportException(ex.getMessage());
- }
-
- return fileName;
- }
-
- @SuppressWarnings("unchecked")
- private String sourcePath()
- {
- List<String> roots = project.getCompileSourceRoots();
-
- return toArgumentPath(roots);
- }
-
- /**
- * Needed to help locate this plugin's local JAR file for the -doclet argument.
- *
- * @parameter default-value="${localRepository}"
- * @read-only
- */
- private ArtifactRepository localRepository;
-
- /**
- * Needed to help locate this plugin's local JAR file for the -doclet argument.
- *
- * @parameter default-value="${plugin.groupId}"
- * @read-only
- */
- private String pluginGroupId;
-
- /**
- * Needed to help locate this plugin's local JAR file for the -doclet argument.
- *
- * @parameter default-value="${plugin.artifactId}"
- * @read-only
- */
- private String pluginArtifactId;
-
- /**
- * Needed to help locate this plugin's local JAR file for the -doclet argument.
- *
- * @parameter default-value="${plugin.version}"
- * @read-only
- */
- private String pluginVersion;
-
- @SuppressWarnings("unchecked")
- private String docletPath() throws MavenReportException
- {
- File file = new File(localRepository.getBasedir());
-
- for (String term : pluginGroupId.split("\\."))
- file = new File(file, term);
-
- file = new File(file, pluginArtifactId);
- file = new File(file, pluginVersion);
-
- file = new File(file, String.format("%s-%s.jar", pluginArtifactId, pluginVersion));
-
- return toArgumentPath(Arrays.asList(file.getAbsolutePath()));
- }
-
- @SuppressWarnings("unchecked")
- private String classPath() throws MavenReportException
- {
- List<Artifact> artifacts = project.getCompileArtifacts();
-
- return artifactsToArgumentPath(artifacts);
- }
-
- private String artifactsToArgumentPath(List<Artifact> artifacts) throws MavenReportException
- {
- List<String> paths = CollectionFactory.newList();
-
- for (Artifact artifact : artifacts)
- {
- if (artifact.getScope().equals("test")) continue;
-
- File file = artifact.getFile();
-
- if (file == null) throw new MavenReportException(
- "Unable to execute Javadoc: compile dependencies are not fully resolved.");
-
- paths.add(file.getAbsolutePath());
- }
-
- return toArgumentPath(paths);
- }
-
- private void executeCommand(Commandline command) throws MavenReportException
- {
- getLog().debug(command.toString());
-
- CommandLineUtils.StringStreamConsumer err = new CommandLineUtils.StringStreamConsumer();
-
- try
- {
- int exitCode = CommandLineUtils.executeCommandLine(command, new DefaultConsumer(), err);
-
- if (exitCode != 0)
- {
- String message = String.format("Javadoc exit code: %d - %s\nCommand line was: %s", exitCode,
- err.getOutput(), command);
-
- throw new MavenReportException(message);
- }
- }
- catch (CommandLineException ex)
- {
- throw new MavenReportException("Unable to execute javadoc command: " + ex.getMessage(), ex);
- }
-
- // ----------------------------------------------------------------------
- // Handle Javadoc warnings
- // ----------------------------------------------------------------------
-
- if (StringUtils.isNotEmpty(err.getOutput()))
- {
- getLog().info("Javadoc Warnings");
-
- StringTokenizer token = new StringTokenizer(err.getOutput(), "\n");
- while (token.hasMoreTokens())
- {
- String current = token.nextToken().trim();
-
- getLog().warn(current);
- }
- }
- }
-
- private String pathToJavadoc() throws IOException, MavenReportException
- {
- String executableName = SystemUtils.IS_OS_WINDOWS ? "javadoc.exe" : "javadoc";
-
- File executable = initialGuessAtJavadocFile(executableName);
-
- if (!executable.exists() || !executable.isFile())
- throw new MavenReportException(String.format("Path %s does not exist or is not a file.", executable));
-
- return executable.getAbsolutePath();
- }
-
- private File initialGuessAtJavadocFile(String executableName)
- {
- if (SystemUtils.IS_OS_MAC_OSX)
- return new File(SystemUtils.getJavaHome() + File.separator + "bin", executableName);
-
- return new File(SystemUtils.getJavaHome() + File.separator + ".." + File.separator + "bin", executableName);
- }
-
- private String toArgumentPath(List<String> paths)
- {
- StringBuilder builder = new StringBuilder(5000).append(QUOTE);
-
- String sep = "";
-
- for (String path : paths)
- {
- builder.append(sep);
- builder.append(StringEscapeUtils.escapeJava(path));
-
- sep = SystemUtils.PATH_SEPARATOR;
- }
-
- return builder.append(QUOTE).toString();
- }
-
- public Map<String, ClassDescription> readXML(String path) throws MavenReportException
- {
- try
- {
- Builder builder = new Builder(false);
-
- File input = new File(path);
-
- Document doc = builder.build(input);
-
- return buildMapFromDocument(doc);
- }
- catch (Exception ex)
- {
- throw new MavenReportException(String.format("Failure reading from %s: %s", path, ex
- .getMessage()), ex);
- }
- }
-
- private Map<String, ClassDescription> buildMapFromDocument(Document doc)
- {
- Map<String, ClassDescription> result = CollectionFactory.newMap();
-
- Elements elements = doc.getRootElement().getChildElements("class");
-
- for (int i = 0; i < elements.size(); i++)
- {
- Element element = elements.get(i);
-
- String description = element.getFirstChildElement("description").getValue();
-
- String className = element.getAttributeValue("name");
- String superClassName = element.getAttributeValue("super-class");
- String supportsInformalParameters = element.getAttributeValue("supports-informal-parameters");
- String since = element.getAttributeValue("since");
- String deprecated = element.getAttributeValue("deprecated");
-
- ClassDescription cd = new ClassDescription(className, superClassName, description,
- Boolean.valueOf(supportsInformalParameters), since,
- Boolean.valueOf(deprecated));
-
- result.put(className, cd);
-
- readParameters(cd, element);
- readPublishedParameters(cd, element);
- readEvents(cd, element);
- }
-
- return result;
- }
-
- private void readEvents(ClassDescription cd, Element classElement)
- {
- Elements elements = classElement.getChildElements("event");
-
- for (int i = 0; i < elements.size(); i++)
- {
- Element node = elements.get(i);
-
- String name = node.getAttributeValue("name");
- String description = node.getValue();
-
- cd.getEvents().put(name, description);
- }
- }
-
- private void readParameters(ClassDescription cd, Element classElement)
- {
- Elements elements = classElement.getChildElements("parameter");
-
- for (int i = 0; i < elements.size(); i++)
- {
- Element node = elements.get(i);
-
- String name = node.getAttributeValue("name");
- String type = node.getAttributeValue("type");
-
- int dotx = type.lastIndexOf('.');
- if (dotx > 0 && type.substring(0, dotx).equals("java.lang")) type = type.substring(dotx + 1);
-
- String defaultValue = node.getAttributeValue("default");
- boolean required = Boolean.parseBoolean(node.getAttributeValue("required"));
- boolean cache = Boolean.parseBoolean(node.getAttributeValue("cache"));
- boolean allowNull = Boolean.parseBoolean(node.getAttributeValue("allowNull"));
- String defaultPrefix = node.getAttributeValue("default-prefix");
- String description = node.getValue();
- String since = node.getAttributeValue("since");
- String deprecated = node.getAttributeValue("deprecated");
-
- ParameterDescription pd = new ParameterDescription(name, type, defaultValue, defaultPrefix, required,
- allowNull, cache, description, since, Boolean.valueOf(deprecated));
-
- cd.getParameters().put(name, pd);
- }
- }
-
- private void readPublishedParameters(ClassDescription cd, Element classElement)
- {
- Elements elements = classElement.getChildElements("published-parameter");
-
- for (int i = 0; i < elements.size(); i++)
- {
- Element element = elements.get(i);
-
- Attribute name = element.getAttribute("name");
- Attribute embeddedTypeName = element.getAttribute("component-class");
-
- cd.getPublishedParameters().put(name.getValue(), embeddedTypeName.getValue());
- }
-
- }
-
- private Element addSection(Element container, String name)
- {
- Element section = new Element("section");
- container.appendChild(section);
-
- section.addAttribute(new Attribute("name", name));
-
- return section;
- }
-
- private Element addLink(Element container, String URL, String text)
- {
- Element link = addChild(container, "a", text);
-
- link.addAttribute(new Attribute("href", URL));
-
- return link;
- }
-
- private Element addChild(Element container, String elementName)
- {
- Element child = new Element(elementName);
- container.appendChild(child);
-
- return child;
- }
-
- private Element addChild(Element container, String elementName, String text)
- {
- Element child = new Element(elementName);
- container.appendChild(child);
-
- child.appendChild(text);
-
- return child;
- }
-
- private Element addChildWithJavadocs(Element container, String elementName, String text, String javadocHref)
- {
- final String[] parts = splitWithGroup(TAPESTRY5_PATTERN, text);
- if (parts.length <= 1)
- {
- return addChild(container, elementName, text);
- }
-
- final Element element = addChild(container, elementName);
-
- for (int i = 0; i < parts.length; i++)
- {
- String part = parts[i];
- element.appendChild(part);
- i++;
- if (i < parts.length)
- {
- part = parts[i];
- if (part.endsWith("."))
- {
- part = part.substring(0, part.length() - 1);
- addLink(element, javadocHref + "/" + toHtml(toPath(part)), extractSimpleName(part));
- element.appendChild(".");
- }
- else
- {
- addLink(element, javadocHref + "/" + toHtml(toPath(part)), extractSimpleName(part));
- }
- }
- }
- return element;
- }
-
- /**
- * Splits a {@link CharSequence} using the given pattern while including after each part the matched group.<p/>
- * Mostly copied from {@link Pattern#split(CharSequence)}.
- */
- private String[] splitWithGroup(Pattern pattern, CharSequence input)
- {
- int index = 0;
- List<String> matchList = CollectionFactory.newList();
- Matcher m = pattern.matcher(input);
-
- // Add segments before each match found
- while (m.find())
- {
- String match = input.subSequence(index, m.start()).toString();
- String group = input.subSequence(m.start(), m.end()).toString();
- matchList.add(match);
- matchList.add(group);
- index = m.end();
- }
-
- // If no match was found, return this
- if (index == 0)
- return new String[] { input.toString() };
-
- // Add remaining segment
- matchList.add(input.subSequence(index, input.length()).toString());
-
- // Construct result
- int resultSize = matchList.size();
- while (resultSize > 0 && matchList.get(resultSize - 1).equals(""))
- resultSize--;
- String[] result = new String[resultSize];
- return matchList.subList(0, resultSize).toArray(result);
- }
-}
View
103 tapestry-component-report/src/main/java/org/apache/tapestry/mojo/ParameterDescription.java
@@ -1,103 +0,0 @@
-// Copyright 2007, 2008 The Apache Software Foundation
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package org.apache.tapestry.mojo;
-
-public class ParameterDescription
-{
- private final String name;
-
- private final String type;
-
- private final String defaultValue;
-
- private final String defaultPrefix;
-
- private final boolean required;
-
- private final boolean allowNull;
-
- private final boolean cache;
-
- private final String description;
-
- private final String since;
-
- private final boolean deprecated;
-
- public ParameterDescription(String name, String type, String defaultValue,
- String defaultPrefix, boolean required, boolean allowNull, boolean cache,
- String description, String since, boolean deprecated)
- {
- this.name = name;
- this.type = type;
- this.defaultValue = defaultValue;
- this.defaultPrefix = defaultPrefix;
- this.required = required;
- this.allowNull = allowNull;
- this.cache = cache;
- this.description = description;
- this.since = since;
- this.deprecated = deprecated;
- }
-
- public boolean getCache()
- {
- return cache;
- }
-
- public String getDefaultPrefix()
- {
- return defaultPrefix;
- }
-
- public String getDefaultValue()
- {
- return defaultValue;
- }
-
- public String getDescription()
- {
- return description;
- }
-
- public String getName()
- {
- return name;
- }
-
- public boolean getRequired()
- {
- return required;
- }
-
- public String getType()
- {
- return type;
- }
-
- public boolean getAllowNull()
- {
- return allowNull;
- }
-
- public String getSince()
- {
- return since;
- }
-
- public boolean isDeprecated() {
- return deprecated;
- }
-}
View
354 tapestry-component-report/src/main/java/org/apache/tapestry/mojo/ParametersDoclet.java
@@ -1,354 +0,0 @@
-// Copyright 2007, 2008, 2009 The Apache Software Foundation
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package org.apache.tapestry.mojo;
-
-import com.sun.javadoc.*;
-import com.sun.javadoc.AnnotationDesc.ElementValuePair;
-
-import java.io.File;
-import java.io.PrintWriter;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.regex.Pattern;
-
-/**
- * Generates an XML file that identifies all the classes that contain parameters, and all the parameters within each
- * component class. This XML is later converted into part of the Maven generated HTML site.
- * <p/>
- * To keep the -doclet parameter passed to javadoc simple, this class should not have any outside dependencies.
- */
-public class ParametersDoclet extends Doclet
-{
- static String OUTPUT_PATH_OPTION = "-o";
-
- static String outputPath;
-
- static class Worker
- {
- private PrintWriter out;
-
- private final Pattern stripper = Pattern.compile("(<.*?>|&.*?;)", Pattern.DOTALL);
-
- public void run(String outputPath, RootDoc root) throws Exception
- {
- File output = new File(outputPath);
-
- out = new PrintWriter(output);
-
- println("<component-parameters>");
-
- for (ClassDoc cd : root.classes())
- emitClass(cd);
-
- println("</component-parameters>");
-
- out.close();
- }
-
- private void emitClass(ClassDoc classDoc)
- {
- if (!classDoc.isPublic())
- return;
-
- // Components must be root classes, not nested classes.
- if (classDoc.containingClass() != null)
- return;
-
- // Check for a no-args public constructor
-
- boolean found = false;
-
- for (ConstructorDoc cons : classDoc.constructors())
- {
- if (cons.isPublic() && cons.parameters().length == 0)
- {
- found = true;
- break;
- }
- }
-
- if (!found)
- return;
-
- Map<String, String> annotationValues = findTapestryAnnotation(classDoc, "SupportsInformalParameters");
-
- boolean deprecated = isDeprecated(classDoc);
-
- println("<class name='%s' super-class='%s' supports-informal-parameters='%s' since='%s' deprecated='%s'>",
- classDoc.qualifiedTypeName(), classDoc.superclass().qualifiedTypeName(), annotationValues != null,
- getSinceTagValue(classDoc), deprecated);
- print("<description>");
- printDescription(classDoc);
- println("</description>", classDoc.commentText());
-
- for (FieldDoc fd : classDoc.fields())
- {
- if (fd.isStatic())
- continue;
-
- if (!fd.isPrivate())
- continue;
-
- Map<String, String> parameterAnnotationsValues = findTapestryAnnotation(fd, "Parameter");
-
- if (parameterAnnotationsValues != null)
- {
- emitParameter(fd, parameterAnnotationsValues);
-
- continue;
- }
-
- Map<String, String> componentAnnotationValues = findTapestryAnnotation(fd, "Component");
-
- if (componentAnnotationValues != null)
- {
- emitPublishedParameters(fd, componentAnnotationValues);
-
- continue;
- }
-
- }
-
- emitEvents(classDoc);
-
- println("</class>");
- }
-
- private boolean isDeprecated(ProgramElementDoc classDoc)
- {
- return (findAnnotation(classDoc, "java.lang.Deprecated") != null)
- || (0 < classDoc.tags("deprecated").length);
- }
-
- private void emitEvents(ClassDoc classDoc)
- {
- for (AnnotationDesc annotation : classDoc.annotations())
- {
- if (!annotation.annotationType().qualifiedTypeName().equals("org.apache.tapestry5.annotations.Events"))
- {
- continue;
- }
-
- // Events has only a single attribute: value(), so we know its the first element
- // in the array.
-
- ElementValuePair pair = annotation.elementValues()[0];
-
- AnnotationValue annotationValue = pair.value();
- AnnotationValue[] values = (AnnotationValue[]) annotationValue.value();
-
- for (AnnotationValue eventValue : values)
- {
- String event = (String) eventValue.value();
- int ws = event.indexOf(' ');
-
- String name = ws < 0 ? event : event.substring(0, ws);
- String description = ws < 0 ? "" : event.substring(ws + 1).trim();
-
- print("<event name='%s'>%s</event>", name, description);
- }
- break;
- }
- }
-
- private void emitPublishedParameters(FieldDoc fd, Map<String, String> componentAnnotationValues)
- {
- String names = get(componentAnnotationValues, "publishParameters", "");
-
- if (names == null || names.equals(""))
- return;
-
- String embeddedTypeName = fd.type().qualifiedTypeName();
-
- for (String name : names.split("\\s*,\\s*"))
- {
- print("<published-parameter name='%s' component-class='%s'/>", name, embeddedTypeName);
- }
- }
-
- private void emitParameter(FieldDoc fd, Map<String, String> parameterAnnotationValues)
- {
- String name = parameterAnnotationValues.get("name");
- if (name == null)
- name = fd.name().replaceAll("^[$_]*", "");
-
- print("<parameter name='%s' type='%s' default='%s' required='%s' cache='%s' "
- + "default-prefix='%s' since='%s' deprecated='%s'>", name, fd.type().qualifiedTypeName(),
- get(parameterAnnotationValues, "value", ""), get(parameterAnnotationValues, "required", "false"),
- get(parameterAnnotationValues, "cache", "true"),
- get(parameterAnnotationValues, "defaultPrefix", "prop"), getSinceTagValue(fd), isDeprecated(fd));
-
- // Body of a parameter is the comment text.
-
- printDescription(fd);
-
- println("\n</parameter>");
- }
-
- private String getSinceTagValue(Doc doc)
- {
- return getTagValue(doc, "since");
- }
-
- private String getTagValue(Doc doc, String tagName)
- {
- Tag[] tags = doc.tags(tagName);
-
- return 0 < tags.length ? tags[0].text() : "";
- }
-
- private String get(Map<String, String> map, String key, String defaultValue)
- {
- if (map.containsKey(key))
- return map.get(key);
-
- return defaultValue;
- }
-
- private Map<String, String> findTapestryAnnotation(ProgramElementDoc doc, String name)
- {
- return findAnnotation(doc, "org.apache.tapestry5.annotations." + name);
- }
-
- private Map<String, String> findAnnotation(ProgramElementDoc doc, String name)
- {
- for (AnnotationDesc annotation : doc.annotations())
- {
- if (annotation.annotationType().qualifiedTypeName().equals(name))
- {
- Map<String, String> result = new HashMap<String, String>();
-
- for (ElementValuePair pair : annotation.elementValues())
- result.put(pair.element().name(), pair.value().value().toString());
-
- return result;
- }
- }
-
- return null;
- }
-
- private void print(String format, Object... arguments)
- {
- String line = String.format(format, arguments);
-
- out.print(line);
- }
-
- private void println(String format, Object... arguments)
- {
- print(format, arguments);
-
- out.println();
- }
-
- private void printDescription(Doc holder)
- {
- StringBuilder builder = new StringBuilder();
-
- for (Tag tag : holder.inlineTags())
- {
- if (tag.name().equals("Text"))
- {
- builder.append(tag.text());
- continue;
- }
-
- if (tag.name().equals("@link"))
- {
- SeeTag seeTag = (SeeTag) tag;
-
- String label = seeTag.label();
- if (label != null && !label.equals(""))
- {
- builder.append(label);
- continue;
- }
-
- if (seeTag.referencedClassName() != null)
- builder.append(seeTag.referencedClassName());
-
- if (seeTag.referencedMemberName() != null)
- {
- builder.append("#");
- builder.append(seeTag.referencedMemberName());
- }
- }
- }
-
- String text = builder.toString();
-
- // Fix it up a little.
-
- // Remove any simple open or close tags found in the text, as well as any XML entities.
-
- String stripped = stripper.matcher(text).replaceAll("");
-
- out.print(stripped);
- }
- }
-
- /**
- * Yes we are interested in annotations, etc.
- */
- public static LanguageVersion languageVersion()
- {
- return LanguageVersion.JAVA_1_5;
- }
-
- public static int optionLength(String option)
- {
- if (option.equals(OUTPUT_PATH_OPTION))
- return 2;
-
- return 0;
- }
-
- public static boolean validOptions(String options[][], DocErrorReporter reporter)
- {
- for (String[] group : options)
- {
- if (group[0].equals(OUTPUT_PATH_OPTION))
- outputPath = group[1];
-
- // Do we need to check for other unexpected options?
- // TODO: Check for duplicate -o?
- }
-
- if (outputPath == null)
- reporter.printError(String.format("Usage: javadoc %s path", OUTPUT_PATH_OPTION));
-
- return true;
- }
-
- public static boolean start(RootDoc root)
- {
- // Enough of this static method bullshit. What the fuck were they thinking?
-
- try
- {
- new Worker().run(outputPath, root);
- }
- catch (Exception ex)
- {
- root.printError(ex.getMessage());
-
- return false;
- }
-
- return true;
- }
-
-}
View
24 tapestry-component-report/src/test/conf/testng.xml
@@ -1,24 +0,0 @@
-<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
-<!--
- Copyright 2008 The Apache Software Foundation
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-
-<suite name="Tapestry Component Report" annotations="1.5" verbose="10">
- <test name="Internals">
- <packages>
- <package name="org.apache.tapestry.mojo"/>
- </packages>
- </test>
-</suite>
View
200 tapestry-component-report/src/test/java/org/apache/tapestry/mojo/ComponentReportTest.java
@@ -1,200 +0,0 @@
-// Copyright 2008, 2009 The Apache Software Foundation
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package org.apache.tapestry.mojo;
-
-import org.apache.maven.doxia.module.xhtml.XhtmlSink;
-import org.apache.maven.doxia.module.xhtml.decoration.render.RenderingContext;
-import org.apache.maven.model.Model;
-import org.apache.maven.plugin.MojoExecutionException;
-import org.apache.maven.project.MavenProject;
-import org.apache.maven.reporting.MavenReportException;
-import static org.apache.tapestry5.ioc.internal.util.CollectionFactory.newList;
-import static org.apache.tapestry5.ioc.internal.util.CollectionFactory.newMap;
-import org.codehaus.plexus.util.FileUtils;
-import org.testng.Assert;
-import org.testng.annotations.DataProvider;
-import org.testng.annotations.Test;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.StringWriter;
-import java.lang.reflect.Field;
-import java.util.Arrays;
-import java.util.List;
-import java.util.Locale;
-import java.util.Map;
-
-/**
- * Tests {@link ComponentReport}.
- */
-public class ComponentReportTest extends Assert
-{
- @Test(dataProvider = "docData")
- public void doc_generation(final Map<String, ClassDescription> javadocResults, String createdFile,
- String tapestryDoc, String[] expectedSummaryParts, String[] expectedFileParts)
- throws MojoExecutionException, IOException, MavenReportException
- {
- String tempDir = System.getProperty("java.io.tmpdir");
- final File tempFolder = new File(tempDir, "t5_tests");
- tempFolder.mkdir();
-
- ComponentReport report = new ComponentReport()
- {
- @Override
- protected String getOutputDirectory()
- {
- return tempFolder.toString();
- }
-
- @Override
- protected MavenProject getProject()
- {
- return new MavenProject(new Model());
- }
-
- @Override
- protected Map<String, ClassDescription> runJavadoc() throws MavenReportException
- {
- return javadocResults;
- }
-
- @Override
- protected List<File> createDocSearchPath()
- {
- return newList();
- }
- };
-
- try
- {
- initializeMojo(report, ComponentReport.class,
- "rootPackages", Arrays.asList("org.apache.tapestry5.corelib"),
- "apidocs", "apidocs",
- "tapestryJavadoc", tapestryDoc,
- "generatedDocsDirectory", tempFolder
- );
- }
- catch (NoSuchFieldException e)
- {
- fail("Cannot initialize mojo");
- }
- catch (IllegalAccessException e)
- {
- fail("Cannot initialize mojo");
- }
-
- // generate report twice - helps uncover mojos that change their state during runs
- // which is bad practice since properties aren't reinitialized on subsequent mojo invocations
- generate(report, tempFolder);
- StringWriter writer = generate(report, tempFolder);
-
- String summaryOutput = writer.toString();
- for (String summaryPart : expectedSummaryParts)
- {
- assertTrue(summaryOutput.contains(summaryPart));
- }
-
- File formReport = new File(tempFolder, createdFile);
- String formOutput = FileUtils.fileRead(formReport);
-
- for (String filePart : expectedFileParts)
- {
- assertTrue(formOutput.contains(filePart), "Output:\n" + formOutput + "\nshould contain:\n" + filePart);
- }
-
- FileUtils.forceDeleteOnExit(tempFolder);
- }
-
- private StringWriter generate(ComponentReport report, File tempFolder)
- throws MavenReportException
- {
- StringWriter writer = new StringWriter();
-
- RenderingContext context = new RenderingContext(tempFolder, "test.html");
- XhtmlSink sink = new XhtmlSink(writer, context, newMap());
-
- report.generate(new DoxiaXhtmlSinkDecorator(sink), Locale.US);
-
- return writer;
- }
-
- private void initializeMojo(Object mojo, Class clazz, Object... propertyValues)
- throws NoSuchFieldException, IllegalAccessException
- {
- for (int i = 0; i < propertyValues.length; i++)
- {
- String property = (String) propertyValues[i++];
- Object value = propertyValues[i];
-
- Field field = clazz.getDeclaredField(property);
- field.setAccessible(true);
-
- field.set(mojo, value);
- }
- }
-
- @DataProvider
- private Object[][] docData()
- {
- return new Object[][] {
- {
- javadocDescriptionForForm(),
- "ref/org/apache/tapestry5/corelib/components/Form.xml",
- "http://tapestry.apache.org/tapestry5/apidocs",
- new String[] { "org.apache.tapestry5.corelib.components.Form" },
- new String[] {
- "<title>Component Reference: org.apache.tapestry5.corelib.components.Form</title>",
- "<a href=\"http://tapestry.apache.org/tapestry5/apidocs/org/apache/tapestry5/EventConstants.html#PREPARE\">" }
- },
- {
- javadocDescriptionForForm(),
- "ref/org/apache/tapestry5/corelib/components/Form.xml",
- "../apidocs",
- new String[] { "org.apache.tapestry5.corelib.components.Form" },
- new String[] {
- "<title>Component Reference: org.apache.tapestry5.corelib.components.Form</title>",
- "<a href=\"../../../../../../../apidocs/org/apache/tapestry5/EventConstants.html#PREPARE\">" }
- },
-
- };
- }
-
- private Map<String, ClassDescription> javadocDescriptionForForm()
- {
- Map<String, ClassDescription> results = newMap();
- ClassDescription classDesc = new ClassDescription(
- "org.apache.tapestry5.corelib.components.Form",
- "java.lang.Object",
- "When it renders, it fires a org.apache.tapestry5.EventConstants#PREPARE_FOR_RENDER\n" +
- " notification, followed by a org.apache.tapestry5.EventConstants#PREPARE",
- false,
- "5.1.0.0",
- false
- );
-
- ParameterDescription paramDesc = new ParameterDescription(
- "validationId", "String", "", "prop", false, false, true,
- "Prefix value used when searching for validation messages and constraints. " +
- "The default is the Form component's\n" +
- " id. This is overriden by org.apache.tapestry5.corelib.components.BeanEditForm.",
- "5.1.0.0", false
- );
- classDesc.getParameters().put(paramDesc.getName(), paramDesc);
-
- results.put(classDesc.getClassName(), classDesc);
-
- return results;
- }
-}
View
408 ...stry-component-report/src/test/java/org/apache/tapestry/mojo/DoxiaXhtmlSinkDecorator.java
@@ -1,408 +0,0 @@
-// Copyright 2008 The Apache Software Foundation
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package org.apache.tapestry.mojo;
-
-import org.codehaus.doxia.sink.Sink;
-import org.apache.maven.doxia.module.xhtml.XhtmlSink;
-
-/**
- * Decorates an {@link XhtmlSink} so that it can be used in place of a
- * {@link Sink}.<p/>
- * Since {@link Sink} is currently deprecated, this decoratar may not be
- * needed in the future - this will happen when the signature of
- * org.apache.maven.reporting.MavenReport#generate(org.codehaus.doxia.sink.Sink, java.util.Locale)
- * (from the org.apache.maven.reporting:maven-reporting-impl artifact) changes to
- * org.apache.maven.reporting.MavenReport#generate(org.apache.maven.doxia.Sink, java.util.Locale)
- */
-public class DoxiaXhtmlSinkDecorator implements Sink {
- private XhtmlSink _xhtmlSink;
-
- public DoxiaXhtmlSinkDecorator(XhtmlSink xhtmlSink) {
- _xhtmlSink = xhtmlSink;
- }
-
- public void head() {
- _xhtmlSink.head();
- }
-
- public void head_() {
- _xhtmlSink.head_();
- }
-
- public void title() {
- _xhtmlSink.title();
- }
-
- public void title_() {
- _xhtmlSink.title_();
- }
-
- public void author_() {
- _xhtmlSink.author_();
- }
-
- public void date_() {
- _xhtmlSink.date_();
- }
-
- public void body() {
- _xhtmlSink.body();
- }
-
- public void body_() {
- _xhtmlSink.body_();
- }
-
- public void section1() {
- _xhtmlSink.section1();
- }
-
- public void section2() {
- _xhtmlSink.section2();
- }
-
- public void section3() {
- _xhtmlSink.section3();
- }
-
- public void section4() {
- _xhtmlSink.section4();
- }
-
- public void section5() {
- _xhtmlSink.section5();
- }
-
- public void section1_() {
- _xhtmlSink.section1_();
- }
-
- public void section2_() {
- _xhtmlSink.section2_();
- }
-
- public void section3_() {
- _xhtmlSink.section3_();
- }
-
- public void section4_() {
- _xhtmlSink.section4_();
- }
-
- public void section5_() {
- _xhtmlSink.section5_();
- }
-
- public void sectionTitle1() {
- _xhtmlSink.sectionTitle1();
- }
-
- public void sectionTitle1_() {
- _xhtmlSink.sectionTitle1_();
- }
-
- public void sectionTitle2() {
- _xhtmlSink.sectionTitle2();
- }
-
- public void sectionTitle2_() {
- _xhtmlSink.sectionTitle2_();
- }
-
- public void sectionTitle3() {
- _xhtmlSink.sectionTitle3();
- }
-
- public void sectionTitle3_() {
- _xhtmlSink.sectionTitle3_();
- }
-
- public void sectionTitle4() {
- _xhtmlSink.sectionTitle4();
- }
-
- public void sectionTitle4_() {
- _xhtmlSink.sectionTitle4_();
- }
-
- public void sectionTitle5() {
- _xhtmlSink.sectionTitle5();
- }
-
- public void sectionTitle5_() {
- _xhtmlSink.sectionTitle5_();
- }
-
- public void list() {
- _xhtmlSink.list();
- }
-
- public void list_() {
- _xhtmlSink.list_();
- }
-
- public void listItem() {
- _xhtmlSink.listItem();
- }
-
- public void listItem_() {
- _xhtmlSink.listItem_();
- }
-
- public void numberedList(int i) {
- _xhtmlSink.numberedList(i);
- }
-
- public void numberedList_() {
- _xhtmlSink.numberedList_();
- }
-
- public void numberedListItem() {
- _xhtmlSink.numberedListItem();
- }
-
- public void numberedListItem_() {
- _xhtmlSink.numberedListItem_();
- }
-
- public void definitionList() {
- _xhtmlSink.definitionList();
- }
-
- public void definitionList_() {
- _xhtmlSink.definitionList_();
- }
-
- public void definedTerm() {
- _xhtmlSink.definedTerm();
- }
-
- public void definedTerm_() {
- _xhtmlSink.definedTerm_();
- }
-
- public void definition() {
- _xhtmlSink.definition();
- }
-
- public void definition_() {
- _xhtmlSink.definition_();
- }
-
- public void paragraph() {
- _xhtmlSink.paragraph();
- }
-
- public void paragraph_() {
- _xhtmlSink.paragraph_();
- }
-
- public void verbatim(boolean