From fb711306baf6a94b19997c3bee86093e9e420770 Mon Sep 17 00:00:00 2001 From: Elliotte Rusty Harold Date: Tue, 23 May 2023 12:50:46 +0000 Subject: [PATCH] [JXR-178] Update parent pom to 39 (#98) * parent pom 39 * spotless format * remove extra copyright notices * still more copyright notices --- maven-jxr-plugin/pom.xml | 15 +- .../maven/plugin/jxr/AbstractJxrReport.java | 452 ++++----- .../maven/plugin/jxr/AggregatorJxrReport.java | 15 +- .../plugin/jxr/AggregatorJxrTestReport.java | 15 +- .../maven/plugin/jxr/JxrNoForkReport.java | 12 +- .../apache/maven/plugin/jxr/JxrReport.java | 91 +- .../maven/plugin/jxr/JxrReportUtil.java | 140 ++- .../maven/plugin/jxr/JxrTestNoForkReport.java | 12 +- .../maven/plugin/jxr/JxrTestReport.java | 76 +- .../maven/plugin/jxr/AbstractJxrTestCase.java | 87 +- .../jxr/DependencyArtifactStubFactory.java | 51 +- .../maven/plugin/jxr/JxrReportTest.java | 423 ++++----- .../maven/plugin/jxr/JxrTestReportTest.java | 44 +- .../AggregateSubmodule1MavenProjectStub.java | 37 +- .../AggregateSubmodule2MavenProjectStub.java | 41 +- .../stubs/AggregateTestMavenProjectStub.java | 60 +- .../jxr/stubs/DefaultArtifactHandlerStub.java | 17 +- .../DefaultConfigurationMavenProjectStub.java | 60 +- .../ExcludeConfigurationMavenProjectStub.java | 57 +- .../IncludeConfigurationMavenProjectStub.java | 58 +- .../jxr/stubs/JxrPluginArtifactStub.java | 48 +- .../plugin/jxr/stubs/JxrProjectStub.java | 22 +- .../stubs/NoJavadocDirMavenProjectStub.java | 59 +- ...adocLinkConfigurationMavenProjectStub.java | 62 +- .../plugin/jxr/stubs/PomMavenProjectStub.java | 70 +- .../stubs/TestSourceDirMavenProjectStub.java | 53 +- maven-jxr/pom.xml | 64 +- .../apache/maven/jxr/DirectoryIndexer.java | 241 ++--- .../main/java/org/apache/maven/jxr/JXR.java | 137 ++- .../apache/maven/jxr/JavaCodeTransform.java | 872 ++++++++---------- .../org/apache/maven/jxr/JxrException.java | 12 +- .../maven/jxr/ant/DirectoryScanner.java | 16 +- .../org/apache/maven/jxr/pacman/BaseType.java | 19 +- .../apache/maven/jxr/pacman/ClassType.java | 26 +- .../apache/maven/jxr/pacman/FileManager.java | 30 +- .../apache/maven/jxr/pacman/ImportType.java | 36 +- .../org/apache/maven/jxr/pacman/JavaFile.java | 73 +- .../apache/maven/jxr/pacman/JavaFileImpl.java | 139 +-- .../maven/jxr/pacman/PackageManager.java | 119 +-- .../apache/maven/jxr/pacman/PackageType.java | 32 +- .../maven/jxr/util/SimpleWordTokenizer.java | 65 +- .../apache/maven/jxr/util/StringEntry.java | 16 +- .../maven/jxr/DirectoryIndexerTest.java | 57 +- .../apache/maven/jxr/IncludeExcludeTest.java | 52 +- .../java/org/apache/maven/jxr/JXR141Test.java | 67 +- .../maven/jxr/JavaCodeTransformTest.java | 155 ++-- .../org/apache/maven/jxr/JxrBeanTest.java | 32 +- .../maven/jxr/pacman/JavaFileImplTest.java | 69 +- .../jxr/util/SimpleWordTokenizerTest.java | 135 ++- pom.xml | 40 +- 50 files changed, 1930 insertions(+), 2651 deletions(-) diff --git a/maven-jxr-plugin/pom.xml b/maven-jxr-plugin/pom.xml index 226b9ed7..20b9078e 100644 --- a/maven-jxr-plugin/pom.xml +++ b/maven-jxr-plugin/pom.xml @@ -1,5 +1,4 @@ - - 4.0.0 @@ -35,15 +33,15 @@ under the License. Maven JXR Plugin 2005 + + ${mavenVersion} + + 3.2.5 1.0.0.v20140518 - - ${mavenVersion} - - org.apache.maven @@ -84,7 +82,8 @@ under the License. org.apache.maven.wagon wagon-provider-api - 2.8 + 2.8 + org.apache.maven.reporting @@ -121,8 +120,8 @@ under the License. test - plexus-container-default org.codehaus.plexus + plexus-container-default diff --git a/maven-jxr-plugin/src/main/java/org/apache/maven/plugin/jxr/AbstractJxrReport.java b/maven-jxr-plugin/src/main/java/org/apache/maven/plugin/jxr/AbstractJxrReport.java index 0d66f1c7..b239be91 100644 --- a/maven-jxr-plugin/src/main/java/org/apache/maven/plugin/jxr/AbstractJxrReport.java +++ b/maven-jxr-plugin/src/main/java/org/apache/maven/plugin/jxr/AbstractJxrReport.java @@ -1,5 +1,3 @@ -package org.apache.maven.plugin.jxr; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.plugin.jxr; import java.io.File; import java.io.IOException; @@ -53,30 +52,31 @@ * @author Brett Porter * @author Vincent Siveton */ -public abstract class AbstractJxrReport - extends AbstractMavenReport -{ +public abstract class AbstractJxrReport extends AbstractMavenReport { - @Parameter( defaultValue = "${session}", readonly = true, required = true ) + @Parameter(defaultValue = "${session}", readonly = true, required = true) private MavenSession session; /** * Title of window of the Xref HTML files. */ - @Parameter( defaultValue = "${project.name} ${project.version} Reference" ) + @Parameter(defaultValue = "${project.name} ${project.version} Reference") private String windowTitle; /** * Title of main page of the Xref HTML files. */ - @Parameter( defaultValue = "${project.name} ${project.version} Reference" ) + @Parameter(defaultValue = "${project.name} ${project.version} Reference") private String docTitle; // CHECKSTYLE_OFF: LineLength /** * String used at the bottom of the Xref HTML files. */ - @Parameter( property = "bottom", defaultValue = "Copyright © {inceptionYear}–{currentYear} {organizationName}. All rights reserved." ) + @Parameter( + property = "bottom", + defaultValue = + "Copyright © {inceptionYear}–{currentYear} {organizationName}. All rights reserved.") private String bottom; // CHECKSTYLE_ON: LineLength @@ -114,7 +114,7 @@ public abstract class AbstractJxrReport /** * The projects in the reactor for aggregation report. */ - @Parameter( defaultValue = "${reactorProjects}", readonly = true ) + @Parameter(defaultValue = "${reactorProjects}", readonly = true) protected List reactorProjects; /** @@ -122,14 +122,14 @@ public abstract class AbstractJxrReport * * @since 2.3 */ - @Parameter( property = "maven.jxr.skip", defaultValue = "false" ) + @Parameter(property = "maven.jxr.skip", defaultValue = "false") protected boolean skip; /** * Link the Javadoc from the Source XRef. Defaults to true and will link automatically if javadoc plugin is being * used. */ - @Parameter( defaultValue = "true" ) + @Parameter(defaultValue = "true") private boolean linkJavadoc; /** @@ -137,7 +137,7 @@ public abstract class AbstractJxrReport * The value should reflect `java.specification.version`, "1.4", "1.8", "9", "10", * by default this system property is used. */ - @Parameter( property = "javadocVersion" ) + @Parameter(property = "javadocVersion") private String javadocVersion; /** @@ -151,14 +151,11 @@ public abstract class AbstractJxrReport * @param sourceDirs the List of the source directories * @return a List of the directories that will be included in the JXR report generation */ - protected List pruneSourceDirs( List sourceDirs ) - { - List pruned = new ArrayList<>( sourceDirs.size() ); - for ( String dir : sourceDirs ) - { - if ( !pruned.contains( dir ) && hasSources( new File( dir ) ) ) - { - pruned.add( dir ); + protected List pruneSourceDirs(List sourceDirs) { + List pruned = new ArrayList<>(sourceDirs.size()); + for (String dir : sourceDirs) { + if (!pruned.contains(dir) && hasSources(new File(dir))) { + pruned.add(dir); } } return pruned; @@ -167,17 +164,13 @@ protected List pruneSourceDirs( List sourceDirs ) /** * Initialize some attributes required during the report generation */ - protected void init() - { + protected void init() { // wanna know if Javadoc is being generated // TODO: what if it is not part of the site though, and just on the command line? - if ( project.getModel().getReporting() != null ) - { - for ( ReportPlugin reportPlugin : Collections.unmodifiableList( - project.getModel().getReporting().getPlugins() ) ) - { - if ( "maven-javadoc-plugin".equals( reportPlugin.getArtifactId() ) ) - { + if (project.getModel().getReporting() != null) { + for (ReportPlugin reportPlugin : Collections.unmodifiableList( + project.getModel().getReporting().getPlugins())) { + if ("maven-javadoc-plugin".equals(reportPlugin.getArtifactId())) { break; } } @@ -190,24 +183,16 @@ protected void init() * @param dir the source directory * @return true if the folder or one of its subfolders contains at least 1 Java file */ - private boolean hasSources( File dir ) - { - if ( dir.exists() && dir.isDirectory() ) - { - for ( File currentFile : dir.listFiles() ) - { - if ( currentFile.isFile() ) - { - if ( currentFile.getName().endsWith( ".java" ) ) - { + private boolean hasSources(File dir) { + if (dir.exists() && dir.isDirectory()) { + for (File currentFile : dir.listFiles()) { + if (currentFile.isFile()) { + if (currentFile.getName().endsWith(".java")) { return true; } - } - else - { - if ( Character.isJavaIdentifierStart( currentFile.getName().charAt( 0 ) ) // avoid .svn directory - && hasSources( currentFile ) ) - { + } else { + if (Character.isJavaIdentifierStart(currentFile.getName().charAt(0)) // avoid .svn directory + && hasSources(currentFile)) { return true; } } @@ -226,99 +211,81 @@ && hasSources( currentFile ) ) * @throws java.io.IOException * @throws org.apache.maven.jxr.JxrException */ - private void createXref( Locale locale, String destinationDirectory, List sourceDirs ) - throws IOException, JxrException - { + private void createXref(Locale locale, String destinationDirectory, List sourceDirs) + throws IOException, JxrException { FileManager fileManager = new FileManager(); - PackageManager packageManager = new PackageManager( fileManager ); - JavaCodeTransform codeTransform = new JavaCodeTransform( packageManager, fileManager ); - - JXR jxr = new JXR( packageManager, codeTransform ); - jxr.setDest( Paths.get( destinationDirectory ) ); - jxr.setInputEncoding( getInputEncoding() ); - jxr.setLocale( locale ); - jxr.setOutputEncoding( getOutputEncoding() ); - jxr.setRevision( "HEAD" ); - jxr.setJavadocLinkDir( getJavadocLocation() ); + PackageManager packageManager = new PackageManager(fileManager); + JavaCodeTransform codeTransform = new JavaCodeTransform(packageManager, fileManager); + + JXR jxr = new JXR(packageManager, codeTransform); + jxr.setDest(Paths.get(destinationDirectory)); + jxr.setInputEncoding(getInputEncoding()); + jxr.setLocale(locale); + jxr.setOutputEncoding(getOutputEncoding()); + jxr.setRevision("HEAD"); + jxr.setJavadocLinkDir(getJavadocLocation()); // Set include/exclude patterns on the jxr instance - if ( excludes != null && !excludes.isEmpty() ) - { - jxr.setExcludes( excludes.toArray( new String[0] ) ); + if (excludes != null && !excludes.isEmpty()) { + jxr.setExcludes(excludes.toArray(new String[0])); } - if ( includes != null && !includes.isEmpty() ) - { - jxr.setIncludes( includes.toArray( new String[0] ) ); + if (includes != null && !includes.isEmpty()) { + jxr.setIncludes(includes.toArray(new String[0])); } // avoid winding up using Velocity in two class loaders. ClassLoader savedTccl = Thread.currentThread().getContextClassLoader(); - try - { - Thread.currentThread().setContextClassLoader( getClass().getClassLoader() ); - jxr.xref( sourceDirs, getTemplateDir(), windowTitle, docTitle, getBottomText() ); - } - finally - { - Thread.currentThread().setContextClassLoader( savedTccl ); + try { + Thread.currentThread().setContextClassLoader(getClass().getClassLoader()); + jxr.xref(sourceDirs, getTemplateDir(), windowTitle, docTitle, getBottomText()); + } finally { + Thread.currentThread().setContextClassLoader(savedTccl); } // and finally copy the stylesheet - copyRequiredResources( destinationDirectory ); + copyRequiredResources(destinationDirectory); } /** * Returns the bottom text to be displayed at the lower part of the generated JXR reports. */ - private String getBottomText() - { - int currentYear = Calendar.getInstance().get( Calendar.YEAR ); - String year = String.valueOf( currentYear ); + private String getBottomText() { + int currentYear = Calendar.getInstance().get(Calendar.YEAR); + String year = String.valueOf(currentYear); String inceptionYear = project.getInceptionYear(); - String theBottom = StringUtils.replace( this.bottom, "{currentYear}", year ); + String theBottom = StringUtils.replace(this.bottom, "{currentYear}", year); - if ( inceptionYear != null ) - { - if ( inceptionYear.equals( year ) ) - { - theBottom = StringUtils.replace( theBottom, "{inceptionYear}–", "" ); - } - else - { - theBottom = StringUtils.replace( theBottom, "{inceptionYear}", inceptionYear ); + if (inceptionYear != null) { + if (inceptionYear.equals(year)) { + theBottom = StringUtils.replace(theBottom, "{inceptionYear}–", ""); + } else { + theBottom = StringUtils.replace(theBottom, "{inceptionYear}", inceptionYear); } - } - else - { - theBottom = StringUtils.replace( theBottom, "{inceptionYear}–", "" ); + } else { + theBottom = StringUtils.replace(theBottom, "{inceptionYear}–", ""); } - if ( project.getOrganization() == null ) - { - theBottom = StringUtils.replace( theBottom, " {organizationName}", "" ); - } - else - { - if ( StringUtils.isNotEmpty( project.getOrganization().getName() ) ) - { - if ( StringUtils.isNotEmpty( project.getOrganization().getUrl() ) ) - { + if (project.getOrganization() == null) { + theBottom = StringUtils.replace(theBottom, " {organizationName}", ""); + } else { + if (StringUtils.isNotEmpty(project.getOrganization().getName())) { + if (StringUtils.isNotEmpty(project.getOrganization().getUrl())) { // CHECKSTYLE_OFF: LineLength - theBottom = - StringUtils.replace( theBottom, "{organizationName}", "" + project.getOrganization().getName() + "" ); + theBottom = StringUtils.replace( + theBottom, + "{organizationName}", + "" + + project.getOrganization().getName() + ""); // CHECKSTYLE_ON: LineLength + } else { + theBottom = StringUtils.replace( + theBottom, + "{organizationName}", + project.getOrganization().getName()); } - else - { - theBottom = - StringUtils.replace( theBottom, "{organizationName}", project.getOrganization().getName() ); - } - } - else - { - theBottom = StringUtils.replace( theBottom, " {organizationName}", "" ); + } else { + theBottom = StringUtils.replace(theBottom, " {organizationName}", ""); } } @@ -330,60 +297,40 @@ private String getBottomText() * * @param dir the directory to copy the resources to */ - private void copyRequiredResources( String dir ) - { - if ( stylesheet != null && !stylesheet.isEmpty() ) - { - File stylesheetFile = new File( stylesheet ); - File destStylesheetFile = new File( dir, "stylesheet.css" ); - - try - { - if ( stylesheetFile.isAbsolute() ) - { - FileUtils.copyFile( stylesheetFile, destStylesheetFile ); + private void copyRequiredResources(String dir) { + if (stylesheet != null && !stylesheet.isEmpty()) { + File stylesheetFile = new File(stylesheet); + File destStylesheetFile = new File(dir, "stylesheet.css"); + + try { + if (stylesheetFile.isAbsolute()) { + FileUtils.copyFile(stylesheetFile, destStylesheetFile); + } else { + URL stylesheetUrl = this.getClass().getClassLoader().getResource(stylesheet); + FileUtils.copyURLToFile(stylesheetUrl, destStylesheetFile); } - else - { - URL stylesheetUrl = this.getClass().getClassLoader().getResource( stylesheet ); - FileUtils.copyURLToFile( stylesheetUrl, destStylesheetFile ); - } - } - catch ( IOException e ) - { - getLog().warn( "An error occured while copying the stylesheet to the target directory", e ); - } - } - else - { - if ( javadocTemplatesVersion.isAtLeast( "1.8" ) ) - { - copyResources( dir, "jdk8/", "stylesheet.css" ); + } catch (IOException e) { + getLog().warn("An error occured while copying the stylesheet to the target directory", e); } - else if ( javadocTemplatesVersion.isAtLeast( "1.7" ) ) - { - String[] jdk7Resources = - { + } else { + if (javadocTemplatesVersion.isAtLeast("1.8")) { + copyResources(dir, "jdk8/", "stylesheet.css"); + } else if (javadocTemplatesVersion.isAtLeast("1.7")) { + String[] jdk7Resources = { "stylesheet.css", "resources/background.gif", "resources/tab.gif", "resources/titlebar.gif", "resources/titlebar_end.gif" }; - copyResources( dir, "jdk7/", jdk7Resources ); - } - else if ( javadocTemplatesVersion.isAtLeast( "1.6" ) ) - { - copyResources( dir, "jdk6/", "stylesheet.css" ); - } - else if ( javadocTemplatesVersion.isAtLeast( "1.4" ) ) - { - copyResources( dir, "jdk4/", "stylesheet.css" ); - } - else - { + copyResources(dir, "jdk7/", jdk7Resources); + } else if (javadocTemplatesVersion.isAtLeast("1.6")) { + copyResources(dir, "jdk6/", "stylesheet.css"); + } else if (javadocTemplatesVersion.isAtLeast("1.4")) { + copyResources(dir, "jdk4/", "stylesheet.css"); + } else { // Fallback to the original stylesheet - copyResources( dir, "", "stylesheet.css" ); + copyResources(dir, "", "stylesheet.css"); } } } @@ -395,26 +342,20 @@ else if ( javadocTemplatesVersion.isAtLeast( "1.4" ) ) * @param sourceFolder resources subfolder to copy from * @param files names of files to copy */ - private void copyResources( String dir, String sourceFolder, String... files ) - { - try - { - for ( String file : files ) - { - URL resourceUrl = this.getClass().getClassLoader().getResource( sourceFolder + file ); - File destResourceFile = new File( dir, file ); - FileUtils.copyURLToFile( resourceUrl, destResourceFile ); + private void copyResources(String dir, String sourceFolder, String... files) { + try { + for (String file : files) { + URL resourceUrl = this.getClass().getClassLoader().getResource(sourceFolder + file); + File destResourceFile = new File(dir, file); + FileUtils.copyURLToFile(resourceUrl, destResourceFile); } - } - catch ( IOException e ) - { - getLog().warn( "An error occured while copying the resource to the target directory", e ); + } catch (IOException e) { + getLog().warn("An error occured while copying the resource to the target directory", e); } } @Override - protected MavenProject getProject() - { + protected MavenProject getProject() { return project; } @@ -422,8 +363,7 @@ protected MavenProject getProject() * Returns the Maven session. * @return Maven session */ - protected MavenSession getSession() - { + protected MavenSession getSession() { return session; } @@ -433,9 +373,8 @@ protected MavenSession getSession() * @param locale the locale of the user * @return the bundle corresponding to the locale */ - protected ResourceBundle getBundle( Locale locale ) - { - return ResourceBundle.getBundle( "jxr-report", locale, this.getClass().getClassLoader() ); + protected ResourceBundle getBundle(Locale locale) { + return ResourceBundle.getBundle("jxr-report", locale, this.getClass().getClassLoader()); } /** @@ -444,72 +383,53 @@ protected ResourceBundle getBundle( Locale locale ) * @param sourceDirs list of source directories * @return true if the report could be generated */ - protected boolean canGenerateReport( List sourceDirs ) - { + protected boolean canGenerateReport(List sourceDirs) { boolean canGenerate = !sourceDirs.isEmpty(); - if ( isAggregate() && !project.isExecutionRoot() ) - { + if (isAggregate() && !project.isExecutionRoot()) { canGenerate = false; } return canGenerate; } @Override - protected void executeReport( Locale locale ) - throws MavenReportException - { - if ( skip ) - { - getLog().info( "Skipping JXR." ); + protected void executeReport(Locale locale) throws MavenReportException { + if (skip) { + getLog().info("Skipping JXR."); return; } List sourceDirs = constructSourceDirs(); - if ( canGenerateReport( sourceDirs ) ) - { + if (canGenerateReport(sourceDirs)) { // init some attributes -- TODO (javadoc) init(); // determine version of templates to use setJavadocTemplatesVersion(); - try - { - createXref( locale, getDestinationDirectory(), sourceDirs ); - } - catch ( JxrException | IOException e ) - { - throw new MavenReportException( "Error while generating the HTML source code of the project.", e ); + try { + createXref(locale, getDestinationDirectory(), sourceDirs); + } catch (JxrException | IOException e) { + throw new MavenReportException("Error while generating the HTML source code of the project.", e); } } } - /** * Determine the templateDir to use, given javadocTemplatesVersion * * @return */ - private String getTemplateDir() - { + private String getTemplateDir() { // Check if overridden - if ( templateDir == null || templateDir.isEmpty() ) - { - if ( javadocTemplatesVersion.isAtLeast( "1.8" ) ) - { + if (templateDir == null || templateDir.isEmpty()) { + if (javadocTemplatesVersion.isAtLeast("1.8")) { return "templates/jdk8"; - } - else if ( javadocTemplatesVersion.isAtLeast( "1.7" ) ) - { + } else if (javadocTemplatesVersion.isAtLeast("1.7")) { return "templates/jdk7"; - } - else if ( javadocTemplatesVersion.isAtLeast( "1.4" ) ) - { + } else if (javadocTemplatesVersion.isAtLeast("1.4")) { return "templates/jdk4"; - } - else - { - getLog().warn( "Unsupported javadocVersion: " + javadocTemplatesVersion + ". Fallback to original" ); + } else { + getLog().warn("Unsupported javadocVersion: " + javadocTemplatesVersion + ". Fallback to original"); return "templates"; } } @@ -520,16 +440,12 @@ else if ( javadocTemplatesVersion.isAtLeast( "1.4" ) ) /** * Sets a new value for {@code javadocTemplatesVersion}. */ - private void setJavadocTemplatesVersion() - { + private void setJavadocTemplatesVersion() { JavaVersion javaVersion = JavaVersion.JAVA_SPECIFICATION_VERSION; - if ( javadocVersion != null && !javadocVersion.isEmpty() ) - { - javadocTemplatesVersion = JavaVersion.parse( javadocVersion ); - } - else - { + if (javadocVersion != null && !javadocVersion.isEmpty()) { + javadocTemplatesVersion = JavaVersion.parse(javadocVersion); + } else { javadocTemplatesVersion = javaVersion; } } @@ -539,102 +455,81 @@ private void setJavadocTemplatesVersion() * * @return a List of the source directories whose contents will be included in the JXR report generation */ - protected List constructSourceDirs() - { - List sourceDirs = new ArrayList<>( getSourceRoots() ); - if ( isAggregate() ) - { - for ( MavenProject project : reactorProjects ) - { - if ( "java".equals( project.getArtifact().getArtifactHandler().getLanguage() ) ) - { - sourceDirs.addAll( getSourceRoots( project ) ); + protected List constructSourceDirs() { + List sourceDirs = new ArrayList<>(getSourceRoots()); + if (isAggregate()) { + for (MavenProject project : reactorProjects) { + if ("java".equals(project.getArtifact().getArtifactHandler().getLanguage())) { + sourceDirs.addAll(getSourceRoots(project)); } } } - sourceDirs = pruneSourceDirs( sourceDirs ); + sourceDirs = pruneSourceDirs(sourceDirs); return sourceDirs; } @Override - public boolean canGenerateReport() - { - return canGenerateReport( constructSourceDirs() ); + public boolean canGenerateReport() { + return canGenerateReport(constructSourceDirs()); } @Override - public boolean isExternalReport() - { + public boolean isExternalReport() { return true; } /** * @return a String that contains the location of the javadocs */ - private Path getJavadocLocation() - throws IOException - { + private Path getJavadocLocation() throws IOException { Path location = null; - if ( linkJavadoc ) - { + if (linkJavadoc) { // We don't need to do the whole translation thing like normal, because JXR does it internally. // It probably shouldn't. - if ( getJavadocDir().exists() ) - { + if (getJavadocDir().exists()) { // XRef was already generated by manual execution of a lifecycle binding location = getJavadocDir().toPath().toAbsolutePath(); - } - else - { + } else { // Not yet generated - check if the report is on its way // Special case: using the site:stage goal - String stagingDirectory = System.getProperty( "stagingDirectory" ); + String stagingDirectory = System.getProperty("stagingDirectory"); - if ( stagingDirectory != null && !stagingDirectory.isEmpty() ) - { + if (stagingDirectory != null && !stagingDirectory.isEmpty()) { String javadocDestDir = getJavadocDir().getName(); - boolean javadocAggregate = JxrReportUtil.isJavadocAggregated( project ); - String structureProject = JxrReportUtil.getStructure( project, false ); + boolean javadocAggregate = JxrReportUtil.isJavadocAggregated(project); + String structureProject = JxrReportUtil.getStructure(project, false); - if ( isAggregate() && javadocAggregate ) - { - location = Paths.get( stagingDirectory, structureProject, javadocDestDir ); + if (isAggregate() && javadocAggregate) { + location = Paths.get(stagingDirectory, structureProject, javadocDestDir); } - if ( !isAggregate() && javadocAggregate ) - { - location = Paths.get( stagingDirectory, javadocDestDir ); + if (!isAggregate() && javadocAggregate) { + location = Paths.get(stagingDirectory, javadocDestDir); String hierarchy = project.getName(); MavenProject parent = project.getParent(); - while ( parent != null ) - { + while (parent != null) { hierarchy = parent.getName(); parent = parent.getParent(); } - location = Paths.get( stagingDirectory, hierarchy, javadocDestDir ); + location = Paths.get(stagingDirectory, hierarchy, javadocDestDir); } - if ( isAggregate() && !javadocAggregate ) - { - getLog().warn( "The JXR plugin is configured to build an aggregated report at the root, " - + "not the Javadoc plugin." ); + if (isAggregate() && !javadocAggregate) { + getLog().warn("The JXR plugin is configured to build an aggregated report at the root, " + + "not the Javadoc plugin."); } - if ( !isAggregate() && !javadocAggregate ) - { - location = Paths.get( stagingDirectory, structureProject, javadocDestDir ); + if (!isAggregate() && !javadocAggregate) { + location = Paths.get(stagingDirectory, structureProject, javadocDestDir); } - } - else - { + } else { location = getJavadocDir().toPath(); } } - if ( location == null ) - { - getLog().warn( "Unable to locate Javadoc to link to - DISABLED" ); + if (location == null) { + getLog().warn("Unable to locate Javadoc to link to - DISABLED"); } } @@ -662,7 +557,7 @@ private Path getJavadocLocation() * @param project the MavenProject where the JXR report plugin will be executed * @return a List of the source directories */ - protected abstract List getSourceRoots( MavenProject project ); + protected abstract List getSourceRoots(MavenProject project); /** * Abstract method that returns the directory of the javadoc files. @@ -676,8 +571,7 @@ private Path getJavadocLocation() * * @return true if aggregate, false otherwise */ - protected boolean isAggregate() - { + protected boolean isAggregate() { return false; } } diff --git a/maven-jxr-plugin/src/main/java/org/apache/maven/plugin/jxr/AggregatorJxrReport.java b/maven-jxr-plugin/src/main/java/org/apache/maven/plugin/jxr/AggregatorJxrReport.java index d5e331bc..3f6ee68a 100644 --- a/maven-jxr-plugin/src/main/java/org/apache/maven/plugin/jxr/AggregatorJxrReport.java +++ b/maven-jxr-plugin/src/main/java/org/apache/maven/plugin/jxr/AggregatorJxrReport.java @@ -1,5 +1,3 @@ -package org.apache.maven.plugin.jxr; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.plugin.jxr; import org.apache.maven.plugins.annotations.Execute; import org.apache.maven.plugins.annotations.LifecyclePhase; @@ -28,16 +27,12 @@ * * @since 2.3 */ -@Mojo( name = "aggregate", aggregator = true ) -@Execute( phase = LifecyclePhase.COMPILE ) -public class AggregatorJxrReport - extends JxrReport -{ +@Mojo(name = "aggregate", aggregator = true) +@Execute(phase = LifecyclePhase.COMPILE) +public class AggregatorJxrReport extends JxrReport { @Override - protected boolean isAggregate() - { + protected boolean isAggregate() { return true; } - } diff --git a/maven-jxr-plugin/src/main/java/org/apache/maven/plugin/jxr/AggregatorJxrTestReport.java b/maven-jxr-plugin/src/main/java/org/apache/maven/plugin/jxr/AggregatorJxrTestReport.java index 9156ac2e..3be1fc2d 100644 --- a/maven-jxr-plugin/src/main/java/org/apache/maven/plugin/jxr/AggregatorJxrTestReport.java +++ b/maven-jxr-plugin/src/main/java/org/apache/maven/plugin/jxr/AggregatorJxrTestReport.java @@ -1,5 +1,3 @@ -package org.apache.maven.plugin.jxr; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.plugin.jxr; import org.apache.maven.plugins.annotations.Execute; import org.apache.maven.plugins.annotations.LifecyclePhase; @@ -28,15 +27,11 @@ * * @since 2.3 */ -@Mojo( name = "test-aggregate", aggregator = true ) -@Execute( phase = LifecyclePhase.TEST_COMPILE ) -public class AggregatorJxrTestReport - extends JxrTestReport -{ +@Mojo(name = "test-aggregate", aggregator = true) +@Execute(phase = LifecyclePhase.TEST_COMPILE) +public class AggregatorJxrTestReport extends JxrTestReport { @Override - protected boolean isAggregate() - { + protected boolean isAggregate() { return true; } - } diff --git a/maven-jxr-plugin/src/main/java/org/apache/maven/plugin/jxr/JxrNoForkReport.java b/maven-jxr-plugin/src/main/java/org/apache/maven/plugin/jxr/JxrNoForkReport.java index eea54b0d..a407ca83 100644 --- a/maven-jxr-plugin/src/main/java/org/apache/maven/plugin/jxr/JxrNoForkReport.java +++ b/maven-jxr-plugin/src/main/java/org/apache/maven/plugin/jxr/JxrNoForkReport.java @@ -1,5 +1,3 @@ -package org.apache.maven.plugin.jxr; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.plugin.jxr; import org.apache.maven.plugins.annotations.Execute; import org.apache.maven.plugins.annotations.LifecyclePhase; @@ -30,9 +29,6 @@ * * @since 3.1.0 */ -@Mojo( name = "jxr-no-fork" ) -@Execute( phase = LifecyclePhase.NONE ) -public class JxrNoForkReport - extends JxrReport -{ -} +@Mojo(name = "jxr-no-fork") +@Execute(phase = LifecyclePhase.NONE) +public class JxrNoForkReport extends JxrReport {} diff --git a/maven-jxr-plugin/src/main/java/org/apache/maven/plugin/jxr/JxrReport.java b/maven-jxr-plugin/src/main/java/org/apache/maven/plugin/jxr/JxrReport.java index 7bc724f8..7740d02a 100644 --- a/maven-jxr-plugin/src/main/java/org/apache/maven/plugin/jxr/JxrReport.java +++ b/maven-jxr-plugin/src/main/java/org/apache/maven/plugin/jxr/JxrReport.java @@ -1,5 +1,3 @@ -package org.apache.maven.plugin.jxr; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.plugin.jxr; import java.io.File; import java.util.ArrayList; @@ -37,15 +36,13 @@ * * @author Fabrice Bellingard */ -@Mojo( name = "jxr" ) -@Execute( phase = LifecyclePhase.GENERATE_SOURCES ) -public class JxrReport - extends AbstractJxrReport -{ +@Mojo(name = "jxr") +@Execute(phase = LifecyclePhase.GENERATE_SOURCES) +public class JxrReport extends AbstractJxrReport { /** * Source directories of the project. */ - @Parameter( defaultValue = "${project.compileSourceRoots}", required = true, readonly = true ) + @Parameter(defaultValue = "${project.compileSourceRoots}", required = true, readonly = true) private List sourceDirs; /** @@ -58,45 +55,38 @@ public class JxrReport /** * Folder where the Xref files will be copied to. */ - @Parameter( defaultValue = "${project.reporting.outputDirectory}/xref" ) + @Parameter(defaultValue = "${project.reporting.outputDirectory}/xref") private String destDir; /** * Folder where Javadoc is generated for this project. */ - @Parameter( defaultValue = "${project.reporting.outputDirectory}/apidocs" ) + @Parameter(defaultValue = "${project.reporting.outputDirectory}/apidocs") private File javadocDir; @Override - protected String getDestinationDirectory() - { + protected String getDestinationDirectory() { return destDir; } @Override - protected List getSourceRoots() - { - if ( sourcePath != null ) - { - String[] sourcePathArray = sourcePath.split( ";" ); - if ( sourcePathArray.length > 0 ) - { - return Arrays.asList( sourcePathArray ); + protected List getSourceRoots() { + if (sourcePath != null) { + String[] sourcePathArray = sourcePath.split(";"); + if (sourcePathArray.length > 0) { + return Arrays.asList(sourcePathArray); } } List l = new ArrayList<>(); - if ( !"pom".equals( getProject().getPackaging().toLowerCase( Locale.US ) ) ) - { - l.addAll( sourceDirs ); + if (!"pom".equals(getProject().getPackaging().toLowerCase(Locale.US))) { + l.addAll(sourceDirs); } - if ( getProject().getExecutionProject() != null ) - { - if ( !"pom".equals( getProject().getExecutionProject().getPackaging().toLowerCase( Locale.US ) ) ) - { - l.addAll( getProject().getExecutionProject().getCompileSourceRoots() ); + if (getProject().getExecutionProject() != null) { + if (!"pom".equals(getProject().getExecutionProject().getPackaging().toLowerCase(Locale.US))) { + l.addAll(getProject().getExecutionProject().getCompileSourceRoots()); } } @@ -104,20 +94,16 @@ protected List getSourceRoots() } @Override - protected List getSourceRoots( MavenProject project ) - { + protected List getSourceRoots(MavenProject project) { List l = new ArrayList<>(); - if ( !"pom".equals( project.getPackaging().toLowerCase( Locale.US ) ) ) - { - l.addAll( project.getCompileSourceRoots() ); + if (!"pom".equals(project.getPackaging().toLowerCase(Locale.US))) { + l.addAll(project.getCompileSourceRoots()); } - if ( project.getExecutionProject() != null ) - { - if ( !"pom".equals( project.getExecutionProject().getPackaging().toLowerCase( Locale.US ) ) ) - { - l.addAll( project.getExecutionProject().getCompileSourceRoots() ); + if (project.getExecutionProject() != null) { + if (!"pom".equals(project.getExecutionProject().getPackaging().toLowerCase(Locale.US))) { + l.addAll(project.getExecutionProject().getCompileSourceRoots()); } } @@ -125,38 +111,31 @@ protected List getSourceRoots( MavenProject project ) } @Override - public String getDescription( Locale locale ) - { - return getBundle( locale ).getString( "report.xref.main.description" ); + public String getDescription(Locale locale) { + return getBundle(locale).getString("report.xref.main.description"); } @Override - public String getName( Locale locale ) - { - return getBundle( locale ).getString( "report.xref.main.name" ); + public String getName(Locale locale) { + return getBundle(locale).getString("report.xref.main.name"); } @Override - public String getOutputName() - { + public String getOutputName() { return "xref/index"; } @Override - protected File getJavadocDir() - { + protected File getJavadocDir() { return javadocDir; } @Override - public void setReportOutputDirectory( File reportOutputDirectory ) - { - if ( ( reportOutputDirectory != null ) && ( !reportOutputDirectory.getAbsolutePath().endsWith( "xref" ) ) ) - { - this.destDir = new File( reportOutputDirectory, "xref" ).getAbsolutePath(); - } - else - { + public void setReportOutputDirectory(File reportOutputDirectory) { + if ((reportOutputDirectory != null) + && (!reportOutputDirectory.getAbsolutePath().endsWith("xref"))) { + this.destDir = new File(reportOutputDirectory, "xref").getAbsolutePath(); + } else { this.destDir = reportOutputDirectory.getAbsolutePath(); } } diff --git a/maven-jxr-plugin/src/main/java/org/apache/maven/plugin/jxr/JxrReportUtil.java b/maven-jxr-plugin/src/main/java/org/apache/maven/plugin/jxr/JxrReportUtil.java index d95a2ffa..2774f4d9 100644 --- a/maven-jxr-plugin/src/main/java/org/apache/maven/plugin/jxr/JxrReportUtil.java +++ b/maven-jxr-plugin/src/main/java/org/apache/maven/plugin/jxr/JxrReportUtil.java @@ -1,5 +1,3 @@ -package org.apache.maven.plugin.jxr; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.plugin.jxr; import java.io.IOException; import java.util.ArrayList; @@ -31,13 +30,13 @@ import org.apache.maven.wagon.repository.Repository; import org.codehaus.plexus.util.StringUtils; import org.codehaus.plexus.util.xml.Xpp3Dom; + /** * Utility class for the jxr report. * * @author Vincent Siveton */ -public class JxrReportUtil -{ +public class JxrReportUtil { private static final String MAVEN_JAVADOC_PLUGIN_GROUP_ID = "org.apache.maven.plugins"; @@ -50,29 +49,22 @@ public class JxrReportUtil * @param project the Maven project * @return if javadoc is aggregated, false otherwise */ - protected static boolean isJavadocAggregated( MavenProject project ) - { + protected static boolean isJavadocAggregated(MavenProject project) { // first check conf for obsolete aggregate param. - boolean javadocAggregate = Boolean.parseBoolean( - JxrReportUtil.getMavenJavadocPluginBasicOption( project, "aggregate", "false" ) ); + boolean javadocAggregate = + Boolean.parseBoolean(JxrReportUtil.getMavenJavadocPluginBasicOption(project, "aggregate", "false")); - if ( javadocAggregate ) - { + if (javadocAggregate) { return true; } - for ( Object pluginObject : getMavenJavadocPlugins( project ) ) - { - if ( pluginObject instanceof Plugin ) - { + for (Object pluginObject : getMavenJavadocPlugins(project)) { + if (pluginObject instanceof Plugin) { Plugin plugin = (Plugin) pluginObject; List executions = plugin.getExecutions(); - for ( PluginExecution pe : executions ) - { + for (PluginExecution pe : executions) { List goals = pe.getGoals(); - for ( String goal : goals ) - { - if ( "aggregate".equals( goal ) ) - { + for (String goal : goals) { + if ("aggregate".equals(goal)) { return true; } } @@ -90,52 +82,44 @@ protected static boolean isJavadocAggregated( MavenProject project ) * @param defaultValue a default value * @return the value for the option name or the default value. Could be null if not found. */ - protected static String getMavenJavadocPluginBasicOption( MavenProject project, String optionName, - String defaultValue ) - { + protected static String getMavenJavadocPluginBasicOption( + MavenProject project, String optionName, String defaultValue) { List plugins = new ArrayList<>(); - plugins.addAll( project.getModel().getReporting().getPlugins() ); - plugins.addAll( project.getModel().getBuild().getPlugins() ); + plugins.addAll(project.getModel().getReporting().getPlugins()); + plugins.addAll(project.getModel().getBuild().getPlugins()); String pluginArtifactId = MAVEN_JAVADOC_PLUGIN_ARTIFACT_ID; - for ( Object next : plugins ) - { + for (Object next : plugins) { Xpp3Dom pluginConf = null; - if ( next instanceof Plugin ) - { + if (next instanceof Plugin) { Plugin plugin = (Plugin) next; // using out-of-box Maven plugins - if ( !isReportPluginMavenJavadoc( pluginArtifactId, plugin ) ) - { + if (!isReportPluginMavenJavadoc(pluginArtifactId, plugin)) { continue; } pluginConf = (Xpp3Dom) plugin.getConfiguration(); } - if ( next instanceof ReportPlugin ) - { + if (next instanceof ReportPlugin) { ReportPlugin reportPlugin = (ReportPlugin) next; // using out-of-box Maven plugins - if ( !isReportPluginJavaDocPlugin( pluginArtifactId, reportPlugin ) ) - { + if (!isReportPluginJavaDocPlugin(pluginArtifactId, reportPlugin)) { continue; } pluginConf = (Xpp3Dom) reportPlugin.getConfiguration(); } - if ( pluginConf == null ) - { + if (pluginConf == null) { continue; } - String attribute = pluginConf.getAttribute( optionName ); - if ( attribute != null && !attribute.isEmpty() ) - { + String attribute = pluginConf.getAttribute(optionName); + if (attribute != null && !attribute.isEmpty()) { return attribute; } } @@ -149,55 +133,47 @@ protected static String getMavenJavadocPluginBasicOption( MavenProject project, * @param project Maven project * @return list of Javadoc plugins */ - protected static List getMavenJavadocPlugins( MavenProject project ) - { + protected static List getMavenJavadocPlugins(MavenProject project) { List plugins = new ArrayList<>(); - plugins.addAll( project.getModel().getReporting().getPlugins() ); - plugins.addAll( project.getModel().getBuild().getPlugins() ); + plugins.addAll(project.getModel().getReporting().getPlugins()); + plugins.addAll(project.getModel().getBuild().getPlugins()); List result = new ArrayList<>(); String pluginArtifactId = MAVEN_JAVADOC_PLUGIN_ARTIFACT_ID; - for ( Object next : plugins ) - { - if ( next instanceof Plugin ) - { + for (Object next : plugins) { + if (next instanceof Plugin) { Plugin plugin = (Plugin) next; // using out-of-box Maven plugins - if ( !isReportPluginMavenJavadoc( pluginArtifactId, plugin ) ) - { + if (!isReportPluginMavenJavadoc(pluginArtifactId, plugin)) { continue; } - result.add( plugin ); + result.add(plugin); } - if ( next instanceof ReportPlugin ) - { + if (next instanceof ReportPlugin) { ReportPlugin reportPlugin = (ReportPlugin) next; // using out-of-box Maven plugins - if ( !isReportPluginJavaDocPlugin( pluginArtifactId, reportPlugin ) ) - { + if (!isReportPluginJavaDocPlugin(pluginArtifactId, reportPlugin)) { continue; } - result.add( reportPlugin ); + result.add(reportPlugin); } } return result; } - private static boolean isReportPluginMavenJavadoc( String pluginArtifactId, Plugin plugin ) - { - return ( plugin.getGroupId().equals( MAVEN_JAVADOC_PLUGIN_GROUP_ID ) ) - && ( plugin.getArtifactId().equals( pluginArtifactId ) ); + private static boolean isReportPluginMavenJavadoc(String pluginArtifactId, Plugin plugin) { + return (plugin.getGroupId().equals(MAVEN_JAVADOC_PLUGIN_GROUP_ID)) + && (plugin.getArtifactId().equals(pluginArtifactId)); } - private static boolean isReportPluginJavaDocPlugin( String pluginArtifactId, ReportPlugin reportPlugin ) - { - return ( reportPlugin.getGroupId().equals( MAVEN_JAVADOC_PLUGIN_GROUP_ID ) ) - && ( reportPlugin.getArtifactId().equals( pluginArtifactId ) ); + private static boolean isReportPluginJavaDocPlugin(String pluginArtifactId, ReportPlugin reportPlugin) { + return (reportPlugin.getGroupId().equals(MAVEN_JAVADOC_PLUGIN_GROUP_ID)) + && (reportPlugin.getArtifactId().equals(pluginArtifactId)); } /** @@ -209,18 +185,14 @@ private static boolean isReportPluginJavaDocPlugin( String pluginArtifactId, Rep * @return the structure relative path * @throws IOException if site url is missing */ - protected static String getStructure( MavenProject project, boolean ignoreMissingSiteUrl ) - throws IOException - { + protected static String getStructure(MavenProject project, boolean ignoreMissingSiteUrl) throws IOException { // @todo come from site plugin! // @see o.a.m.p.site.SiteStageMojo#getStructure(MavenProject project, boolean ignoreMissingSiteUrl ) - if ( project.getDistributionManagement() == null ) - { + if (project.getDistributionManagement() == null) { String hierarchy = project.getName(); MavenProject parent = project.getParent(); - while ( parent != null ) - { + while (parent != null) { hierarchy = parent.getName() + '/' + hierarchy; parent = parent.getParent(); } @@ -229,35 +201,29 @@ protected static String getStructure( MavenProject project, boolean ignoreMissin } Site site = project.getDistributionManagement().getSite(); - if ( site == null ) - { - if ( !ignoreMissingSiteUrl ) - { - throw new IOException( "Missing site information in the distribution management " - + "element in the project: '" + project.getName() + "'." ); + if (site == null) { + if (!ignoreMissingSiteUrl) { + throw new IOException("Missing site information in the distribution management " + + "element in the project: '" + project.getName() + "'."); } return null; } - if ( StringUtils.isEmpty( site.getUrl() ) ) - { - if ( !ignoreMissingSiteUrl ) - { - throw new IOException( "The URL in the site is missing in the project descriptor." ); + if (StringUtils.isEmpty(site.getUrl())) { + if (!ignoreMissingSiteUrl) { + throw new IOException("The URL in the site is missing in the project descriptor."); } return null; } - Repository repository = new Repository( site.getId(), site.getUrl() ); - if ( StringUtils.isEmpty( repository.getBasedir() ) ) - { + Repository repository = new Repository(site.getId(), site.getUrl()); + if (StringUtils.isEmpty(repository.getBasedir())) { return repository.getHost(); } - if ( repository.getBasedir().startsWith( "/" ) ) - { + if (repository.getBasedir().startsWith("/")) { return repository.getHost() + repository.getBasedir(); } diff --git a/maven-jxr-plugin/src/main/java/org/apache/maven/plugin/jxr/JxrTestNoForkReport.java b/maven-jxr-plugin/src/main/java/org/apache/maven/plugin/jxr/JxrTestNoForkReport.java index f8856ebd..bf5d16c0 100644 --- a/maven-jxr-plugin/src/main/java/org/apache/maven/plugin/jxr/JxrTestNoForkReport.java +++ b/maven-jxr-plugin/src/main/java/org/apache/maven/plugin/jxr/JxrTestNoForkReport.java @@ -1,5 +1,3 @@ -package org.apache.maven.plugin.jxr; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.plugin.jxr; import org.apache.maven.plugins.annotations.Execute; import org.apache.maven.plugins.annotations.LifecyclePhase; @@ -30,9 +29,6 @@ * * @since 3.1.0 */ -@Mojo( name = "test-jxr-no-fork" ) -@Execute( phase = LifecyclePhase.NONE ) -public class JxrTestNoForkReport - extends JxrTestReport -{ -} +@Mojo(name = "test-jxr-no-fork") +@Execute(phase = LifecyclePhase.NONE) +public class JxrTestNoForkReport extends JxrTestReport {} diff --git a/maven-jxr-plugin/src/main/java/org/apache/maven/plugin/jxr/JxrTestReport.java b/maven-jxr-plugin/src/main/java/org/apache/maven/plugin/jxr/JxrTestReport.java index 99945d6f..62d51405 100644 --- a/maven-jxr-plugin/src/main/java/org/apache/maven/plugin/jxr/JxrTestReport.java +++ b/maven-jxr-plugin/src/main/java/org/apache/maven/plugin/jxr/JxrTestReport.java @@ -1,5 +1,3 @@ -package org.apache.maven.plugin.jxr; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.plugin.jxr; import java.io.File; import java.util.ArrayList; @@ -37,44 +36,38 @@ * @author Fabrice Bellingard * @author Brett Porter */ -@Mojo( name = "test-jxr" ) -@Execute( phase = LifecyclePhase.GENERATE_TEST_SOURCES ) -public class JxrTestReport - extends AbstractJxrReport -{ +@Mojo(name = "test-jxr") +@Execute(phase = LifecyclePhase.GENERATE_TEST_SOURCES) +public class JxrTestReport extends AbstractJxrReport { /** * Test directories of the project. */ - @Parameter( defaultValue = "${project.testCompileSourceRoots}", required = true, readonly = true ) + @Parameter(defaultValue = "${project.testCompileSourceRoots}", required = true, readonly = true) private List sourceDirs; /** * Folder where the Xref files will be copied to. */ - @Parameter( defaultValue = "${project.reporting.outputDirectory}/xref-test" ) + @Parameter(defaultValue = "${project.reporting.outputDirectory}/xref-test") private String destDir; /** * Folder where Test Javadoc is generated for this project. */ - @Parameter( defaultValue = "${project.reporting.outputDirectory}/testapidocs" ) + @Parameter(defaultValue = "${project.reporting.outputDirectory}/testapidocs") private File testJavadocDir; @Override - protected List getSourceRoots() - { + protected List getSourceRoots() { List l = new ArrayList<>(); - if ( !"pom".equals( getProject().getPackaging().toLowerCase( Locale.US ) ) ) - { - l.addAll( sourceDirs ); + if (!"pom".equals(getProject().getPackaging().toLowerCase(Locale.US))) { + l.addAll(sourceDirs); } - if ( getProject().getExecutionProject() != null ) - { - if ( !"pom".equals( getProject().getExecutionProject().getPackaging().toLowerCase( Locale.US ) ) ) - { - l.addAll( getProject().getExecutionProject().getTestCompileSourceRoots() ); + if (getProject().getExecutionProject() != null) { + if (!"pom".equals(getProject().getExecutionProject().getPackaging().toLowerCase(Locale.US))) { + l.addAll(getProject().getExecutionProject().getTestCompileSourceRoots()); } } @@ -82,15 +75,12 @@ protected List getSourceRoots() } @Override - protected List getSourceRoots( MavenProject project ) - { + protected List getSourceRoots(MavenProject project) { List l = new ArrayList<>(); - if ( project.getExecutionProject() != null ) - { - if ( !"pom".equals( project.getExecutionProject().getPackaging().toLowerCase( Locale.US ) ) ) - { - l.addAll( project.getExecutionProject().getTestCompileSourceRoots() ); + if (project.getExecutionProject() != null) { + if (!"pom".equals(project.getExecutionProject().getPackaging().toLowerCase(Locale.US))) { + l.addAll(project.getExecutionProject().getTestCompileSourceRoots()); } } @@ -98,44 +88,36 @@ protected List getSourceRoots( MavenProject project ) } @Override - protected String getDestinationDirectory() - { + protected String getDestinationDirectory() { return destDir; } @Override - public String getDescription( Locale locale ) - { - return getBundle( locale ).getString( "report.xref.test.description" ); + public String getDescription(Locale locale) { + return getBundle(locale).getString("report.xref.test.description"); } @Override - public String getName( Locale locale ) - { - return getBundle( locale ).getString( "report.xref.test.name" ); + public String getName(Locale locale) { + return getBundle(locale).getString("report.xref.test.name"); } @Override - public String getOutputName() - { + public String getOutputName() { return "xref-test/index"; } @Override - protected File getJavadocDir() - { + protected File getJavadocDir() { return testJavadocDir; } @Override - public void setReportOutputDirectory( File reportOutputDirectory ) - { - if ( ( reportOutputDirectory != null ) && ( !reportOutputDirectory.getAbsolutePath().endsWith( "xref-test" ) ) ) - { - this.destDir = new File( reportOutputDirectory, "xref-test" ).getAbsolutePath(); - } - else - { + public void setReportOutputDirectory(File reportOutputDirectory) { + if ((reportOutputDirectory != null) + && (!reportOutputDirectory.getAbsolutePath().endsWith("xref-test"))) { + this.destDir = new File(reportOutputDirectory, "xref-test").getAbsolutePath(); + } else { this.destDir = reportOutputDirectory.getAbsolutePath(); } } diff --git a/maven-jxr-plugin/src/test/java/org/apache/maven/plugin/jxr/AbstractJxrTestCase.java b/maven-jxr-plugin/src/test/java/org/apache/maven/plugin/jxr/AbstractJxrTestCase.java index 3b008b0b..b865c5a5 100644 --- a/maven-jxr-plugin/src/test/java/org/apache/maven/plugin/jxr/AbstractJxrTestCase.java +++ b/maven-jxr-plugin/src/test/java/org/apache/maven/plugin/jxr/AbstractJxrTestCase.java @@ -1,5 +1,3 @@ -package org.apache.maven.plugin.jxr; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.plugin.jxr; import java.io.File; import java.io.IOException; @@ -31,16 +30,14 @@ import org.apache.maven.project.MavenProject; import org.apache.maven.project.ProjectBuilder; import org.apache.maven.project.ProjectBuildingRequest; -import org.eclipse.aether.internal.impl.SimpleLocalRepositoryManagerFactory; import org.eclipse.aether.DefaultRepositorySystemSession; +import org.eclipse.aether.internal.impl.SimpleLocalRepositoryManagerFactory; import org.eclipse.aether.repository.LocalRepository; /** * Abstract class to test reports generation. */ -public abstract class AbstractJxrTestCase - extends AbstractMojoTestCase -{ +public abstract class AbstractJxrTestCase extends AbstractMojoTestCase { private ArtifactStubFactory artifactStubFactory; /** @@ -49,20 +46,16 @@ public abstract class AbstractJxrTestCase private MavenProject testMavenProject; @Override - protected void setUp() - throws Exception - { + protected void setUp() throws Exception { // required for mojo lookups to work super.setUp(); - artifactStubFactory = new DependencyArtifactStubFactory( getTestFile( "target" ), true, false ); + artifactStubFactory = new DependencyArtifactStubFactory(getTestFile("target"), true, false); artifactStubFactory.getWorkingDir().mkdirs(); } @Override - protected void tearDown() - throws Exception - { + protected void tearDown() throws Exception { super.tearDown(); } @@ -71,8 +64,7 @@ protected void tearDown() * * @return the maven project */ - protected MavenProject getTestMavenProject() - { + protected MavenProject getTestMavenProject() { return testMavenProject; } @@ -83,15 +75,13 @@ protected MavenProject getTestMavenProject() * @return the generated report as file * @throws IOException if the return file doesnt exist */ - protected File getGeneratedReport( String name ) - throws IOException - { - String outputDirectory = getBasedir() + "/target/test/unit/" + getTestMavenProject().getArtifactId(); - - File report = new File( outputDirectory, name ); - if ( !report.exists() ) - { - throw new IOException( "File not found. Attempted: " + report ); + protected File getGeneratedReport(String name) throws IOException { + String outputDirectory = + getBasedir() + "/target/test/unit/" + getTestMavenProject().getArtifactId(); + + File report = new File(outputDirectory, name); + if (!report.exists()) { + throw new IOException("File not found. Attempted: " + report); } return report; @@ -105,55 +95,48 @@ protected File getGeneratedReport( String name ) * @return the generated HTML file * @throws Exception if any */ - protected File generateReport( String goal, String pluginXml ) - throws Exception - { - File pluginXmlFile = new File( getBasedir(), "src/test/resources/unit/" + pluginXml ); - AbstractJxrReport mojo = createReportMojo( goal, pluginXmlFile ); - return generateReport( mojo, pluginXmlFile ); + protected File generateReport(String goal, String pluginXml) throws Exception { + File pluginXmlFile = new File(getBasedir(), "src/test/resources/unit/" + pluginXml); + AbstractJxrReport mojo = createReportMojo(goal, pluginXmlFile); + return generateReport(mojo, pluginXmlFile); } - protected AbstractJxrReport createReportMojo( String goal, File pluginXmlFile ) - throws Exception - { - AbstractJxrReport mojo = (AbstractJxrReport) lookupMojo( goal, pluginXmlFile ); - assertNotNull( "Mojo not found.", mojo ); + protected AbstractJxrReport createReportMojo(String goal, File pluginXmlFile) throws Exception { + AbstractJxrReport mojo = (AbstractJxrReport) lookupMojo(goal, pluginXmlFile); + assertNotNull("Mojo not found.", mojo); - LegacySupport legacySupport = lookup( LegacySupport.class ); - legacySupport.setSession( newMavenSession( new MavenProjectStub() ) ); + LegacySupport legacySupport = lookup(LegacySupport.class); + legacySupport.setSession(newMavenSession(new MavenProjectStub())); DefaultRepositorySystemSession repoSession = - (DefaultRepositorySystemSession) legacySupport.getRepositorySession(); - repoSession.setLocalRepositoryManager( new SimpleLocalRepositoryManagerFactory().newInstance( repoSession, new LocalRepository( artifactStubFactory.getWorkingDir() ) ) ); + (DefaultRepositorySystemSession) legacySupport.getRepositorySession(); + repoSession.setLocalRepositoryManager(new SimpleLocalRepositoryManagerFactory() + .newInstance(repoSession, new LocalRepository(artifactStubFactory.getWorkingDir()))); - setVariableValueToObject( mojo, "session", legacySupport.getSession() ); - setVariableValueToObject( mojo, "remoteRepositories", mojo.getProject().getRemoteArtifactRepositories() ); + setVariableValueToObject(mojo, "session", legacySupport.getSession()); + setVariableValueToObject(mojo, "remoteRepositories", mojo.getProject().getRemoteArtifactRepositories()); return mojo; } - protected File generateReport( AbstractJxrReport mojo, File pluginXmlFile ) - throws Exception - { + protected File generateReport(AbstractJxrReport mojo, File pluginXmlFile) throws Exception { mojo.execute(); - ProjectBuilder builder = lookup( ProjectBuilder.class ); + ProjectBuilder builder = lookup(ProjectBuilder.class); ProjectBuildingRequest buildingRequest = new DefaultProjectBuildingRequest(); - buildingRequest.setRepositorySession( lookup( LegacySupport.class ).getRepositorySession() ); + buildingRequest.setRepositorySession(lookup(LegacySupport.class).getRepositorySession()); - testMavenProject = builder.build( pluginXmlFile, buildingRequest ).getProject(); + testMavenProject = builder.build(pluginXmlFile, buildingRequest).getProject(); File outputDir = mojo.getReportOutputDirectory(); String filename = mojo.getOutputName() + ".html"; - return new File( outputDir, filename ); + return new File(outputDir, filename); } /** * Read the contents of the specified file object into a string */ - protected String readFile( File xrefTestDir, String fileName ) throws IOException - { - return new String( Files.readAllBytes( xrefTestDir.toPath().resolve( fileName ) ) ); + protected String readFile(File xrefTestDir, String fileName) throws IOException { + return new String(Files.readAllBytes(xrefTestDir.toPath().resolve(fileName))); } - } diff --git a/maven-jxr-plugin/src/test/java/org/apache/maven/plugin/jxr/DependencyArtifactStubFactory.java b/maven-jxr-plugin/src/test/java/org/apache/maven/plugin/jxr/DependencyArtifactStubFactory.java index dcccfbc1..7c7ce080 100644 --- a/maven-jxr-plugin/src/test/java/org/apache/maven/plugin/jxr/DependencyArtifactStubFactory.java +++ b/maven-jxr-plugin/src/test/java/org/apache/maven/plugin/jxr/DependencyArtifactStubFactory.java @@ -1,5 +1,3 @@ -package org.apache.maven.plugin.jxr; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "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 + * 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 @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.plugin.jxr; import java.io.File; import java.io.IOException; @@ -27,42 +26,44 @@ import org.apache.maven.artifact.versioning.VersionRange; import org.apache.maven.plugin.testing.ArtifactStubFactory; -public class DependencyArtifactStubFactory - extends ArtifactStubFactory -{ +public class DependencyArtifactStubFactory extends ArtifactStubFactory { private boolean flattenedPath = true; - public DependencyArtifactStubFactory( File theWorkingDir, boolean theCreateFiles, boolean flattenedPath ) - { - this( theWorkingDir, theCreateFiles ); + public DependencyArtifactStubFactory(File theWorkingDir, boolean theCreateFiles, boolean flattenedPath) { + this(theWorkingDir, theCreateFiles); this.flattenedPath = flattenedPath; } - public DependencyArtifactStubFactory( File theWorkingDir, boolean theCreateFiles ) - { - super( theWorkingDir, theCreateFiles ); + public DependencyArtifactStubFactory(File theWorkingDir, boolean theCreateFiles) { + super(theWorkingDir, theCreateFiles); } @Override - public Artifact createArtifact( String groupId, String artifactId, VersionRange versionRange, String scope, - String type, String classifier, boolean optional ) - throws IOException - { + public Artifact createArtifact( + String groupId, + String artifactId, + VersionRange versionRange, + String scope, + String type, + String classifier, + boolean optional) + throws IOException { File workingDir = getWorkingDir(); - if ( !flattenedPath ) - { + if (!flattenedPath) { // don't use flatten directories, won't happen at runtime - String path = groupId.replace( '.', '/' ) + '/' + - artifactId + '/' + - ArtifactUtils.toSnapshotVersion( versionRange.getRecommendedVersion().toString() ); - setWorkingDir( new File( workingDir, path ) ); + String path = groupId.replace('.', '/') + + '/' + + artifactId + + '/' + + ArtifactUtils.toSnapshotVersion( + versionRange.getRecommendedVersion().toString()); + setWorkingDir(new File(workingDir, path)); } - Artifact artifact = - super.createArtifact( groupId, artifactId, versionRange, scope, type, classifier, optional ); + Artifact artifact = super.createArtifact(groupId, artifactId, versionRange, scope, type, classifier, optional); - setWorkingDir( workingDir ); + setWorkingDir(workingDir); return artifact; } diff --git a/maven-jxr-plugin/src/test/java/org/apache/maven/plugin/jxr/JxrReportTest.java b/maven-jxr-plugin/src/test/java/org/apache/maven/plugin/jxr/JxrReportTest.java index 90b0a742..2a614b65 100644 --- a/maven-jxr-plugin/src/test/java/org/apache/maven/plugin/jxr/JxrReportTest.java +++ b/maven-jxr-plugin/src/test/java/org/apache/maven/plugin/jxr/JxrReportTest.java @@ -1,5 +1,3 @@ -package org.apache.maven.plugin.jxr; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -18,58 +16,55 @@ * specific language governing permissions and limitations * under the License. */ - -import org.codehaus.plexus.util.FileUtils; +package org.apache.maven.plugin.jxr; import java.io.File; import java.nio.file.Files; import java.nio.file.Path; import java.util.Locale; +import org.codehaus.plexus.util.FileUtils; + /** * @author Maria Odea Ching * @author Dennis Lundberg */ -public class JxrReportTest - extends AbstractJxrTestCase -{ +public class JxrReportTest extends AbstractJxrTestCase { /** * Test the plugin with original configuration * * @throws Exception */ - public void testDefaultConfiguration() - throws Exception - { - File resourcesDir = new File( getBasedir(), "src/test/resources/unit/default-configuration" ); + public void testDefaultConfiguration() throws Exception { + File resourcesDir = new File(getBasedir(), "src/test/resources/unit/default-configuration"); - File outputDir = new File( getBasedir(), "target/test/unit/default-configuration/target/site" ); - File xrefDir = new File( outputDir, "xref" ); + File outputDir = new File(getBasedir(), "target/test/unit/default-configuration/target/site"); + File xrefDir = new File(outputDir, "xref"); - FileUtils.copyDirectory( new File( resourcesDir, "javadoc-files" ), outputDir ); + FileUtils.copyDirectory(new File(resourcesDir, "javadoc-files"), outputDir); - generateReport( "jxr", "default-configuration/default-configuration-plugin-config.xml" ); + generateReport("jxr", "default-configuration/default-configuration-plugin-config.xml"); - //check if xref files were generated - assertTrue( new File( xrefDir, "allclasses-frame.html" ).exists() ); - assertTrue( new File( xrefDir, "index.html" ).exists() ); - assertTrue( new File( xrefDir, "overview-frame.html" ).exists() ); - assertTrue( new File( xrefDir, "overview-summary.html" ).exists() ); - assertTrue( new File( xrefDir, "stylesheet.css" ).exists() ); - assertTrue( new File( xrefDir, "def/configuration/App.html" ).exists() ); - assertTrue( new File( xrefDir, "def/configuration/AppSample.html" ).exists() ); - assertTrue( new File( xrefDir, "def/configuration/package-frame.html" ).exists() ); - assertTrue( new File( xrefDir, "def/configuration/package-summary.html" ).exists() ); + // check if xref files were generated + assertTrue(new File(xrefDir, "allclasses-frame.html").exists()); + assertTrue(new File(xrefDir, "index.html").exists()); + assertTrue(new File(xrefDir, "overview-frame.html").exists()); + assertTrue(new File(xrefDir, "overview-summary.html").exists()); + assertTrue(new File(xrefDir, "stylesheet.css").exists()); + assertTrue(new File(xrefDir, "def/configuration/App.html").exists()); + assertTrue(new File(xrefDir, "def/configuration/AppSample.html").exists()); + assertTrue(new File(xrefDir, "def/configuration/package-frame.html").exists()); + assertTrue(new File(xrefDir, "def/configuration/package-summary.html").exists()); - //check if there's a link to the javadoc files - String str = readFile( xrefDir, "def/configuration/AppSample.html" ); - assertTrue( str.toLowerCase().contains( "/apidocs/def/configuration/appsample.html\"" ) ); + // check if there's a link to the javadoc files + String str = readFile(xrefDir, "def/configuration/AppSample.html"); + assertTrue(str.toLowerCase().contains("/apidocs/def/configuration/appsample.html\"")); - str = readFile( xrefDir, "def/configuration/App.html" ); - assertTrue( str.toLowerCase().contains( "/apidocs/def/configuration/app.html\"".toLowerCase() ) ); + str = readFile(xrefDir, "def/configuration/App.html"); + assertTrue(str.toLowerCase().contains("/apidocs/def/configuration/app.html\"".toLowerCase())); // check if encoding is UTF-8, the default value - assertTrue( str.contains( "text/html; charset=UTF-8" ) ); + assertTrue(str.contains("text/html; charset=UTF-8")); } /** @@ -77,38 +72,36 @@ public void testDefaultConfiguration() * * @throws Exception */ - public void testJdk4Configuration() - throws Exception - { - File resourcesDir = new File( getBasedir(), "src/test/resources/unit/default-configuration" ); + public void testJdk4Configuration() throws Exception { + File resourcesDir = new File(getBasedir(), "src/test/resources/unit/default-configuration"); - File outputDir = new File( getBasedir(), "target/test/unit/default-configuration/target/site/4" ); - File xrefDir = new File( outputDir, "xref" ); + File outputDir = new File(getBasedir(), "target/test/unit/default-configuration/target/site/4"); + File xrefDir = new File(outputDir, "xref"); - FileUtils.copyDirectory( new File( resourcesDir, "javadoc-files" ), outputDir ); + FileUtils.copyDirectory(new File(resourcesDir, "javadoc-files"), outputDir); - generateReport( "jxr", "default-configuration/default-configuration-plugin-config-4.xml" ); + generateReport("jxr", "default-configuration/default-configuration-plugin-config-4.xml"); - //check if xref files were generated - assertTrue( new File( xrefDir, "allclasses-frame.html" ).exists() ); - assertTrue( new File( xrefDir, "index.html" ).exists() ); - assertTrue( new File( xrefDir, "overview-frame.html" ).exists() ); - assertTrue( new File( xrefDir, "overview-summary.html" ).exists() ); - assertTrue( new File( xrefDir, "stylesheet.css" ).exists() ); - assertTrue( new File( xrefDir, "def/configuration/App.html" ).exists() ); - assertTrue( new File( xrefDir, "def/configuration/AppSample.html" ).exists() ); - assertTrue( new File( xrefDir, "def/configuration/package-frame.html" ).exists() ); - assertTrue( new File( xrefDir, "def/configuration/package-summary.html" ).exists() ); + // check if xref files were generated + assertTrue(new File(xrefDir, "allclasses-frame.html").exists()); + assertTrue(new File(xrefDir, "index.html").exists()); + assertTrue(new File(xrefDir, "overview-frame.html").exists()); + assertTrue(new File(xrefDir, "overview-summary.html").exists()); + assertTrue(new File(xrefDir, "stylesheet.css").exists()); + assertTrue(new File(xrefDir, "def/configuration/App.html").exists()); + assertTrue(new File(xrefDir, "def/configuration/AppSample.html").exists()); + assertTrue(new File(xrefDir, "def/configuration/package-frame.html").exists()); + assertTrue(new File(xrefDir, "def/configuration/package-summary.html").exists()); - //check if there's a link to the javadoc files - String str = readFile( xrefDir, "def/configuration/AppSample.html" ); - assertTrue( str.toLowerCase( Locale.US ).contains( "/apidocs/def/configuration/appsample.html\"" ) ); + // check if there's a link to the javadoc files + String str = readFile(xrefDir, "def/configuration/AppSample.html"); + assertTrue(str.toLowerCase(Locale.US).contains("/apidocs/def/configuration/appsample.html\"")); - str = readFile( xrefDir, "def/configuration/App.html" ); - assertTrue( str.toLowerCase( Locale.US ).contains( "/apidocs/def/configuration/app.html\"" ) ); + str = readFile(xrefDir, "def/configuration/App.html"); + assertTrue(str.toLowerCase(Locale.US).contains("/apidocs/def/configuration/app.html\"")); // check if encoding is UTF-8, the default value - assertTrue( str.contains( "text/html; charset=UTF-8" ) ); + assertTrue(str.contains("text/html; charset=UTF-8")); } /** @@ -116,38 +109,36 @@ public void testJdk4Configuration() * * @throws Exception */ - public void testJdk6Configuration() - throws Exception - { - File resourcesDir = new File( getBasedir(), "src/test/resources/unit/default-configuration" ); + public void testJdk6Configuration() throws Exception { + File resourcesDir = new File(getBasedir(), "src/test/resources/unit/default-configuration"); - File outputDir = new File( getBasedir(), "target/test/unit/default-configuration/target/site/6" ); - File xrefDir = new File( outputDir, "xref" ); + File outputDir = new File(getBasedir(), "target/test/unit/default-configuration/target/site/6"); + File xrefDir = new File(outputDir, "xref"); - FileUtils.copyDirectory( new File( resourcesDir, "javadoc-files" ), outputDir ); + FileUtils.copyDirectory(new File(resourcesDir, "javadoc-files"), outputDir); - generateReport( "jxr", "default-configuration/default-configuration-plugin-config-6.xml" ); + generateReport("jxr", "default-configuration/default-configuration-plugin-config-6.xml"); - //check if xref files were generated - assertTrue( new File( xrefDir, "allclasses-frame.html" ).exists() ); - assertTrue( new File( xrefDir, "index.html" ).exists() ); - assertTrue( new File( xrefDir, "overview-frame.html" ).exists() ); - assertTrue( new File( xrefDir, "overview-summary.html" ).exists() ); - assertTrue( new File( xrefDir, "stylesheet.css" ).exists() ); - assertTrue( new File( xrefDir, "def/configuration/App.html" ).exists() ); - assertTrue( new File( xrefDir, "def/configuration/AppSample.html" ).exists() ); - assertTrue( new File( xrefDir, "def/configuration/package-frame.html" ).exists() ); - assertTrue( new File( xrefDir, "def/configuration/package-summary.html" ).exists() ); + // check if xref files were generated + assertTrue(new File(xrefDir, "allclasses-frame.html").exists()); + assertTrue(new File(xrefDir, "index.html").exists()); + assertTrue(new File(xrefDir, "overview-frame.html").exists()); + assertTrue(new File(xrefDir, "overview-summary.html").exists()); + assertTrue(new File(xrefDir, "stylesheet.css").exists()); + assertTrue(new File(xrefDir, "def/configuration/App.html").exists()); + assertTrue(new File(xrefDir, "def/configuration/AppSample.html").exists()); + assertTrue(new File(xrefDir, "def/configuration/package-frame.html").exists()); + assertTrue(new File(xrefDir, "def/configuration/package-summary.html").exists()); - //check if there's a link to the javadoc files - String str = readFile( xrefDir, "def/configuration/AppSample.html" ); - assertTrue( str.toLowerCase( Locale.US ).contains( "/apidocs/def/configuration/appsample.html\"" ) ); + // check if there's a link to the javadoc files + String str = readFile(xrefDir, "def/configuration/AppSample.html"); + assertTrue(str.toLowerCase(Locale.US).contains("/apidocs/def/configuration/appsample.html\"")); - str = readFile( xrefDir, "def/configuration/App.html" ); - assertTrue( str.toLowerCase( Locale.US ).contains( "/apidocs/def/configuration/app.html\"" ) ); + str = readFile(xrefDir, "def/configuration/App.html"); + assertTrue(str.toLowerCase(Locale.US).contains("/apidocs/def/configuration/app.html\"")); // check if encoding is UTF-8, the default value - assertTrue( str.contains( "text/html; charset=UTF-8" ) ); + assertTrue(str.contains("text/html; charset=UTF-8")); } /** @@ -155,42 +146,40 @@ public void testJdk6Configuration() * * @throws Exception */ - public void testJdk7Configuration() - throws Exception - { - File resourcesDir = new File( getBasedir(), "src/test/resources/unit/default-configuration" ); - - File outputDir = new File( getBasedir(), "target/test/unit/default-configuration/target/site/7" ); - File xrefDir = new File( outputDir, "xref" ); - - FileUtils.copyDirectory( new File( resourcesDir, "javadoc-files" ), outputDir ); - - generateReport( "jxr", "default-configuration/default-configuration-plugin-config-7.xml" ); - - //check if xref files were generated - assertTrue( new File( xrefDir, "allclasses-frame.html" ).exists() ); - assertTrue( new File( xrefDir, "index.html" ).exists() ); - assertTrue( new File( xrefDir, "overview-frame.html" ).exists() ); - assertTrue( new File( xrefDir, "overview-summary.html" ).exists() ); - assertTrue( new File( xrefDir, "stylesheet.css" ).exists() ); - assertTrue( new File( xrefDir, "resources/background.gif" ).exists() ); - assertTrue( new File( xrefDir, "resources/tab.gif" ).exists() ); - assertTrue( new File( xrefDir, "resources/titlebar.gif" ).exists() ); - assertTrue( new File( xrefDir, "resources/titlebar_end.gif" ).exists() ); - assertTrue( new File( xrefDir, "def/configuration/App.html" ).exists() ); - assertTrue( new File( xrefDir, "def/configuration/AppSample.html" ).exists() ); - assertTrue( new File( xrefDir, "def/configuration/package-frame.html" ).exists() ); - assertTrue( new File( xrefDir, "def/configuration/package-summary.html" ).exists() ); - - //check if there's a link to the javadoc files - String str = readFile( xrefDir, "def/configuration/AppSample.html" ); - assertTrue( str.toLowerCase( Locale.US ).contains( "/apidocs/def/configuration/appsample.html\"" ) ); - - str = readFile( xrefDir, "def/configuration/App.html" ); - assertTrue( str.toLowerCase( Locale.US ).contains( "/apidocs/def/configuration/app.html\"" ) ); + public void testJdk7Configuration() throws Exception { + File resourcesDir = new File(getBasedir(), "src/test/resources/unit/default-configuration"); + + File outputDir = new File(getBasedir(), "target/test/unit/default-configuration/target/site/7"); + File xrefDir = new File(outputDir, "xref"); + + FileUtils.copyDirectory(new File(resourcesDir, "javadoc-files"), outputDir); + + generateReport("jxr", "default-configuration/default-configuration-plugin-config-7.xml"); + + // check if xref files were generated + assertTrue(new File(xrefDir, "allclasses-frame.html").exists()); + assertTrue(new File(xrefDir, "index.html").exists()); + assertTrue(new File(xrefDir, "overview-frame.html").exists()); + assertTrue(new File(xrefDir, "overview-summary.html").exists()); + assertTrue(new File(xrefDir, "stylesheet.css").exists()); + assertTrue(new File(xrefDir, "resources/background.gif").exists()); + assertTrue(new File(xrefDir, "resources/tab.gif").exists()); + assertTrue(new File(xrefDir, "resources/titlebar.gif").exists()); + assertTrue(new File(xrefDir, "resources/titlebar_end.gif").exists()); + assertTrue(new File(xrefDir, "def/configuration/App.html").exists()); + assertTrue(new File(xrefDir, "def/configuration/AppSample.html").exists()); + assertTrue(new File(xrefDir, "def/configuration/package-frame.html").exists()); + assertTrue(new File(xrefDir, "def/configuration/package-summary.html").exists()); + + // check if there's a link to the javadoc files + String str = readFile(xrefDir, "def/configuration/AppSample.html"); + assertTrue(str.toLowerCase(Locale.US).contains("/apidocs/def/configuration/appsample.html\"")); + + str = readFile(xrefDir, "def/configuration/App.html"); + assertTrue(str.toLowerCase(Locale.US).contains("/apidocs/def/configuration/app.html\"")); // check if encoding is UTF-8, the default value - assertTrue( str.contains( "text/html; charset=UTF-8" ) ); + assertTrue(str.contains("text/html; charset=UTF-8")); } /** @@ -198,38 +187,36 @@ public void testJdk7Configuration() * * @throws Exception */ - public void testJdk8Configuration() - throws Exception - { - File resourcesDir = new File( getBasedir(), "src/test/resources/unit/default-configuration" ); + public void testJdk8Configuration() throws Exception { + File resourcesDir = new File(getBasedir(), "src/test/resources/unit/default-configuration"); - File outputDir = new File( getBasedir(), "target/test/unit/default-configuration/target/site/8" ); - File xrefDir = new File( outputDir, "xref" ); + File outputDir = new File(getBasedir(), "target/test/unit/default-configuration/target/site/8"); + File xrefDir = new File(outputDir, "xref"); - FileUtils.copyDirectory( new File( resourcesDir, "javadoc-files" ), outputDir ); + FileUtils.copyDirectory(new File(resourcesDir, "javadoc-files"), outputDir); - generateReport( "jxr", "default-configuration/default-configuration-plugin-config-8.xml" ); + generateReport("jxr", "default-configuration/default-configuration-plugin-config-8.xml"); - //check if xref files were generated - assertTrue( new File( xrefDir, "allclasses-frame.html" ).exists() ); - assertTrue( new File( xrefDir, "index.html" ).exists() ); - assertTrue( new File( xrefDir, "overview-frame.html" ).exists() ); - assertTrue( new File( xrefDir, "overview-summary.html" ).exists() ); - assertTrue( new File( xrefDir, "stylesheet.css" ).exists() ); - assertTrue( new File( xrefDir, "def/configuration/App.html" ).exists() ); - assertTrue( new File( xrefDir, "def/configuration/AppSample.html" ).exists() ); - assertTrue( new File( xrefDir, "def/configuration/package-frame.html" ).exists() ); - assertTrue( new File( xrefDir, "def/configuration/package-summary.html" ).exists() ); + // check if xref files were generated + assertTrue(new File(xrefDir, "allclasses-frame.html").exists()); + assertTrue(new File(xrefDir, "index.html").exists()); + assertTrue(new File(xrefDir, "overview-frame.html").exists()); + assertTrue(new File(xrefDir, "overview-summary.html").exists()); + assertTrue(new File(xrefDir, "stylesheet.css").exists()); + assertTrue(new File(xrefDir, "def/configuration/App.html").exists()); + assertTrue(new File(xrefDir, "def/configuration/AppSample.html").exists()); + assertTrue(new File(xrefDir, "def/configuration/package-frame.html").exists()); + assertTrue(new File(xrefDir, "def/configuration/package-summary.html").exists()); - //check if there's a link to the javadoc files - String str = readFile( xrefDir, "def/configuration/AppSample.html" ); - assertTrue( str.toLowerCase().contains( "/apidocs/def/configuration/appsample.html\"" ) ); + // check if there's a link to the javadoc files + String str = readFile(xrefDir, "def/configuration/AppSample.html"); + assertTrue(str.toLowerCase().contains("/apidocs/def/configuration/appsample.html\"")); - str = readFile( xrefDir, "def/configuration/App.html" ); - assertTrue( str.toLowerCase().contains( "/apidocs/def/configuration/app.html\"".toLowerCase() ) ); + str = readFile(xrefDir, "def/configuration/App.html"); + assertTrue(str.toLowerCase().contains("/apidocs/def/configuration/app.html\"".toLowerCase())); // check if encoding is UTF-8, the default value - assertTrue( str.contains( "text/html; charset=UTF-8" ) ); + assertTrue(str.contains("text/html; charset=UTF-8")); } /** @@ -237,40 +224,37 @@ public void testJdk8Configuration() * * @throws Exception */ - public void testNoJavadocLink() - throws Exception - { - generateReport( "jxr", "nojavadoclink-configuration/nojavadoclink-configuration-plugin-config.xml" ); - - File xrefDir = new File( getBasedir(), "target/test/unit/nojavadoclink-configuration/target/site/xref" ); - - //check if xref files were generated - assertTrue( new File( xrefDir, "allclasses-frame.html" ).exists() ); - assertTrue( new File( xrefDir, "index.html" ).exists() ); - assertTrue( new File( xrefDir, "overview-frame.html" ).exists() ); - assertTrue( new File( xrefDir, "overview-summary.html" ).exists() ); - assertTrue( new File( xrefDir, "stylesheet.css" ).exists() ); - assertTrue( new File( xrefDir, "nojavadoclink/configuration/App.html" ).exists() ); - assertTrue( new File( xrefDir, "nojavadoclink/configuration/AppSample.html" ).exists() ); - assertTrue( new File( xrefDir, "nojavadoclink/configuration/package-frame.html" ).exists() ); - assertTrue( new File( xrefDir, "nojavadoclink/configuration/package-summary.html" ).exists() ); - assertTrue( new File( xrefDir, "nojavadoclink/configuration/sample/package-summary.html" ).exists() ); - assertTrue( new File( xrefDir, "nojavadoclink/configuration/sample/package-frame.html" ).exists() ); - assertTrue( new File( xrefDir, "nojavadoclink/configuration/sample/Sample.html" ).exists() ); - - //check if there's a link to the javadoc files - String str = readFile( xrefDir, "nojavadoclink/configuration/AppSample.html" ); - assertEquals( str.toLowerCase( Locale.US ).indexOf( "/apidocs/nojavadoclink/configuration/appsample.html\"" ), - -1 ); - - str = readFile( xrefDir, "nojavadoclink/configuration/App.html" ); - assertEquals( str.toLowerCase( Locale.US ).indexOf( "/apidocs/nojavadoclink/configuration/app.html\"" ), -1 ); - - str = readFile( xrefDir, "nojavadoclink/configuration/sample/Sample.html" ); - assertEquals( str.toLowerCase().indexOf( "/apidocs/nojavadoclink/configuration/sample/sample.html\"" ), -1 ); + public void testNoJavadocLink() throws Exception { + generateReport("jxr", "nojavadoclink-configuration/nojavadoclink-configuration-plugin-config.xml"); + + File xrefDir = new File(getBasedir(), "target/test/unit/nojavadoclink-configuration/target/site/xref"); + + // check if xref files were generated + assertTrue(new File(xrefDir, "allclasses-frame.html").exists()); + assertTrue(new File(xrefDir, "index.html").exists()); + assertTrue(new File(xrefDir, "overview-frame.html").exists()); + assertTrue(new File(xrefDir, "overview-summary.html").exists()); + assertTrue(new File(xrefDir, "stylesheet.css").exists()); + assertTrue(new File(xrefDir, "nojavadoclink/configuration/App.html").exists()); + assertTrue(new File(xrefDir, "nojavadoclink/configuration/AppSample.html").exists()); + assertTrue(new File(xrefDir, "nojavadoclink/configuration/package-frame.html").exists()); + assertTrue(new File(xrefDir, "nojavadoclink/configuration/package-summary.html").exists()); + assertTrue(new File(xrefDir, "nojavadoclink/configuration/sample/package-summary.html").exists()); + assertTrue(new File(xrefDir, "nojavadoclink/configuration/sample/package-frame.html").exists()); + assertTrue(new File(xrefDir, "nojavadoclink/configuration/sample/Sample.html").exists()); + + // check if there's a link to the javadoc files + String str = readFile(xrefDir, "nojavadoclink/configuration/AppSample.html"); + assertEquals(str.toLowerCase(Locale.US).indexOf("/apidocs/nojavadoclink/configuration/appsample.html\""), -1); + + str = readFile(xrefDir, "nojavadoclink/configuration/App.html"); + assertEquals(str.toLowerCase(Locale.US).indexOf("/apidocs/nojavadoclink/configuration/app.html\""), -1); + + str = readFile(xrefDir, "nojavadoclink/configuration/sample/Sample.html"); + assertEquals(str.toLowerCase().indexOf("/apidocs/nojavadoclink/configuration/sample/sample.html\""), -1); // check if encoding is ISO-8859-1, like specified in the plugin configuration - assertTrue( str.contains( "text/html; charset=ISO-8859-1" ) ); + assertTrue(str.contains("text/html; charset=ISO-8859-1")); } /** @@ -278,24 +262,22 @@ public void testNoJavadocLink() * * @throws Exception */ - public void testAggregate() - throws Exception - { - generateReport( "jxr", "aggregate-test/aggregate-test-plugin-config.xml" ); - - File xrefDir = new File( getBasedir(), "target/test/unit/aggregate-test/target/site/xref" ); - - //check if xref files were generated for submodule1 - assertTrue( new File( xrefDir, "aggregate/test/submodule1/package-frame.html" ).exists() ); - assertTrue( new File( xrefDir, "aggregate/test/submodule1/package-summary.html" ).exists() ); - assertTrue( new File( xrefDir, "aggregate/test/submodule1/Submodule1App.html" ).exists() ); - assertTrue( new File( xrefDir, "aggregate/test/submodule1/Submodule1AppSample.html" ).exists() ); - - //check if xref files were generated for submodule2 - assertTrue( new File( xrefDir, "aggregate/test/submodule2/package-frame.html" ).exists() ); - assertTrue( new File( xrefDir, "aggregate/test/submodule2/package-summary.html" ).exists() ); - assertTrue( new File( xrefDir, "aggregate/test/submodule2/Submodule2App.html" ).exists() ); - assertTrue( new File( xrefDir, "aggregate/test/submodule2/Submodule2AppSample.html" ).exists() ); + public void testAggregate() throws Exception { + generateReport("jxr", "aggregate-test/aggregate-test-plugin-config.xml"); + + File xrefDir = new File(getBasedir(), "target/test/unit/aggregate-test/target/site/xref"); + + // check if xref files were generated for submodule1 + assertTrue(new File(xrefDir, "aggregate/test/submodule1/package-frame.html").exists()); + assertTrue(new File(xrefDir, "aggregate/test/submodule1/package-summary.html").exists()); + assertTrue(new File(xrefDir, "aggregate/test/submodule1/Submodule1App.html").exists()); + assertTrue(new File(xrefDir, "aggregate/test/submodule1/Submodule1AppSample.html").exists()); + + // check if xref files were generated for submodule2 + assertTrue(new File(xrefDir, "aggregate/test/submodule2/package-frame.html").exists()); + assertTrue(new File(xrefDir, "aggregate/test/submodule2/package-summary.html").exists()); + assertTrue(new File(xrefDir, "aggregate/test/submodule2/Submodule2App.html").exists()); + assertTrue(new File(xrefDir, "aggregate/test/submodule2/Submodule2AppSample.html").exists()); } /** @@ -303,19 +285,17 @@ public void testAggregate() * * @throws Exception */ - public void testNoJavadocDir() - throws Exception - { - generateReport( "jxr", "nojavadocdir-test/nojavadocdir-test-plugin-config.xml" ); + public void testNoJavadocDir() throws Exception { + generateReport("jxr", "nojavadocdir-test/nojavadocdir-test-plugin-config.xml"); - File xrefDir = new File( getBasedir(), "target/test/unit/nojavadocdir-test/target/site/xref" ); + File xrefDir = new File(getBasedir(), "target/test/unit/nojavadocdir-test/target/site/xref"); - //check if there's a link to the javadoc files - String str = readFile( xrefDir, "nojavadocdir/test/AppSample.html" ); - assertTrue( str.toLowerCase( Locale.US ).contains( "/apidocs/nojavadocdir/test/appsample.html" ) ); + // check if there's a link to the javadoc files + String str = readFile(xrefDir, "nojavadocdir/test/AppSample.html"); + assertTrue(str.toLowerCase(Locale.US).contains("/apidocs/nojavadocdir/test/appsample.html")); - str = readFile( xrefDir, "nojavadocdir/test/App.html" ); - assertTrue( str.toLowerCase( Locale.US ).contains( "/apidocs/nojavadocdir/test/app.html" ) ); + str = readFile(xrefDir, "nojavadocdir/test/App.html"); + assertTrue(str.toLowerCase(Locale.US).contains("/apidocs/nojavadocdir/test/app.html")); } /** @@ -323,18 +303,16 @@ public void testNoJavadocDir() * * @throws Exception */ - public void testExclude() - throws Exception - { - generateReport( "jxr", "exclude-configuration/exclude-configuration-plugin-config.xml" ); + public void testExclude() throws Exception { + generateReport("jxr", "exclude-configuration/exclude-configuration-plugin-config.xml"); - Path xrefDir = new File( getBasedir(), "target/test/unit/exclude-configuration/target/site/xref" ).toPath(); + Path xrefDir = new File(getBasedir(), "target/test/unit/exclude-configuration/target/site/xref").toPath(); // check that the non-excluded xref files were generated - assertTrue( Files.exists( xrefDir.resolve( "exclude/configuration/App.html" ) ) ); + assertTrue(Files.exists(xrefDir.resolve("exclude/configuration/App.html"))); // check that the excluded xref files were not generated - assertFalse( Files.exists( xrefDir.resolve( "exclude/configuration/AppSample.html" ) ) ); + assertFalse(Files.exists(xrefDir.resolve("exclude/configuration/AppSample.html"))); } /** @@ -342,31 +320,25 @@ public void testExclude() * * @throws Exception */ - public void testInclude() - throws Exception - { - generateReport( "jxr", "include-configuration/include-configuration-plugin-config.xml" ); + public void testInclude() throws Exception { + generateReport("jxr", "include-configuration/include-configuration-plugin-config.xml"); - Path xrefDir = new File( getBasedir(), "target/test/unit/include-configuration/target/site/xref" ).toPath(); + Path xrefDir = new File(getBasedir(), "target/test/unit/include-configuration/target/site/xref").toPath(); // check that the included xref files were generated - assertTrue( Files.exists( xrefDir.resolve( "include/configuration/App.html" ))); + assertTrue(Files.exists(xrefDir.resolve("include/configuration/App.html"))); // check that the non-included xref files were not generated - assertFalse( Files.exists( xrefDir.resolve( "include/configuration/AppSample.html" ))); + assertFalse(Files.exists(xrefDir.resolve("include/configuration/AppSample.html"))); } - public void testExceptions() - { - try - { - generateReport( "jxr", "default-configuration/exception-test-plugin-config.xml" ); + public void testExceptions() { + try { + generateReport("jxr", "default-configuration/exception-test-plugin-config.xml"); - fail( "Must throw exception" ); - } - catch ( Exception e ) - { - assertTrue( true ); + fail("Must throw exception"); + } catch (Exception e) { + assertTrue(true); } } @@ -375,12 +347,9 @@ public void testExceptions() * * @throws Exception */ - public void testPom() - throws Exception - { - generateReport( "jxr", "pom-test/pom-test-plugin-config.xml" ); + public void testPom() throws Exception { + generateReport("jxr", "pom-test/pom-test-plugin-config.xml"); - assertFalse( new File( getBasedir(), "target/test/unit/pom-test" ).exists() ); + assertFalse(new File(getBasedir(), "target/test/unit/pom-test").exists()); } - } diff --git a/maven-jxr-plugin/src/test/java/org/apache/maven/plugin/jxr/JxrTestReportTest.java b/maven-jxr-plugin/src/test/java/org/apache/maven/plugin/jxr/JxrTestReportTest.java index c70eab21..4acbc6ba 100644 --- a/maven-jxr-plugin/src/test/java/org/apache/maven/plugin/jxr/JxrTestReportTest.java +++ b/maven-jxr-plugin/src/test/java/org/apache/maven/plugin/jxr/JxrTestReportTest.java @@ -1,5 +1,3 @@ -package org.apache.maven.plugin.jxr; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -18,46 +16,40 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.plugin.jxr; import java.io.File; -import java.io.IOException; -import java.nio.file.Files; /** * @author Maria Odea Ching */ -public class JxrTestReportTest - extends AbstractJxrTestCase -{ +public class JxrTestReportTest extends AbstractJxrTestCase { /** * Method to test when the source dir is the test source dir * * @throws Exception */ - public void testSourceDir() - throws Exception - { - generateReport( "test-jxr", "testsourcedir-test/testsourcedir-test-plugin-config.xml" ); + public void testSourceDir() throws Exception { + generateReport("test-jxr", "testsourcedir-test/testsourcedir-test-plugin-config.xml"); - File xrefTestDir = new File( getBasedir(), "target/test/unit/testsourcedir-test/target/site/xref-test" ); + File xrefTestDir = new File(getBasedir(), "target/test/unit/testsourcedir-test/target/site/xref-test"); // check if the jxr docs were generated - assertTrue( new File( xrefTestDir, "testsourcedir/test/AppSampleTest.html" ).exists() ); - assertTrue( new File( xrefTestDir, "testsourcedir/test/AppTest.html" ).exists() ); - assertTrue( new File( xrefTestDir, "testsourcedir/test/package-frame.html" ).exists() ); - assertTrue( new File( xrefTestDir, "testsourcedir/test/package-summary.html" ).exists() ); - assertTrue( new File( xrefTestDir, "allclasses-frame.html" ).exists() ); - assertTrue( new File( xrefTestDir, "index.html" ).exists() ); - assertTrue( new File( xrefTestDir, "overview-frame.html" ).exists() ); - assertTrue( new File( xrefTestDir, "overview-summary.html" ).exists() ); - assertTrue( new File( xrefTestDir, "stylesheet.css" ).exists() ); + assertTrue(new File(xrefTestDir, "testsourcedir/test/AppSampleTest.html").exists()); + assertTrue(new File(xrefTestDir, "testsourcedir/test/AppTest.html").exists()); + assertTrue(new File(xrefTestDir, "testsourcedir/test/package-frame.html").exists()); + assertTrue(new File(xrefTestDir, "testsourcedir/test/package-summary.html").exists()); + assertTrue(new File(xrefTestDir, "allclasses-frame.html").exists()); + assertTrue(new File(xrefTestDir, "index.html").exists()); + assertTrue(new File(xrefTestDir, "overview-frame.html").exists()); + assertTrue(new File(xrefTestDir, "overview-summary.html").exists()); + assertTrue(new File(xrefTestDir, "stylesheet.css").exists()); // check if there's a link to the javadoc files - String str = readFile( xrefTestDir, "testsourcedir/test/AppSampleTest.html" ); - assertFalse( str.toLowerCase().contains( "/apidocs/testsourcedir/test/AppSample.html\"".toLowerCase() ) ); + String str = readFile(xrefTestDir, "testsourcedir/test/AppSampleTest.html"); + assertFalse(str.toLowerCase().contains("/apidocs/testsourcedir/test/AppSample.html\"".toLowerCase())); - str = readFile( xrefTestDir, "testsourcedir/test/AppTest.html" ); - assertFalse( str.toLowerCase().contains( "/apidocs/testsourcedir/test/App.html\"".toLowerCase() ) ); + str = readFile(xrefTestDir, "testsourcedir/test/AppTest.html"); + assertFalse(str.toLowerCase().contains("/apidocs/testsourcedir/test/App.html\"".toLowerCase())); } - } diff --git a/maven-jxr-plugin/src/test/java/org/apache/maven/plugin/jxr/stubs/AggregateSubmodule1MavenProjectStub.java b/maven-jxr-plugin/src/test/java/org/apache/maven/plugin/jxr/stubs/AggregateSubmodule1MavenProjectStub.java index 40d55e8d..4b35e5b6 100644 --- a/maven-jxr-plugin/src/test/java/org/apache/maven/plugin/jxr/stubs/AggregateSubmodule1MavenProjectStub.java +++ b/maven-jxr-plugin/src/test/java/org/apache/maven/plugin/jxr/stubs/AggregateSubmodule1MavenProjectStub.java @@ -1,5 +1,3 @@ -package org.apache.maven.plugin.jxr.stubs; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -18,37 +16,34 @@ * specific language governing permissions and limitations * under the License. */ - -import org.apache.maven.artifact.Artifact; -import org.apache.maven.plugin.testing.stubs.MavenProjectStub; +package org.apache.maven.plugin.jxr.stubs; import java.util.ArrayList; import java.util.List; +import org.apache.maven.artifact.Artifact; +import org.apache.maven.plugin.testing.stubs.MavenProjectStub; + /** * @author Maria Odea Ching */ -public class AggregateSubmodule1MavenProjectStub - extends MavenProjectStub -{ +public class AggregateSubmodule1MavenProjectStub extends MavenProjectStub { - public AggregateSubmodule1MavenProjectStub() - { - setArtifactId( "aggregate-test-submodule1" ); - setGroupId( "aggregate.test" ); - setVersion( "1.0-SNAPSHOT" ); - setPackaging( "jar" ); - setInceptionYear( "2006" ); + public AggregateSubmodule1MavenProjectStub() { + setArtifactId("aggregate-test-submodule1"); + setGroupId("aggregate.test"); + setVersion("1.0-SNAPSHOT"); + setPackaging("jar"); + setInceptionYear("2006"); String basedir = getBasedir().getAbsolutePath(); List compileSourceRoots = new ArrayList<>(); compileSourceRoots.add( - basedir + "/src/test/resources/unit/aggregate-test/submodule1/aggregate/test/submodule1" ); - setCompileSourceRoots( compileSourceRoots ); + basedir + "/src/test/resources/unit/aggregate-test/submodule1/aggregate/test/submodule1"); + setCompileSourceRoots(compileSourceRoots); - Artifact artifact = new JxrPluginArtifactStub( getGroupId(), getArtifactId(), getVersion(), getPackaging() ); - artifact.setArtifactHandler( new DefaultArtifactHandlerStub() ); - setArtifact( artifact ); + Artifact artifact = new JxrPluginArtifactStub(getGroupId(), getArtifactId(), getVersion(), getPackaging()); + artifact.setArtifactHandler(new DefaultArtifactHandlerStub()); + setArtifact(artifact); } - } diff --git a/maven-jxr-plugin/src/test/java/org/apache/maven/plugin/jxr/stubs/AggregateSubmodule2MavenProjectStub.java b/maven-jxr-plugin/src/test/java/org/apache/maven/plugin/jxr/stubs/AggregateSubmodule2MavenProjectStub.java index 1cd6940f..5560cb01 100644 --- a/maven-jxr-plugin/src/test/java/org/apache/maven/plugin/jxr/stubs/AggregateSubmodule2MavenProjectStub.java +++ b/maven-jxr-plugin/src/test/java/org/apache/maven/plugin/jxr/stubs/AggregateSubmodule2MavenProjectStub.java @@ -1,5 +1,3 @@ -package org.apache.maven.plugin.jxr.stubs; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -18,47 +16,44 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.plugin.jxr.stubs; + +import java.util.ArrayList; +import java.util.List; import org.apache.maven.artifact.Artifact; import org.apache.maven.model.ReportPlugin; import org.apache.maven.plugin.testing.stubs.MavenProjectStub; -import java.util.ArrayList; -import java.util.List; - /** * @author Maria Odea Ching */ -public class AggregateSubmodule2MavenProjectStub - extends MavenProjectStub -{ +public class AggregateSubmodule2MavenProjectStub extends MavenProjectStub { private List reportPlugins = new ArrayList<>(); - public AggregateSubmodule2MavenProjectStub() - { - setArtifactId( "aggregate-test-submodule2" ); - setGroupId( "aggregate.test" ); - setVersion( "1.0-SNAPSHOT" ); - setPackaging( "jar" ); - setInceptionYear( "2006" ); + public AggregateSubmodule2MavenProjectStub() { + setArtifactId("aggregate-test-submodule2"); + setGroupId("aggregate.test"); + setVersion("1.0-SNAPSHOT"); + setPackaging("jar"); + setInceptionYear("2006"); String basedir = getBasedir().getAbsolutePath(); List compileSourceRoots = new ArrayList<>(); compileSourceRoots.add( - basedir + "/src/test/resources/unit/aggregate-test/submodule2/aggregate/test/submodule2" ); - setCompileSourceRoots( compileSourceRoots ); + basedir + "/src/test/resources/unit/aggregate-test/submodule2/aggregate/test/submodule2"); + setCompileSourceRoots(compileSourceRoots); - //set the report plugins + // set the report plugins reportPlugins = new ArrayList<>(); - Artifact artifact = new JxrPluginArtifactStub( getGroupId(), getArtifactId(), getVersion(), getPackaging() ); - artifact.setArtifactHandler( new DefaultArtifactHandlerStub() ); - setArtifact( artifact ); + Artifact artifact = new JxrPluginArtifactStub(getGroupId(), getArtifactId(), getVersion(), getPackaging()); + artifact.setArtifactHandler(new DefaultArtifactHandlerStub()); + setArtifact(artifact); } @Override - public List getReportPlugins() - { + public List getReportPlugins() { return reportPlugins; } } diff --git a/maven-jxr-plugin/src/test/java/org/apache/maven/plugin/jxr/stubs/AggregateTestMavenProjectStub.java b/maven-jxr-plugin/src/test/java/org/apache/maven/plugin/jxr/stubs/AggregateTestMavenProjectStub.java index 057aebb6..572e9c54 100644 --- a/maven-jxr-plugin/src/test/java/org/apache/maven/plugin/jxr/stubs/AggregateTestMavenProjectStub.java +++ b/maven-jxr-plugin/src/test/java/org/apache/maven/plugin/jxr/stubs/AggregateTestMavenProjectStub.java @@ -1,5 +1,3 @@ -package org.apache.maven.plugin.jxr.stubs; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -18,6 +16,11 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.plugin.jxr.stubs; + +import java.io.FileReader; +import java.util.ArrayList; +import java.util.List; import org.apache.maven.artifact.Artifact; import org.apache.maven.model.Model; @@ -25,57 +28,46 @@ import org.apache.maven.model.io.xpp3.MavenXpp3Reader; import org.apache.maven.plugin.testing.stubs.MavenProjectStub; -import java.io.FileReader; -import java.util.ArrayList; -import java.util.List; - /** * @author Maria Odea Ching */ -public class AggregateTestMavenProjectStub - extends MavenProjectStub -{ +public class AggregateTestMavenProjectStub extends MavenProjectStub { private List reportPlugins = new ArrayList<>(); - public AggregateTestMavenProjectStub() - { + public AggregateTestMavenProjectStub() { MavenXpp3Reader pomReader = new MavenXpp3Reader(); Model model = null; - try - { - model = pomReader.read( new FileReader( - getBasedir() + "/src/test/resources/unit/aggregate-test/aggregate-test-plugin-config.xml" ) ); - setModel( model ); - } - catch ( Exception ignored ) - { + try { + model = pomReader.read(new FileReader( + getBasedir() + "/src/test/resources/unit/aggregate-test/aggregate-test-plugin-config.xml")); + setModel(model); + } catch (Exception ignored) { } - setArtifactId( model.getArtifactId() ); - setGroupId( model.getGroupId() ); - setVersion( model.getVersion() ); - setPackaging( model.getPackaging() ); - setInceptionYear( model.getInceptionYear() ); + setArtifactId(model.getArtifactId()); + setGroupId(model.getGroupId()); + setVersion(model.getVersion()); + setPackaging(model.getPackaging()); + setInceptionYear(model.getInceptionYear()); String basedir = getBasedir().getAbsolutePath(); List compileSourceRoots = new ArrayList<>(); - compileSourceRoots.add( basedir + "/src/test/resources/unit/aggregate-test/aggregate/test" ); - setCompileSourceRoots( compileSourceRoots ); + compileSourceRoots.add(basedir + "/src/test/resources/unit/aggregate-test/aggregate/test"); + setCompileSourceRoots(compileSourceRoots); - //set the report plugins - reportPlugins = new ArrayList<>( model.getReporting().getPlugins() ); + // set the report plugins + reportPlugins = new ArrayList<>(model.getReporting().getPlugins()); - Artifact artifact = new JxrPluginArtifactStub( getGroupId(), getArtifactId(), getVersion(), getPackaging() ); - artifact.setArtifactHandler( new DefaultArtifactHandlerStub() ); - setArtifact( artifact ); - setExecutionRoot( true ); + Artifact artifact = new JxrPluginArtifactStub(getGroupId(), getArtifactId(), getVersion(), getPackaging()); + artifact.setArtifactHandler(new DefaultArtifactHandlerStub()); + setArtifact(artifact); + setExecutionRoot(true); } @Override - public List getReportPlugins() - { + public List getReportPlugins() { return reportPlugins; } } diff --git a/maven-jxr-plugin/src/test/java/org/apache/maven/plugin/jxr/stubs/DefaultArtifactHandlerStub.java b/maven-jxr-plugin/src/test/java/org/apache/maven/plugin/jxr/stubs/DefaultArtifactHandlerStub.java index 3b32f552..dff3e3e6 100644 --- a/maven-jxr-plugin/src/test/java/org/apache/maven/plugin/jxr/stubs/DefaultArtifactHandlerStub.java +++ b/maven-jxr-plugin/src/test/java/org/apache/maven/plugin/jxr/stubs/DefaultArtifactHandlerStub.java @@ -1,5 +1,3 @@ -package org.apache.maven.plugin.jxr.stubs; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -18,30 +16,25 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.plugin.jxr.stubs; import org.apache.maven.artifact.handler.DefaultArtifactHandler; /** * @author Maria Odea Ching */ -public class DefaultArtifactHandlerStub - extends DefaultArtifactHandler -{ +public class DefaultArtifactHandlerStub extends DefaultArtifactHandler { private String language; - public String getLanguage() - { - if ( language == null ) - { + public String getLanguage() { + if (language == null) { language = "java"; } return language; } - public void setLanguage( String language ) - { + public void setLanguage(String language) { this.language = language; } - } diff --git a/maven-jxr-plugin/src/test/java/org/apache/maven/plugin/jxr/stubs/DefaultConfigurationMavenProjectStub.java b/maven-jxr-plugin/src/test/java/org/apache/maven/plugin/jxr/stubs/DefaultConfigurationMavenProjectStub.java index 326a7548..d2219483 100644 --- a/maven-jxr-plugin/src/test/java/org/apache/maven/plugin/jxr/stubs/DefaultConfigurationMavenProjectStub.java +++ b/maven-jxr-plugin/src/test/java/org/apache/maven/plugin/jxr/stubs/DefaultConfigurationMavenProjectStub.java @@ -1,5 +1,3 @@ -package org.apache.maven.plugin.jxr.stubs; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -18,6 +16,11 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.plugin.jxr.stubs; + +import java.io.FileReader; +import java.util.ArrayList; +import java.util.List; import org.apache.maven.artifact.Artifact; import org.apache.maven.model.Model; @@ -25,58 +28,45 @@ import org.apache.maven.model.io.xpp3.MavenXpp3Reader; import org.apache.maven.plugin.testing.stubs.MavenProjectStub; -import java.io.FileReader; -import java.util.ArrayList; -import java.util.List; - /** * @author Maria Odea Ching */ -public class DefaultConfigurationMavenProjectStub - extends MavenProjectStub -{ +public class DefaultConfigurationMavenProjectStub extends MavenProjectStub { private List reportPlugins = new ArrayList<>(); - public DefaultConfigurationMavenProjectStub() - { + public DefaultConfigurationMavenProjectStub() { MavenXpp3Reader pomReader = new MavenXpp3Reader(); Model model = null; - try - { - model = pomReader.read( new FileReader( getBasedir() + - "/src/test/resources/unit/default-configuration/default-configuration-plugin-config.xml" ) ); - setModel( model ); - } - catch ( Exception ignored ) - { + try { + model = pomReader.read(new FileReader(getBasedir() + + "/src/test/resources/unit/default-configuration/default-configuration-plugin-config.xml")); + setModel(model); + } catch (Exception ignored) { } - setArtifactId( model.getArtifactId() ); - setGroupId( model.getGroupId() ); - setVersion( model.getVersion() ); - setPackaging( model.getPackaging() ); - setInceptionYear( model.getInceptionYear() ); + setArtifactId(model.getArtifactId()); + setGroupId(model.getGroupId()); + setVersion(model.getVersion()); + setPackaging(model.getPackaging()); + setInceptionYear(model.getInceptionYear()); String basedir = getBasedir().getAbsolutePath(); List compileSourceRoots = new ArrayList<>(); - compileSourceRoots.add( basedir + "/src/test/resources/unit/default-configuration/def/configuration" ); - setCompileSourceRoots( compileSourceRoots ); - - //set the report plugins - reportPlugins = new ArrayList<>( model.getReporting().getPlugins() ); + compileSourceRoots.add(basedir + "/src/test/resources/unit/default-configuration/def/configuration"); + setCompileSourceRoots(compileSourceRoots); - Artifact artifact = new JxrPluginArtifactStub( getGroupId(), getArtifactId(), getVersion(), getPackaging() ); - artifact.setArtifactHandler( new DefaultArtifactHandlerStub() ); - setArtifact( artifact ); + // set the report plugins + reportPlugins = new ArrayList<>(model.getReporting().getPlugins()); + Artifact artifact = new JxrPluginArtifactStub(getGroupId(), getArtifactId(), getVersion(), getPackaging()); + artifact.setArtifactHandler(new DefaultArtifactHandlerStub()); + setArtifact(artifact); } @Override - public List getReportPlugins() - { + public List getReportPlugins() { return reportPlugins; } - } diff --git a/maven-jxr-plugin/src/test/java/org/apache/maven/plugin/jxr/stubs/ExcludeConfigurationMavenProjectStub.java b/maven-jxr-plugin/src/test/java/org/apache/maven/plugin/jxr/stubs/ExcludeConfigurationMavenProjectStub.java index 24c0fa0e..9866204f 100644 --- a/maven-jxr-plugin/src/test/java/org/apache/maven/plugin/jxr/stubs/ExcludeConfigurationMavenProjectStub.java +++ b/maven-jxr-plugin/src/test/java/org/apache/maven/plugin/jxr/stubs/ExcludeConfigurationMavenProjectStub.java @@ -1,5 +1,3 @@ -package org.apache.maven.plugin.jxr.stubs; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -18,63 +16,56 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.plugin.jxr.stubs; + +import java.io.FileReader; +import java.util.ArrayList; +import java.util.List; import org.apache.maven.artifact.Artifact; import org.apache.maven.model.Model; import org.apache.maven.model.ReportPlugin; import org.apache.maven.model.io.xpp3.MavenXpp3Reader; -import java.io.FileReader; -import java.util.ArrayList; -import java.util.List; - /** * @author Dennis Lundberg */ -public class ExcludeConfigurationMavenProjectStub - extends JxrProjectStub -{ +public class ExcludeConfigurationMavenProjectStub extends JxrProjectStub { private List reportPlugins = new ArrayList<>(); - public ExcludeConfigurationMavenProjectStub() - { + public ExcludeConfigurationMavenProjectStub() { MavenXpp3Reader pomReader = new MavenXpp3Reader(); Model model = null; - try - { - model = pomReader.read( new FileReader( getBasedir() + - "/src/test/resources/unit/exclude-configuration/exclude-configuration-plugin-config.xml" ) ); - setModel( model ); - } - catch ( Exception ignored ) - { + try { + model = pomReader.read(new FileReader(getBasedir() + + "/src/test/resources/unit/exclude-configuration/exclude-configuration-plugin-config.xml")); + setModel(model); + } catch (Exception ignored) { } - setArtifactId( model.getArtifactId() ); - setGroupId( model.getGroupId() ); - setVersion( model.getVersion() ); - setPackaging( model.getPackaging() ); - setInceptionYear( model.getInceptionYear() ); + setArtifactId(model.getArtifactId()); + setGroupId(model.getGroupId()); + setVersion(model.getVersion()); + setPackaging(model.getPackaging()); + setInceptionYear(model.getInceptionYear()); String basedir = getBasedir().getAbsolutePath(); List compileSourceRoots = new ArrayList<>(); - compileSourceRoots.add( basedir + "/src/test/resources/unit/exclude-configuration/exclude/configuration" ); - setCompileSourceRoots( compileSourceRoots ); + compileSourceRoots.add(basedir + "/src/test/resources/unit/exclude-configuration/exclude/configuration"); + setCompileSourceRoots(compileSourceRoots); // set the report plugins - reportPlugins = new ArrayList<>( model.getReporting().getPlugins() ); - - Artifact artifact = new JxrPluginArtifactStub( getGroupId(), getArtifactId(), getVersion(), getPackaging() ); - artifact.setArtifactHandler( new DefaultArtifactHandlerStub() ); - setArtifact( artifact ); + reportPlugins = new ArrayList<>(model.getReporting().getPlugins()); + Artifact artifact = new JxrPluginArtifactStub(getGroupId(), getArtifactId(), getVersion(), getPackaging()); + artifact.setArtifactHandler(new DefaultArtifactHandlerStub()); + setArtifact(artifact); } @Override - public List getReportPlugins() - { + public List getReportPlugins() { return reportPlugins; } } diff --git a/maven-jxr-plugin/src/test/java/org/apache/maven/plugin/jxr/stubs/IncludeConfigurationMavenProjectStub.java b/maven-jxr-plugin/src/test/java/org/apache/maven/plugin/jxr/stubs/IncludeConfigurationMavenProjectStub.java index 10a16239..5130359b 100644 --- a/maven-jxr-plugin/src/test/java/org/apache/maven/plugin/jxr/stubs/IncludeConfigurationMavenProjectStub.java +++ b/maven-jxr-plugin/src/test/java/org/apache/maven/plugin/jxr/stubs/IncludeConfigurationMavenProjectStub.java @@ -1,5 +1,3 @@ -package org.apache.maven.plugin.jxr.stubs; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -18,64 +16,56 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.plugin.jxr.stubs; + +import java.io.FileReader; +import java.util.ArrayList; +import java.util.List; import org.apache.maven.artifact.Artifact; import org.apache.maven.model.Model; import org.apache.maven.model.ReportPlugin; import org.apache.maven.model.io.xpp3.MavenXpp3Reader; -import java.io.FileReader; -import java.util.ArrayList; -import java.util.List; - /** * @author Dennis Lundberg */ -public class IncludeConfigurationMavenProjectStub - extends JxrProjectStub -{ +public class IncludeConfigurationMavenProjectStub extends JxrProjectStub { private List reportPlugins = new ArrayList<>(); - public IncludeConfigurationMavenProjectStub() - { + public IncludeConfigurationMavenProjectStub() { MavenXpp3Reader pomReader = new MavenXpp3Reader(); Model model = null; - try - { - model = pomReader.read( new FileReader( getBasedir() + - "/src/test/resources/unit/include-configuration/include-configuration-plugin-config.xml" ) ); - setModel( model ); - } - catch ( Exception ignored ) - { + try { + model = pomReader.read(new FileReader(getBasedir() + + "/src/test/resources/unit/include-configuration/include-configuration-plugin-config.xml")); + setModel(model); + } catch (Exception ignored) { } - setArtifactId( model.getArtifactId() ); - setGroupId( model.getGroupId() ); - setVersion( model.getVersion() ); - setPackaging( model.getPackaging() ); - setInceptionYear( model.getInceptionYear() ); + setArtifactId(model.getArtifactId()); + setGroupId(model.getGroupId()); + setVersion(model.getVersion()); + setPackaging(model.getPackaging()); + setInceptionYear(model.getInceptionYear()); String basedir = getBasedir().getAbsolutePath(); List compileSourceRoots = new ArrayList<>(); - compileSourceRoots.add( - basedir + "/src/test/resources/unit/include-configuration/include/configuration" ); - setCompileSourceRoots( compileSourceRoots ); + compileSourceRoots.add(basedir + "/src/test/resources/unit/include-configuration/include/configuration"); + setCompileSourceRoots(compileSourceRoots); // set the report plugins - reportPlugins = new ArrayList<>( model.getReporting().getPlugins() ); - - Artifact artifact = new JxrPluginArtifactStub( getGroupId(), getArtifactId(), getVersion(), getPackaging() ); - artifact.setArtifactHandler( new DefaultArtifactHandlerStub() ); - setArtifact( artifact ); + reportPlugins = new ArrayList<>(model.getReporting().getPlugins()); + Artifact artifact = new JxrPluginArtifactStub(getGroupId(), getArtifactId(), getVersion(), getPackaging()); + artifact.setArtifactHandler(new DefaultArtifactHandlerStub()); + setArtifact(artifact); } @Override - public List getReportPlugins() - { + public List getReportPlugins() { return reportPlugins; } } diff --git a/maven-jxr-plugin/src/test/java/org/apache/maven/plugin/jxr/stubs/JxrPluginArtifactStub.java b/maven-jxr-plugin/src/test/java/org/apache/maven/plugin/jxr/stubs/JxrPluginArtifactStub.java index fe4be3ed..7ecb7d4b 100644 --- a/maven-jxr-plugin/src/test/java/org/apache/maven/plugin/jxr/stubs/JxrPluginArtifactStub.java +++ b/maven-jxr-plugin/src/test/java/org/apache/maven/plugin/jxr/stubs/JxrPluginArtifactStub.java @@ -1,5 +1,3 @@ -package org.apache.maven.plugin.jxr.stubs; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.plugin.jxr.stubs; import org.apache.maven.artifact.handler.ArtifactHandler; import org.apache.maven.artifact.versioning.VersionRange; @@ -26,9 +25,7 @@ /** * @author Maria Odea Ching */ -public class JxrPluginArtifactStub - extends ArtifactStub -{ +public class JxrPluginArtifactStub extends ArtifactStub { private String groupId; @@ -42,72 +39,59 @@ public class JxrPluginArtifactStub private ArtifactHandler handler; - public JxrPluginArtifactStub( String groupId, String artifactId, String version, String packaging ) - { + public JxrPluginArtifactStub(String groupId, String artifactId, String version, String packaging) { this.groupId = groupId; this.artifactId = artifactId; this.version = version; this.packaging = packaging; - versionRange = VersionRange.createFromVersion( version ); + versionRange = VersionRange.createFromVersion(version); } - public void setGroupId( String groupId ) - { + public void setGroupId(String groupId) { this.groupId = groupId; } - public String getGroupId() - { + public String getGroupId() { return groupId; } - public void setArtifactId( String artifactId ) - { + public void setArtifactId(String artifactId) { this.artifactId = artifactId; } - public String getArtifactId() - { + public String getArtifactId() { return artifactId; } - public void setVersion( String version ) - { + public void setVersion(String version) { this.version = version; } - public String getVersion() - { + public String getVersion() { return version; } - public void setPackaging( String packaging ) - { + public void setPackaging(String packaging) { this.packaging = packaging; } - public String getPackaging() - { + public String getPackaging() { return packaging; } - public VersionRange getVersionRange() - { + public VersionRange getVersionRange() { return versionRange; } - public void setVersionRange( VersionRange versionRange ) - { + public void setVersionRange(VersionRange versionRange) { this.versionRange = versionRange; } - public ArtifactHandler getArtifactHandler() - { + public ArtifactHandler getArtifactHandler() { return handler; } - public void setArtifactHandler( ArtifactHandler handler ) - { + public void setArtifactHandler(ArtifactHandler handler) { this.handler = handler; } } diff --git a/maven-jxr-plugin/src/test/java/org/apache/maven/plugin/jxr/stubs/JxrProjectStub.java b/maven-jxr-plugin/src/test/java/org/apache/maven/plugin/jxr/stubs/JxrProjectStub.java index 45f4b5f7..12bf7d4c 100644 --- a/maven-jxr-plugin/src/test/java/org/apache/maven/plugin/jxr/stubs/JxrProjectStub.java +++ b/maven-jxr-plugin/src/test/java/org/apache/maven/plugin/jxr/stubs/JxrProjectStub.java @@ -1,5 +1,3 @@ -package org.apache.maven.plugin.jxr.stubs; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "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 + * 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 @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.plugin.jxr.stubs; import java.util.Collections; import java.util.List; @@ -28,15 +27,16 @@ import org.apache.maven.artifact.repository.layout.DefaultRepositoryLayout; import org.apache.maven.plugin.testing.stubs.MavenProjectStub; -public abstract class JxrProjectStub - extends MavenProjectStub -{ +public abstract class JxrProjectStub extends MavenProjectStub { @Override - public List getRemoteArtifactRepositories() - { - ArtifactRepository repository = new MavenArtifactRepository( "central", "https://repo1.maven.org/maven2", - new DefaultRepositoryLayout(), new ArtifactRepositoryPolicy(), new ArtifactRepositoryPolicy() ); + public List getRemoteArtifactRepositories() { + ArtifactRepository repository = new MavenArtifactRepository( + "central", + "https://repo1.maven.org/maven2", + new DefaultRepositoryLayout(), + new ArtifactRepositoryPolicy(), + new ArtifactRepositoryPolicy()); - return Collections.singletonList( repository ); + return Collections.singletonList(repository); } } diff --git a/maven-jxr-plugin/src/test/java/org/apache/maven/plugin/jxr/stubs/NoJavadocDirMavenProjectStub.java b/maven-jxr-plugin/src/test/java/org/apache/maven/plugin/jxr/stubs/NoJavadocDirMavenProjectStub.java index 0448f953..1e1368b4 100644 --- a/maven-jxr-plugin/src/test/java/org/apache/maven/plugin/jxr/stubs/NoJavadocDirMavenProjectStub.java +++ b/maven-jxr-plugin/src/test/java/org/apache/maven/plugin/jxr/stubs/NoJavadocDirMavenProjectStub.java @@ -1,5 +1,3 @@ -package org.apache.maven.plugin.jxr.stubs; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -18,63 +16,56 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.plugin.jxr.stubs; + +import java.io.FileReader; +import java.util.ArrayList; +import java.util.List; import org.apache.maven.artifact.Artifact; import org.apache.maven.model.Model; import org.apache.maven.model.ReportPlugin; import org.apache.maven.model.io.xpp3.MavenXpp3Reader; -import org.apache.maven.plugin.testing.stubs.MavenProjectStub; - -import java.io.FileReader; -import java.util.ArrayList; -import java.util.List; /** * @author Maria Odea Ching */ -public class NoJavadocDirMavenProjectStub - extends JxrProjectStub -{ +public class NoJavadocDirMavenProjectStub extends JxrProjectStub { private List reportPlugins; - public NoJavadocDirMavenProjectStub() - { + public NoJavadocDirMavenProjectStub() { MavenXpp3Reader pomReader = new MavenXpp3Reader(); Model model = null; - try - { - model = pomReader.read( new FileReader( - getBasedir() + "/src/test/resources/unit/nojavadocdir-test/nojavadocdir-test-plugin-config.xml" ) ); - setModel( model ); - } - catch ( Exception ignored ) - { + try { + model = pomReader.read(new FileReader( + getBasedir() + "/src/test/resources/unit/nojavadocdir-test/nojavadocdir-test-plugin-config.xml")); + setModel(model); + } catch (Exception ignored) { } - setArtifactId( model.getArtifactId() ); - setGroupId( model.getGroupId() ); - setVersion( model.getVersion() ); - setPackaging( model.getPackaging() ); - setInceptionYear( model.getInceptionYear() ); + setArtifactId(model.getArtifactId()); + setGroupId(model.getGroupId()); + setVersion(model.getVersion()); + setPackaging(model.getPackaging()); + setInceptionYear(model.getInceptionYear()); String basedir = getBasedir().getAbsolutePath(); List compileSourceRoots = new ArrayList<>(); - compileSourceRoots.add( basedir + "/src/test/resources/unit/nojavadocdir-test/nojavadocdir/test" ); - setCompileSourceRoots( compileSourceRoots ); + compileSourceRoots.add(basedir + "/src/test/resources/unit/nojavadocdir-test/nojavadocdir/test"); + setCompileSourceRoots(compileSourceRoots); - //set the report plugins - reportPlugins = new ArrayList<>( model.getReporting().getPlugins() ); + // set the report plugins + reportPlugins = new ArrayList<>(model.getReporting().getPlugins()); - Artifact artifact = new JxrPluginArtifactStub( getGroupId(), getArtifactId(), getVersion(), getPackaging() ); - artifact.setArtifactHandler( new DefaultArtifactHandlerStub() ); - setArtifact( artifact ); + Artifact artifact = new JxrPluginArtifactStub(getGroupId(), getArtifactId(), getVersion(), getPackaging()); + artifact.setArtifactHandler(new DefaultArtifactHandlerStub()); + setArtifact(artifact); } @Override - public List getReportPlugins() - { + public List getReportPlugins() { return reportPlugins; } } diff --git a/maven-jxr-plugin/src/test/java/org/apache/maven/plugin/jxr/stubs/NoJavadocLinkConfigurationMavenProjectStub.java b/maven-jxr-plugin/src/test/java/org/apache/maven/plugin/jxr/stubs/NoJavadocLinkConfigurationMavenProjectStub.java index 47df0672..342d8d64 100644 --- a/maven-jxr-plugin/src/test/java/org/apache/maven/plugin/jxr/stubs/NoJavadocLinkConfigurationMavenProjectStub.java +++ b/maven-jxr-plugin/src/test/java/org/apache/maven/plugin/jxr/stubs/NoJavadocLinkConfigurationMavenProjectStub.java @@ -1,5 +1,3 @@ -package org.apache.maven.plugin.jxr.stubs; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -18,6 +16,11 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.plugin.jxr.stubs; + +import java.io.FileReader; +import java.util.ArrayList; +import java.util.List; import org.apache.maven.artifact.Artifact; import org.apache.maven.model.Model; @@ -25,59 +28,48 @@ import org.apache.maven.model.io.xpp3.MavenXpp3Reader; import org.apache.maven.plugin.testing.stubs.MavenProjectStub; -import java.io.File; -import java.io.FileReader; -import java.util.ArrayList; -import java.util.List; - /** * @author Maria Odea Ching */ -public class NoJavadocLinkConfigurationMavenProjectStub - extends MavenProjectStub -{ +public class NoJavadocLinkConfigurationMavenProjectStub extends MavenProjectStub { List reportPlugins; - public NoJavadocLinkConfigurationMavenProjectStub() - { + public NoJavadocLinkConfigurationMavenProjectStub() { MavenXpp3Reader pomReader = new MavenXpp3Reader(); Model model = null; - try - { - model = pomReader.read( new FileReader( getBasedir() + - "/src/test/resources/unit/nojavadoclink-configuration/nojavadoclink-configuration-plugin-config.xml" ) ); - setModel( model ); - } - catch ( Exception ignored ) - { + try { + model = pomReader.read( + new FileReader( + getBasedir() + + "/src/test/resources/unit/nojavadoclink-configuration/nojavadoclink-configuration-plugin-config.xml")); + setModel(model); + } catch (Exception ignored) { } - setArtifactId( model.getArtifactId() ); - setGroupId( model.getGroupId() ); - setVersion( model.getVersion() ); - setPackaging( model.getPackaging() ); - setInceptionYear( model.getInceptionYear() ); + setArtifactId(model.getArtifactId()); + setGroupId(model.getGroupId()); + setVersion(model.getVersion()); + setPackaging(model.getPackaging()); + setInceptionYear(model.getInceptionYear()); String basedir = getBasedir().getAbsolutePath(); List compileSourceRoots = new ArrayList<>(); compileSourceRoots.add( - basedir + "/src/test/resources/unit/nojavadoclink-configuration/nojavadoclink/configuration" ); - setCompileSourceRoots( compileSourceRoots ); - - //set the report plugins - reportPlugins = new ArrayList<>( model.getReporting().getPlugins() ); + basedir + "/src/test/resources/unit/nojavadoclink-configuration/nojavadoclink/configuration"); + setCompileSourceRoots(compileSourceRoots); - Artifact artifact = new JxrPluginArtifactStub( getGroupId(), getArtifactId(), getVersion(), getPackaging() ); - artifact.setArtifactHandler( new DefaultArtifactHandlerStub() ); - setArtifact( artifact ); + // set the report plugins + reportPlugins = new ArrayList<>(model.getReporting().getPlugins()); + Artifact artifact = new JxrPluginArtifactStub(getGroupId(), getArtifactId(), getVersion(), getPackaging()); + artifact.setArtifactHandler(new DefaultArtifactHandlerStub()); + setArtifact(artifact); } @Override - public List getReportPlugins() - { + public List getReportPlugins() { return reportPlugins; } } diff --git a/maven-jxr-plugin/src/test/java/org/apache/maven/plugin/jxr/stubs/PomMavenProjectStub.java b/maven-jxr-plugin/src/test/java/org/apache/maven/plugin/jxr/stubs/PomMavenProjectStub.java index ba9aee72..cadb456d 100644 --- a/maven-jxr-plugin/src/test/java/org/apache/maven/plugin/jxr/stubs/PomMavenProjectStub.java +++ b/maven-jxr-plugin/src/test/java/org/apache/maven/plugin/jxr/stubs/PomMavenProjectStub.java @@ -1,5 +1,3 @@ -package org.apache.maven.plugin.jxr.stubs; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ * "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 + * 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 @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.plugin.jxr.stubs; import java.io.File; import java.io.FileReader; @@ -32,72 +31,63 @@ /** * @author Vincent Siveton */ -public class PomMavenProjectStub - extends MavenProjectStub -{ +public class PomMavenProjectStub extends MavenProjectStub { private Build build; - public PomMavenProjectStub() - { + public PomMavenProjectStub() { MavenXpp3Reader pomReader = new MavenXpp3Reader(); Model model; - try - { - model = pomReader.read( new FileReader( new File( getBasedir(), "pom-test-plugin-config.xml" ) ) ); - setModel( model ); - } - catch ( Exception e ) - { - throw new RuntimeException( e ); + try { + model = pomReader.read(new FileReader(new File(getBasedir(), "pom-test-plugin-config.xml"))); + setModel(model); + } catch (Exception e) { + throw new RuntimeException(e); } - setGroupId( model.getGroupId() ); - setArtifactId( model.getArtifactId() ); - setVersion( model.getVersion() ); - setName( model.getName() ); - setUrl( model.getUrl() ); - setPackaging( model.getPackaging() ); + setGroupId(model.getGroupId()); + setArtifactId(model.getArtifactId()); + setVersion(model.getVersion()); + setName(model.getName()); + setUrl(model.getUrl()); + setPackaging(model.getPackaging()); Build build = new Build(); - build.setFinalName( model.getArtifactId() ); - build.setDirectory( super.getBasedir() + "/target/test/unit/pom-test/target" ); - build.setSourceDirectory( getBasedir() + "/src/main/java" ); - build.setOutputDirectory( super.getBasedir() + "/target/test/unit/pom-test/target/classes" ); - build.setTestSourceDirectory( getBasedir() + "/src/test/java" ); - build.setTestOutputDirectory( super.getBasedir() + "/target/test/unit/pom-test/target/test-classes" ); - setBuild( build ); + build.setFinalName(model.getArtifactId()); + build.setDirectory(super.getBasedir() + "/target/test/unit/pom-test/target"); + build.setSourceDirectory(getBasedir() + "/src/main/java"); + build.setOutputDirectory(super.getBasedir() + "/target/test/unit/pom-test/target/classes"); + build.setTestSourceDirectory(getBasedir() + "/src/test/java"); + build.setTestOutputDirectory(super.getBasedir() + "/target/test/unit/pom-test/target/test-classes"); + setBuild(build); List compileSourceRoots = new ArrayList<>(); - compileSourceRoots.add( getBasedir() + "/src/main/java" ); - setCompileSourceRoots( compileSourceRoots ); + compileSourceRoots.add(getBasedir() + "/src/main/java"); + setCompileSourceRoots(compileSourceRoots); List testCompileSourceRoots = new ArrayList<>(); - testCompileSourceRoots.add( getBasedir() + "/src/test/java" ); - setTestCompileSourceRoots( testCompileSourceRoots ); + testCompileSourceRoots.add(getBasedir() + "/src/test/java"); + setTestCompileSourceRoots(testCompileSourceRoots); } /** * @see org.apache.maven.plugin.testing.stubs.MavenProjectStub#getBuild() */ - public Build getBuild() - { + public Build getBuild() { return build; } /** * @see org.apache.maven.plugin.testing.stubs.MavenProjectStub#setBuild(org.apache.maven.model.Build) */ - public void setBuild( Build build ) - { + public void setBuild(Build build) { this.build = build; } /** * @see org.apache.maven.plugin.testing.stubs.MavenProjectStub#getBasedir() */ - public File getBasedir() - { - return new File( super.getBasedir() + "/src/test/resources/unit/pom-test" ); + public File getBasedir() { + return new File(super.getBasedir() + "/src/test/resources/unit/pom-test"); } } diff --git a/maven-jxr-plugin/src/test/java/org/apache/maven/plugin/jxr/stubs/TestSourceDirMavenProjectStub.java b/maven-jxr-plugin/src/test/java/org/apache/maven/plugin/jxr/stubs/TestSourceDirMavenProjectStub.java index b4412851..a286b607 100644 --- a/maven-jxr-plugin/src/test/java/org/apache/maven/plugin/jxr/stubs/TestSourceDirMavenProjectStub.java +++ b/maven-jxr-plugin/src/test/java/org/apache/maven/plugin/jxr/stubs/TestSourceDirMavenProjectStub.java @@ -1,5 +1,3 @@ -package org.apache.maven.plugin.jxr.stubs; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -18,53 +16,46 @@ * specific language governing permissions and limitations * under the License. */ - -import org.apache.maven.artifact.Artifact; -import org.apache.maven.model.Model; -import org.apache.maven.model.io.xpp3.MavenXpp3Reader; +package org.apache.maven.plugin.jxr.stubs; import java.io.FileReader; import java.util.ArrayList; import java.util.List; +import org.apache.maven.artifact.Artifact; +import org.apache.maven.model.Model; +import org.apache.maven.model.io.xpp3.MavenXpp3Reader; + /** * @author Maria Odea Ching */ -public class TestSourceDirMavenProjectStub - extends JxrProjectStub -{ +public class TestSourceDirMavenProjectStub extends JxrProjectStub { - public TestSourceDirMavenProjectStub() - { + public TestSourceDirMavenProjectStub() { MavenXpp3Reader pomReader = new MavenXpp3Reader(); Model model = null; - try - { - model = pomReader.read( new FileReader( - getBasedir() + "/src/test/resources/unit/testsourcedir-test/testsourcedir-test-plugin-config.xml" ) ); - setModel( model ); - } - catch ( Exception ignored ) - { + try { + model = pomReader.read(new FileReader( + getBasedir() + "/src/test/resources/unit/testsourcedir-test/testsourcedir-test-plugin-config.xml")); + setModel(model); + } catch (Exception ignored) { } - setArtifactId( model.getArtifactId() ); - setGroupId( model.getGroupId() ); - setVersion( model.getVersion() ); - setPackaging( model.getPackaging() ); - setInceptionYear( model.getInceptionYear() ); + setArtifactId(model.getArtifactId()); + setGroupId(model.getGroupId()); + setVersion(model.getVersion()); + setPackaging(model.getPackaging()); + setInceptionYear(model.getInceptionYear()); String basedir = getBasedir().getAbsolutePath(); List compileSourceRoots = new ArrayList<>(); - compileSourceRoots.add( basedir + "/src/test/resources/unit/testsourcedir-test" ); - setCompileSourceRoots( compileSourceRoots ); - - Artifact artifact = new JxrPluginArtifactStub( getGroupId(), getArtifactId(), getVersion(), getPackaging() ); - artifact.setArtifactHandler( new DefaultArtifactHandlerStub() ); - setArtifact( artifact ); + compileSourceRoots.add(basedir + "/src/test/resources/unit/testsourcedir-test"); + setCompileSourceRoots(compileSourceRoots); + Artifact artifact = new JxrPluginArtifactStub(getGroupId(), getArtifactId(), getVersion(), getPackaging()); + artifact.setArtifactHandler(new DefaultArtifactHandlerStub()); + setArtifact(artifact); } - } diff --git a/maven-jxr/pom.xml b/maven-jxr/pom.xml index 06a921bc..331a20c0 100644 --- a/maven-jxr/pom.xml +++ b/maven-jxr/pom.xml @@ -1,5 +1,4 @@ - - 4.0.0 @@ -33,6 +31,33 @@ under the License. Maven JXR + + + org.codehaus.plexus + plexus-utils + + + org.slf4j + slf4j-api + + + org.apache.velocity + velocity + 1.7 + + + + junit + junit + test + + + org.slf4j + slf4j-simple + test + + + @@ -71,37 +96,10 @@ under the License. - - org.eclipse.sisu - sisu-maven-plugin - + + org.eclipse.sisu + sisu-maven-plugin + - - - - org.codehaus.plexus - plexus-utils - - - org.slf4j - slf4j-api - - - org.apache.velocity - velocity - 1.7 - - - - junit - junit - test - - - org.slf4j - slf4j-simple - test - - diff --git a/maven-jxr/src/main/java/org/apache/maven/jxr/DirectoryIndexer.java b/maven-jxr/src/main/java/org/apache/maven/jxr/DirectoryIndexer.java index ea2710ec..fa25b9ef 100644 --- a/maven-jxr/src/main/java/org/apache/maven/jxr/DirectoryIndexer.java +++ b/maven-jxr/src/main/java/org/apache/maven/jxr/DirectoryIndexer.java @@ -1,5 +1,3 @@ -package org.apache.maven.jxr; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.jxr; import java.io.File; import java.io.FileOutputStream; @@ -58,8 +57,7 @@ * @author Fabrice Bellingard * @author Brian Leonard */ -public class DirectoryIndexer -{ +public class DirectoryIndexer { /* * JavaCodeTransform uses this to cross-reference package references * with that package's main summary page. @@ -95,8 +93,7 @@ public class DirectoryIndexer * @param packageManager PackageManager for this project * @param root Path of the root output directory */ - public DirectoryIndexer( PackageManager packageManager, String root ) - { + public DirectoryIndexer(PackageManager packageManager, String root) { this.packageManager = packageManager; this.root = root; } @@ -106,8 +103,7 @@ public DirectoryIndexer( PackageManager packageManager, String root ) * * @param outputEncoding output encoding */ - public void setOutputEncoding( String outputEncoding ) - { + public void setOutputEncoding(String outputEncoding) { this.outputEncoding = outputEncoding; } @@ -115,8 +111,7 @@ public void setOutputEncoding( String outputEncoding ) * Gets the output encoding. * @return output encoding */ - public String getOutputEncoding() - { + public String getOutputEncoding() { return outputEncoding; } @@ -126,8 +121,7 @@ public String getOutputEncoding() * * @param templateDir location of the template directory */ - public void setTemplateDir( String templateDir ) - { + public void setTemplateDir(String templateDir) { this.templateDir = templateDir; } @@ -136,8 +130,7 @@ public void setTemplateDir( String templateDir ) * * @return location of the template directory */ - public String getTemplateDir() - { + public String getTemplateDir() { return templateDir; } @@ -147,8 +140,7 @@ public String getTemplateDir() * * @param windowTitle the <title> attribute */ - public void setWindowTitle( String windowTitle ) - { + public void setWindowTitle(String windowTitle) { this.windowTitle = windowTitle; } @@ -157,8 +149,7 @@ public void setWindowTitle( String windowTitle ) * * @return window title */ - public String getWindowTitle() - { + public String getWindowTitle() { return windowTitle; } @@ -168,8 +159,7 @@ public String getWindowTitle() * * @param docTitle major page heading */ - public void setDocTitle( String docTitle ) - { + public void setDocTitle(String docTitle) { this.docTitle = docTitle; } @@ -178,8 +168,7 @@ public void setDocTitle( String docTitle ) * * @return major page heading */ - public String getDocTitle() - { + public String getDocTitle() { return docTitle; } @@ -189,8 +178,7 @@ public String getDocTitle() * * @param bottom page footer */ - public void setBottom( String bottom ) - { + public void setBottom(String bottom) { this.bottom = bottom; } @@ -199,8 +187,7 @@ public void setBottom( String bottom ) * * @return bottom page footer */ - public String getBottom() - { + public String getBottom() { return bottom; } @@ -209,104 +196,90 @@ public String getBottom() * * @throws JxrException If something went wrong */ - public void process() - throws JxrException - { + public void process() throws JxrException { ProjectInfo info = getProjectInfo(); VelocityEngine engine = new VelocityEngine(); - setProperties( engine ); - try - { + setProperties(engine); + try { engine.init(); - } - catch ( Exception e ) - { - throw new JxrException( "Error initializing Velocity", e ); + } catch (Exception e) { + throw new JxrException("Error initializing Velocity", e); } VelocityContext context = new VelocityContext(); - context.put( "outputEncoding", getOutputEncoding() ); - context.put( "windowTitle", getWindowTitle() ); - context.put( "docTitle", getDocTitle() ); - context.put( "bottom", getBottom() ); - context.put( "info", info ); - - doVelocity( "index", root, context, engine ); - doVelocity( "overview-frame", root, context, engine ); - doVelocity( "allclasses-frame", root, context, engine ); - doVelocity( "overview-summary", root, context, engine ); - - for ( PackageInfo pkgInfo : info.getAllPackages().values() ) - { - VelocityContext subContext = new VelocityContext( context ); - subContext.put( "pkgInfo", pkgInfo ); + context.put("outputEncoding", getOutputEncoding()); + context.put("windowTitle", getWindowTitle()); + context.put("docTitle", getDocTitle()); + context.put("bottom", getBottom()); + context.put("info", info); + + doVelocity("index", root, context, engine); + doVelocity("overview-frame", root, context, engine); + doVelocity("allclasses-frame", root, context, engine); + doVelocity("overview-summary", root, context, engine); + + for (PackageInfo pkgInfo : info.getAllPackages().values()) { + VelocityContext subContext = new VelocityContext(context); + subContext.put("pkgInfo", pkgInfo); String outDir = root + '/' + pkgInfo.getDir(); - doVelocity( "package-summary", outDir, subContext, engine ); - doVelocity( "package-frame", outDir, subContext, engine ); + doVelocity("package-summary", outDir, subContext, engine); + doVelocity("package-frame", outDir, subContext, engine); } } /* * Sets Velocity properties to find templates. */ - private void setProperties( VelocityEngine engine ) - { - Path templateDirFile = Paths.get( getTemplateDir() ); - if ( templateDirFile.isAbsolute() ) - { + private void setProperties(VelocityEngine engine) { + Path templateDirFile = Paths.get(getTemplateDir()); + if (templateDirFile.isAbsolute()) { // the property has been overridden: need to use a FileResourceLoader - engine.setProperty( "resource.loader", "file" ); - engine.setProperty( "file.resource.loader.class", - "org.apache.velocity.runtime.resource.loader.FileResourceLoader" ); - engine.setProperty( "file.resource.loader.path", templateDirFile.toString() ); - } - else - { + engine.setProperty("resource.loader", "file"); + engine.setProperty( + "file.resource.loader.class", "org.apache.velocity.runtime.resource.loader.FileResourceLoader"); + engine.setProperty("file.resource.loader.path", templateDirFile.toString()); + } else { // use of the default templates - engine.setProperty( "resource.loader", "classpath" ); - engine.setProperty( "classpath.resource.loader.class", - "org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader" ); + engine.setProperty("resource.loader", "classpath"); + engine.setProperty( + "classpath.resource.loader.class", + "org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader"); } // avoid "unable to find resource 'VM_global_library.vm' in any resource loader." - engine.setProperty( "velocimacro.library", "" ); -// engine.setProperty( Log.class.getName(), log ); -// engine.setProperty( "runtime.log.logsystem.class", VelocityLogger.class.getName() ); + engine.setProperty("velocimacro.library", ""); + // engine.setProperty( Log.class.getName(), log ); + // engine.setProperty( "runtime.log.logsystem.class", VelocityLogger.class.getName() ); } /* * Generate the HTML file according to the Velocity template */ - private void doVelocity( String templateName, String outDir, VelocityContext context, VelocityEngine engine ) - throws JxrException - { + private void doVelocity(String templateName, String outDir, VelocityContext context, VelocityEngine engine) + throws JxrException { // output file - File file = new File( outDir, templateName + ".html" ); + File file = new File(outDir, templateName + ".html"); file.getParentFile().mkdirs(); - try ( Writer writer = new OutputStreamWriter( new FileOutputStream( file ), getOutputEncoding() ) ) - { + try (Writer writer = new OutputStreamWriter(new FileOutputStream(file), getOutputEncoding())) { // template file StringBuilder templateFile = new StringBuilder(); - File templateDirFile = new File( getTemplateDir() ); - if ( !templateDirFile.isAbsolute() ) - { + File templateDirFile = new File(getTemplateDir()); + if (!templateDirFile.isAbsolute()) { // default templates - templateFile.append( getTemplateDir() ); - templateFile.append( '/' ); + templateFile.append(getTemplateDir()); + templateFile.append('/'); } - templateFile.append( templateName ); - templateFile.append( ".vm" ); - Template template = engine.getTemplate( templateFile.toString() ); + templateFile.append(templateName); + templateFile.append(".vm"); + Template template = engine.getTemplate(templateFile.toString()); // do the merge - template.merge( context, writer ); + template.merge(context, writer); writer.flush(); - } - catch ( Exception e ) - { - throw new JxrException( "Error merging velocity template", e ); + } catch (Exception e) { + throw new JxrException("Error merging velocity template", e); } } @@ -325,50 +298,46 @@ private void doVelocity( String templateName, String outDir, VelocityContext con * allClasses collection of Maps with class info, format as above * */ - ProjectInfo getProjectInfo() - { + ProjectInfo getProjectInfo() { Map allPackages = new TreeMap<>(); Map allClasses = new TreeMap<>(); - for ( PackageType pkg : packageManager.getPackageTypes() ) - { + for (PackageType pkg : packageManager.getPackageTypes()) { String pkgName = pkg.getName(); - String pkgDir = pkgName.replace( '.', '/' ); - String rootRef = pkgName.replaceAll( "[^\\.]+(\\.|$)", "../" ); + String pkgDir = pkgName.replace('.', '/'); + String rootRef = pkgName.replaceAll("[^\\.]+(\\.|$)", "../"); // special case for the default package // javadoc doesn't deal with it, but it's easy for us - if ( pkgName.length() == 0 ) - { + if (pkgName.length() == 0) { pkgName = "(default package)"; pkgDir = "."; rootRef = "./"; } Map pkgClasses = new TreeMap<>(); - for ( ClassType clazz : pkg.getClassTypes() ) - { + for (ClassType clazz : pkg.getClassTypes()) { String className = clazz.getName(); - ClassInfo classInfo = new ClassInfo( className, pkgDir ); + ClassInfo classInfo = new ClassInfo(className, pkgDir); - classInfo.setFilename( clazz.getFilename() ); + classInfo.setFilename(clazz.getFilename()); - pkgClasses.put( className, classInfo ); + pkgClasses.put(className, classInfo); // Adding package name to key in order to ensure classes with identical names in different packages are // all included. - allClasses.put( className + "#" + pkgName, classInfo ); + allClasses.put(className + "#" + pkgName, classInfo); } - PackageInfo pkgInfo = new PackageInfo( pkgName, pkgDir ); - pkgInfo.setClasses( pkgClasses ); - pkgInfo.setRootRef( rootRef ); + PackageInfo pkgInfo = new PackageInfo(pkgName, pkgDir); + pkgInfo.setClasses(pkgClasses); + pkgInfo.setRootRef(rootRef); - allPackages.put( pkgName, pkgInfo ); + allPackages.put(pkgName, pkgInfo); } - return new ProjectInfo( allPackages, allClasses ); + return new ProjectInfo(allPackages, allClasses); } /** @@ -376,25 +345,21 @@ ProjectInfo getProjectInfo() * @author Robert Scholte * @since 3.2.0 */ - public static class ProjectInfo - { + public static class ProjectInfo { private final Map allPackages; private final Map allClasses; - public ProjectInfo( Map allPackages, Map allClasses ) - { + public ProjectInfo(Map allPackages, Map allClasses) { this.allPackages = allPackages; this.allClasses = allClasses; } - public Map getAllPackages() - { + public Map getAllPackages() { return allPackages; } - public Map getAllClasses() - { + public Map getAllClasses() { return allClasses; } } @@ -404,8 +369,7 @@ public Map getAllClasses() * @author Robert Scholte * @since 3.2.0 */ - public static class PackageInfo - { + public static class PackageInfo { private final String name; private final String dir; @@ -414,39 +378,32 @@ public static class PackageInfo private String rootRef; - public PackageInfo( String name, String dir ) - { + public PackageInfo(String name, String dir) { this.name = name; this.dir = dir; } - public String getName() - { + public String getName() { return name; } - public String getDir() - { + public String getDir() { return dir; } - public void setClasses( Map classes ) - { + public void setClasses(Map classes) { this.classes = classes; } - public Map getClasses() - { + public Map getClasses() { return classes; } - public void setRootRef( String rootRef ) - { + public void setRootRef(String rootRef) { this.rootRef = rootRef; } - public String getRootRef() - { + public String getRootRef() { return rootRef; } } @@ -457,38 +414,32 @@ public String getRootRef() * @author Robert Scholte * @since 3.2.0 */ - public static class ClassInfo - { + public static class ClassInfo { private final String name; private final String dir; private String filename; - public ClassInfo( String name, String dir ) - { + public ClassInfo(String name, String dir) { super(); this.name = name; this.dir = dir; } - public String getName() - { + public String getName() { return name; } - public String getDir() - { + public String getDir() { return dir; } - public void setFilename( String filename ) - { + public void setFilename(String filename) { this.filename = filename; } - public String getFilename() - { + public String getFilename() { return filename; } } diff --git a/maven-jxr/src/main/java/org/apache/maven/jxr/JXR.java b/maven-jxr/src/main/java/org/apache/maven/jxr/JXR.java index ac13f860..2c9beb35 100644 --- a/maven-jxr/src/main/java/org/apache/maven/jxr/JXR.java +++ b/maven-jxr/src/main/java/org/apache/maven/jxr/JXR.java @@ -1,5 +1,3 @@ -package org.apache.maven.jxr; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -18,11 +16,7 @@ * specific language governing permissions and limitations * under the License. */ - -import org.apache.maven.jxr.ant.DirectoryScanner; -import org.apache.maven.jxr.pacman.PackageManager; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +package org.apache.maven.jxr; import java.io.IOException; import java.nio.file.Path; @@ -30,14 +24,18 @@ import java.util.List; import java.util.Locale; +import org.apache.maven.jxr.ant.DirectoryScanner; +import org.apache.maven.jxr.pacman.PackageManager; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + /** * Main entry point into Maven used to kick off the XReference code building. * * @author Kevin A. Burton */ -public class JXR -{ - private static final Logger LOGGER = LoggerFactory.getLogger( JXR.class ); +public class JXR { + private static final Logger LOGGER = LoggerFactory.getLogger(JXR.class); private final PackageManager pkgmgr; @@ -50,7 +48,7 @@ public class JXR /** * The default list of include patterns to use. */ - private static final String[] DEFAULT_INCLUDES = { "**/*.java" }; + private static final String[] DEFAULT_INCLUDES = {"**/*.java"}; /** * Path to destination. @@ -68,7 +66,6 @@ public class JXR */ private Path javadocLinkDir; - /** * The revision of the module currently being processed. */ @@ -84,8 +81,7 @@ public class JXR */ private String[] includes = DEFAULT_INCLUDES; - public JXR( PackageManager pkgmgr, JavaCodeTransform transformer ) - { + public JXR(PackageManager pkgmgr, JavaCodeTransform transformer) { this.pkgmgr = pkgmgr; this.transformer = transformer; } @@ -98,32 +94,28 @@ public JXR( PackageManager pkgmgr, JavaCodeTransform transformer ) * @param bottom bottom text * @throws IOException on transformation error */ - public void processPath( PackageManager packageManager, Path sourceDir, String bottom ) - throws IOException - { + public void processPath(PackageManager packageManager, Path sourceDir, String bottom) throws IOException { DirectoryScanner ds = new DirectoryScanner(); // I'm not sure why we don't use the directoryScanner in packageManager, // but since we don't we need to set includes/excludes here as well - ds.setExcludes( excludes ); - ds.setIncludes( includes ); + ds.setExcludes(excludes); + ds.setIncludes(includes); ds.addDefaultExcludes(); - ds.setBasedir( sourceDir.toString() ); + ds.setBasedir(sourceDir.toString()); ds.scan(); - //now get the list of included files + // now get the list of included files String[] files = ds.getIncludedFiles(); - for ( String file : files ) - { - Path sourceFile = sourceDir.resolve( file ); + for (String file : files) { + Path sourceFile = sourceDir.resolve(file); - if ( isJavaFile( sourceFile.toString() ) ) - { - String newFileName = file.replaceFirst( ".java$", ".html" ); + if (isJavaFile(sourceFile.toString())) { + String newFileName = file.replaceFirst(".java$", ".html"); - transform( sourceFile, this.destDir.resolve( newFileName ), bottom ); + transform(sourceFile, this.destDir.resolve(newFileName), bottom); } } } @@ -134,9 +126,8 @@ public void processPath( PackageManager packageManager, Path sourceDir, String b * @param filename The name of the file to check * @return {@code true} if the file is a Java file */ - public static boolean isJavaFile( String filename ) - { - return filename.endsWith( ".java" ); + public static boolean isJavaFile(String filename) { + return filename.endsWith(".java"); } /** @@ -145,9 +136,8 @@ public static boolean isJavaFile( String filename ) * @param filename The name of the file to check * @return {@code true} if the file is an HTML file */ - public static boolean isHtmlFile( String filename ) - { - return filename.endsWith( ".html" ); + public static boolean isHtmlFile(String filename) { + return filename.endsWith(".html"); } /** @@ -155,8 +145,7 @@ public static boolean isHtmlFile( String filename ) * * @param dest destination */ - public void setDest( Path dest ) - { + public void setDest(Path dest) { this.destDir = dest; } @@ -165,8 +154,7 @@ public void setDest( Path dest ) * * @param locale locale */ - public void setLocale( Locale locale ) - { + public void setLocale(Locale locale) { this.locale = locale; } @@ -175,8 +163,7 @@ public void setLocale( Locale locale ) * * @param inputEncoding input encoding */ - public void setInputEncoding( String inputEncoding ) - { + public void setInputEncoding(String inputEncoding) { this.inputEncoding = inputEncoding; } @@ -185,8 +172,7 @@ public void setInputEncoding( String inputEncoding ) * * @param outputEncoding output encoding */ - public void setOutputEncoding( String outputEncoding ) - { + public void setOutputEncoding(String outputEncoding) { this.outputEncoding = outputEncoding; } @@ -194,8 +180,7 @@ public void setOutputEncoding( String outputEncoding ) * Sets the relative path to javadocs. * @param javadocLinkDir path to javadocs */ - public void setJavadocLinkDir( Path javadocLinkDir ) - { + public void setJavadocLinkDir(Path javadocLinkDir) { // get a relative link to the javadocs this.javadocLinkDir = javadocLinkDir; } @@ -205,8 +190,7 @@ public void setJavadocLinkDir( Path javadocLinkDir ) * * @param revision revision */ - public void setRevision( String revision ) - { + public void setRevision(String revision) { this.revision = revision; } @@ -221,29 +205,27 @@ public void setRevision( String revision ) * @throws IOException on I/O error * @throws JxrException on Velocity error */ - public void xref( List sourceDirs, String templateDir, String windowTitle, String docTitle, String bottom ) - throws IOException, JxrException - { - pkgmgr.setExcludes( excludes ); - pkgmgr.setIncludes( includes ); + public void xref(List sourceDirs, String templateDir, String windowTitle, String docTitle, String bottom) + throws IOException, JxrException { + pkgmgr.setExcludes(excludes); + pkgmgr.setIncludes(includes); // go through each source directory and xref the java files - for ( String dir : sourceDirs ) - { - Path path = Paths.get( dir ).toRealPath(); + for (String dir : sourceDirs) { + Path path = Paths.get(dir).toRealPath(); - pkgmgr.process( path ); + pkgmgr.process(path); - processPath( pkgmgr, path, bottom ); + processPath(pkgmgr, path, bottom); } // once we have all the source files xref'd, create the index pages - DirectoryIndexer indexer = new DirectoryIndexer( pkgmgr, destDir.toString() ); - indexer.setOutputEncoding( outputEncoding ); - indexer.setTemplateDir( templateDir ); - indexer.setWindowTitle( windowTitle ); - indexer.setDocTitle( docTitle ); - indexer.setBottom( bottom ); + DirectoryIndexer indexer = new DirectoryIndexer(pkgmgr, destDir.toString()); + indexer.setOutputEncoding(outputEncoding); + indexer.setTemplateDir(templateDir); + indexer.setWindowTitle(windowTitle); + indexer.setDocTitle(docTitle); + indexer.setBottom(bottom); indexer.process(); } @@ -259,15 +241,13 @@ public void xref( List sourceDirs, String templateDir, String windowTitl * @param bottom The bottom footer text just as in the package pages * @throws IOException if the transform can't happen for some reason */ - private void transform( Path sourceFile, Path destFile, String bottom ) - throws IOException - { - LOGGER.debug( sourceFile + " -> " + destFile ); + private void transform(Path sourceFile, Path destFile, String bottom) throws IOException { + LOGGER.debug(sourceFile + " -> " + destFile); // get a relative link to the javadocs - Path javadoc = javadocLinkDir != null ? getRelativeLink( destFile.getParent(), javadocLinkDir ) : null; - transformer.transform( sourceFile, destFile, locale, inputEncoding, outputEncoding, javadoc, - this.revision, bottom ); + Path javadoc = javadocLinkDir != null ? getRelativeLink(destFile.getParent(), javadocLinkDir) : null; + transformer.transform( + sourceFile, destFile, locale, inputEncoding, outputEncoding, javadoc, this.revision, bottom); } /** @@ -283,26 +263,19 @@ private void transform( Path sourceFile, Path destFile, String bottom ) * @param toDir The directory into which the link points. * @return a String of format {@code "../../schmoo/"} */ - private static Path getRelativeLink( Path fromDir, Path toDir ) - { - return fromDir.relativize( toDir ); + private static Path getRelativeLink(Path fromDir, Path toDir) { + return fromDir.relativize(toDir); } - public void setExcludes( String[] excludes ) - { + public void setExcludes(String[] excludes) { this.excludes = excludes; } - - public void setIncludes( String[] includes ) - { - if ( includes == null ) - { + public void setIncludes(String[] includes) { + if (includes == null) { // We should not include non-java files, so we use a sensible default pattern this.includes = DEFAULT_INCLUDES; - } - else - { + } else { this.includes = includes; } } diff --git a/maven-jxr/src/main/java/org/apache/maven/jxr/JavaCodeTransform.java b/maven-jxr/src/main/java/org/apache/maven/jxr/JavaCodeTransform.java index 8b857c9d..3740e096 100644 --- a/maven-jxr/src/main/java/org/apache/maven/jxr/JavaCodeTransform.java +++ b/maven-jxr/src/main/java/org/apache/maven/jxr/JavaCodeTransform.java @@ -1,3 +1,21 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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.maven.jxr; /* @@ -30,15 +48,6 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -import org.apache.maven.jxr.pacman.ClassType; -import org.apache.maven.jxr.pacman.FileManager; -import org.apache.maven.jxr.pacman.ImportType; -import org.apache.maven.jxr.pacman.JavaFile; -import org.apache.maven.jxr.pacman.PackageManager; -import org.apache.maven.jxr.pacman.PackageType; -import org.apache.maven.jxr.util.SimpleWordTokenizer; -import org.apache.maven.jxr.util.StringEntry; - import java.io.BufferedReader; import java.io.FileInputStream; import java.io.FileOutputStream; @@ -63,6 +72,15 @@ import java.util.Map; import java.util.Set; +import org.apache.maven.jxr.pacman.ClassType; +import org.apache.maven.jxr.pacman.FileManager; +import org.apache.maven.jxr.pacman.ImportType; +import org.apache.maven.jxr.pacman.JavaFile; +import org.apache.maven.jxr.pacman.PackageManager; +import org.apache.maven.jxr.pacman.PackageType; +import org.apache.maven.jxr.util.SimpleWordTokenizer; +import org.apache.maven.jxr.util.StringEntry; + /** * Syntax highlights java by turning it into html. A codeviewer object is created and then keeps state as lines are * passed in. Each line passed in as java test, is returned as syntax highlighted html text. Users of the class can set @@ -90,9 +108,7 @@ * importFilter * */ -public class JavaCodeTransform - implements Serializable -{ +public class JavaCodeTransform implements Serializable { // ---------------------------------------------------------------------- // public fields // ---------------------------------------------------------------------- @@ -147,14 +163,15 @@ public class JavaCodeTransform */ private static final String STYLESHEET_FILENAME = "stylesheet.css"; - private static final String[] VALID_URI_SCHEMES = { "http://", "https://", "mailto:" }; + private static final String[] VALID_URI_SCHEMES = {"http://", "https://", "mailto:"}; /** * Specify the only characters that are allowed in a URI besides alpha and numeric characters. Refer RFC2396 - * http://www.ietf.org/rfc/rfc2396.txt */ - private static final char[] VALID_URI_CHARS = { '?', '+', '%', '&', ':', '/', '.', '@', '_', ';', '=', '$', ',', - '-', '!', '~', '*', '\'', '(', ')' }; + private static final char[] VALID_URI_CHARS = { + '?', '+', '%', '&', ':', '/', '.', '@', '_', ';', '=', '$', ',', '-', '!', '~', '*', '\'', '(', ')' + }; // ---------------------------------------------------------------------- // private fields @@ -211,65 +228,64 @@ public class JavaCodeTransform private final FileManager fileManager; { - reservedWords.put( "abstract", "abstract" ); - reservedWords.put( "do", "do" ); - reservedWords.put( "inner", "inner" ); - reservedWords.put( "public", "public" ); - reservedWords.put( "var", "var" ); - reservedWords.put( "boolean", "boolean" ); - reservedWords.put( "continue", "continue" ); - reservedWords.put( "int", "int" ); - reservedWords.put( "return", "return" ); - reservedWords.put( "void", "void" ); - reservedWords.put( "break", "break" ); - reservedWords.put( "else", "else" ); - reservedWords.put( "interface", "interface" ); - reservedWords.put( "short", "short" ); - reservedWords.put( "volatile", "volatile" ); - reservedWords.put( "byvalue", "byvalue" ); - reservedWords.put( "extends", "extends" ); - reservedWords.put( "long", "long" ); - reservedWords.put( "static", "static" ); - reservedWords.put( "while", "while" ); - reservedWords.put( "case", "case" ); - reservedWords.put( "final", "final" ); - reservedWords.put( "native", "native" ); - reservedWords.put( "super", "super" ); - reservedWords.put( "transient", "transient" ); - reservedWords.put( "cast", "cast" ); - reservedWords.put( "float", "float" ); - reservedWords.put( "new", "new" ); - reservedWords.put( "rest", "rest" ); - reservedWords.put( "catch", "catch" ); - reservedWords.put( "for", "for" ); - reservedWords.put( "null", "null" ); - reservedWords.put( "synchronized", "synchronized" ); - reservedWords.put( "char", "char" ); - reservedWords.put( "finally", "finally" ); - reservedWords.put( "operator", "operator" ); - reservedWords.put( "this", "this" ); - reservedWords.put( "class", "class" ); - reservedWords.put( "generic", "generic" ); - reservedWords.put( "outer", "outer" ); - reservedWords.put( "switch", "switch" ); - reservedWords.put( "const", "const" ); - reservedWords.put( "goto", "goto" ); - reservedWords.put( "package", "package" ); - reservedWords.put( "throw", "throw" ); - reservedWords.put( "double", "double" ); - reservedWords.put( "if", "if" ); - reservedWords.put( "private", "private" ); - reservedWords.put( "true", "true" ); - reservedWords.put( "default", "default" ); - reservedWords.put( "import", "import" ); - reservedWords.put( "protected", "protected" ); - reservedWords.put( "try", "try" ); - reservedWords.put( "throws", "throws" ); - reservedWords.put( "implements", "implements" ); + reservedWords.put("abstract", "abstract"); + reservedWords.put("do", "do"); + reservedWords.put("inner", "inner"); + reservedWords.put("public", "public"); + reservedWords.put("var", "var"); + reservedWords.put("boolean", "boolean"); + reservedWords.put("continue", "continue"); + reservedWords.put("int", "int"); + reservedWords.put("return", "return"); + reservedWords.put("void", "void"); + reservedWords.put("break", "break"); + reservedWords.put("else", "else"); + reservedWords.put("interface", "interface"); + reservedWords.put("short", "short"); + reservedWords.put("volatile", "volatile"); + reservedWords.put("byvalue", "byvalue"); + reservedWords.put("extends", "extends"); + reservedWords.put("long", "long"); + reservedWords.put("static", "static"); + reservedWords.put("while", "while"); + reservedWords.put("case", "case"); + reservedWords.put("final", "final"); + reservedWords.put("native", "native"); + reservedWords.put("super", "super"); + reservedWords.put("transient", "transient"); + reservedWords.put("cast", "cast"); + reservedWords.put("float", "float"); + reservedWords.put("new", "new"); + reservedWords.put("rest", "rest"); + reservedWords.put("catch", "catch"); + reservedWords.put("for", "for"); + reservedWords.put("null", "null"); + reservedWords.put("synchronized", "synchronized"); + reservedWords.put("char", "char"); + reservedWords.put("finally", "finally"); + reservedWords.put("operator", "operator"); + reservedWords.put("this", "this"); + reservedWords.put("class", "class"); + reservedWords.put("generic", "generic"); + reservedWords.put("outer", "outer"); + reservedWords.put("switch", "switch"); + reservedWords.put("const", "const"); + reservedWords.put("goto", "goto"); + reservedWords.put("package", "package"); + reservedWords.put("throw", "throw"); + reservedWords.put("double", "double"); + reservedWords.put("if", "if"); + reservedWords.put("private", "private"); + reservedWords.put("true", "true"); + reservedWords.put("default", "default"); + reservedWords.put("import", "import"); + reservedWords.put("protected", "protected"); + reservedWords.put("try", "try"); + reservedWords.put("throws", "throws"); + reservedWords.put("implements", "implements"); } - public JavaCodeTransform( PackageManager packageManager, FileManager fileManager ) - { + public JavaCodeTransform(PackageManager packageManager, FileManager fileManager) { this.packageManager = packageManager; this.fileManager = fileManager; } @@ -284,9 +300,8 @@ public JavaCodeTransform( PackageManager packageManager, FileManager fileManager * @param line String * @return filtered line of code */ - private String syntaxHighlight( String line ) - { - return htmlFilter( line ); + private String syntaxHighlight(String line) { + return htmlFilter(line); } /** @@ -294,64 +309,54 @@ private String syntaxHighlight( String line ) * * @param out the writer where the header is appended to */ - private void appendHeader( PrintWriter out ) - { + private void appendHeader(PrintWriter out) { String outputEncoding = this.outputEncoding; - if ( outputEncoding == null ) - { + if (outputEncoding == null) { outputEncoding = "ISO-8859-1"; } // header - out.println( "" ); - out.print( "" ); - out.print( "" ); - out.print( "" ); + out.println(""); + out.print(""); + out.print(""); + out.print(""); // title ("classname xref") - out.print( "" ); - try - { - JavaFile javaFile = fileManager.getFile( this.getCurrentFilename() ); + out.print("<title>"); + try { + JavaFile javaFile = fileManager.getFile(this.getCurrentFilename()); // Use the name of the file instead of the class to handle inner classes properly - if ( javaFile.getClassType() != null && javaFile.getClassType().getFilename() != null ) - { - out.print( javaFile.getClassType().getFilename() ); - } - else - { - out.print( javaFile.getFilename() ); + if (javaFile.getClassType() != null && javaFile.getClassType().getFilename() != null) { + out.print(javaFile.getClassType().getFilename()); + } else { + out.print(javaFile.getFilename()); } - out.print( ' ' ); - } - catch ( IOException e ) - { + out.print(' '); + } catch (IOException e) { e.printStackTrace(); - } - finally - { - out.println( "xref" ); + } finally { + out.println("xref"); } // stylesheet link - out.print( "" ); + out.print(""); - out.println( "" ); - out.println( "" ); - out.print( this.getFileOverview() ); + out.println(""); + out.println(""); + out.print(this.getFileOverview()); // start code section - out.println( "
" );
+        out.println("
");
     }
 
     /**
@@ -360,15 +365,14 @@ private void appendHeader( PrintWriter out )
      * @param out the writer where the header is appended to
      * @param bottom the bottom text
      */
-    private void appendFooter( PrintWriter out, String bottom )
-    {
-        out.println( "
" ); - out.println( "
" ); - out.print( "
" ); - out.print( bottom ); - out.println( "
" ); - out.println( "" ); - out.println( "" ); + private void appendFooter(PrintWriter out, String bottom) { + out.println("
"); + out.println("
"); + out.print("
"); + out.print(bottom); + out.println("
"); + out.println(""); + out.println(""); } /** @@ -383,38 +387,41 @@ private void appendFooter( PrintWriter out, String bottom ) * @param bottom string * @throws IOException */ - private void transform( Reader sourceReader, Writer destWriter, Locale locale, - String outputEncoding, Path javadocLinkDir, String revision, String bottom ) - throws IOException - { + private void transform( + Reader sourceReader, + Writer destWriter, + Locale locale, + String outputEncoding, + Path javadocLinkDir, + String revision, + String bottom) + throws IOException { this.locale = locale; this.outputEncoding = outputEncoding; this.javadocLinkDir = javadocLinkDir; this.revision = revision; - BufferedReader in = new BufferedReader( sourceReader ); + BufferedReader in = new BufferedReader(sourceReader); - PrintWriter out = new PrintWriter( destWriter ); + PrintWriter out = new PrintWriter(destWriter); String line; - appendHeader( out ); + appendHeader(out); int linenumber = 1; - while ( ( line = in.readLine() ) != null ) - { - if ( LINE_NUMBERS ) - { - out.print( "" + linenumber + "" + getLineWidth( linenumber ) ); + while ((line = in.readLine()) != null) { + if (LINE_NUMBERS) { + out.print("" + + linenumber + "" + getLineWidth(linenumber)); } - out.println( this.syntaxHighlight( line ) ); + out.println(this.syntaxHighlight(line)); ++linenumber; } - appendFooter( out, bottom ); + appendFooter(out, bottom); out.flush(); } @@ -432,52 +439,46 @@ private void transform( Reader sourceReader, Writer destWriter, Locale locale, * @param bottom bottom text * @throws IOException in I/O failures in reading/writing files */ - public final void transform( Path sourcefile, Path destfile, Locale locale, String inputEncoding, - String outputEncoding, Path javadocLinkDir, String revision, String bottom ) - throws IOException - { - this.setCurrentFilename( sourcefile ); + public final void transform( + Path sourcefile, + Path destfile, + Locale locale, + String inputEncoding, + String outputEncoding, + Path javadocLinkDir, + String revision, + String bottom) + throws IOException { + this.setCurrentFilename(sourcefile); // make sure that the parent directories exist... - Files.createDirectories( destfile.getParent() ); + Files.createDirectories(destfile.getParent()); - try ( Reader fr = getReader( sourcefile, inputEncoding ); Writer fw = getWriter( destfile, outputEncoding ) ) - { - transform( fr, fw, locale, outputEncoding, javadocLinkDir, revision, bottom ); - } - catch ( RuntimeException e ) - { - System.out.println( "Unable to processPath " + sourcefile + " => " + destfile ); + try (Reader fr = getReader(sourcefile, inputEncoding); + Writer fw = getWriter(destfile, outputEncoding)) { + transform(fr, fw, locale, outputEncoding, javadocLinkDir, revision, bottom); + } catch (RuntimeException e) { + System.out.println("Unable to processPath " + sourcefile + " => " + destfile); throw e; } } - private Writer getWriter( Path destfile, String outputEncoding ) - throws IOException - { + private Writer getWriter(Path destfile, String outputEncoding) throws IOException { Writer fw; - if ( outputEncoding != null ) - { - fw = new OutputStreamWriter( new FileOutputStream( destfile.toFile() ), outputEncoding ); - } - else - { - fw = new FileWriter( destfile.toFile() ); + if (outputEncoding != null) { + fw = new OutputStreamWriter(new FileOutputStream(destfile.toFile()), outputEncoding); + } else { + fw = new FileWriter(destfile.toFile()); } return fw; } - private Reader getReader( Path sourcefile, String inputEncoding ) - throws IOException - { + private Reader getReader(Path sourcefile, String inputEncoding) throws IOException { Reader fr; - if ( inputEncoding != null ) - { - fr = new InputStreamReader( new FileInputStream( sourcefile.toFile() ), inputEncoding ); - } - else - { - fr = new FileReader( sourcefile.toFile() ); + if (inputEncoding != null) { + fr = new InputStreamReader(new FileInputStream(sourcefile.toFile()), inputEncoding); + } else { + fr = new FileReader(sourcefile.toFile()); } return fr; } @@ -487,8 +488,7 @@ private Reader getReader( Path sourcefile, String inputEncoding ) * * @return path of file */ - private Path getCurrentFilename() - { + private Path getCurrentFilename() { return this.currentFilename; } @@ -497,8 +497,7 @@ private Path getCurrentFilename() * * @param filename file name */ - private void setCurrentFilename( Path filename ) - { + private void setCurrentFilename(Path filename) { this.currentFilename = filename; } @@ -507,29 +506,24 @@ private void setCurrentFilename( Path filename ) * * @return package root */ - private String getPackageRoot() - { + private String getPackageRoot() { StringBuilder buff = new StringBuilder(); JavaFile jf; - try - { - jf = fileManager.getFile( this.getCurrentFilename() ); - } - catch ( IOException e ) - { + try { + jf = fileManager.getFile(this.getCurrentFilename()); + } catch (IOException e) { e.printStackTrace(); return null; } String current = jf.getPackageType().getName(); - int count = this.getPackageCount( current ); + int count = this.getPackageCount(current); - for ( int i = 0; i < count; ++i ) - { - buff.append( "../" ); + for (int i = 0; i < count; ++i) { + buff.append("../"); } return buff.toString(); @@ -541,23 +535,18 @@ private String getPackageRoot() * @param line String * @return href */ - private String uriFilter( String line ) - { - for ( String scheme : VALID_URI_SCHEMES ) - { - int index = line.indexOf( scheme ); + private String uriFilter(String line) { + for (String scheme : VALID_URI_SCHEMES) { + int index = line.indexOf(scheme); - if ( index != -1 ) - { + if (index != -1) { int start = index; int end = -1; - for ( int j = start; j < line.length(); ++j ) - { - char current = line.charAt( j ); + for (int j = start; j < line.length(); ++j) { + char current = line.charAt(j); - if ( !Character.isLetterOrDigit( current ) && isInvalidURICharacter( current ) ) - { + if (!Character.isLetterOrDigit(current) && isInvalidURICharacter(current)) { end = j; break; } @@ -568,19 +557,17 @@ private String uriFilter( String line ) // now you should have the full URI so you can replace this // in the current buffer - if ( end != -1 ) - { - String uri = ( end + 1 == line.length() ) ? line.substring( start ) : line.substring( start, end ); + if (end != -1) { + String uri = (end + 1 == line.length()) ? line.substring(start) : line.substring(start, end); - line = line.replace( uri, "" + uri + "" ); + line = line.replace(uri, "" + uri + ""); } } } // if we are in a multiline comment we should not call JXR here. - if ( !inMultiLineComment && !inJavadocComment ) - { - return jxrFilter( line ); + if (!inMultiLineComment && !inJavadocComment) { + return jxrFilter(line); } return line; @@ -591,8 +578,7 @@ private String uriFilter( String line ) * * @return revision */ - public final String getRevision() - { + public final String getRevision() { return this.revision; } @@ -604,25 +590,21 @@ public final String getRevision() * @param classType ClassType * @return cross-referenced line */ - private String xrLine( String line, String packageName, ClassType classType ) - { - StringBuilder buff = new StringBuilder( line ); + private String xrLine(String line, String packageName, ClassType classType) { + StringBuilder buff = new StringBuilder(line); String link; String find; String href; - if ( classType != null ) - { - href = this.getHREF( packageName, classType ); + if (classType != null) { + href = this.getHREF(packageName, classType); find = classType.getName(); // build out what the link would be. link = "" + find + ""; - } - else - { - href = this.getHREF( packageName ); + } else { + href = this.getHREF(packageName); find = packageName; // build out what the link would be. @@ -635,21 +617,19 @@ private String xrLine( String line, String packageName, ClassType classType ) // now replace the word in the buffer with the link String replace = link; - List tokens = SimpleWordTokenizer.tokenize( buff.toString(), find ); + List tokens = SimpleWordTokenizer.tokenize(buff.toString(), find); // JXR-141: If there are more than 1 tokens to be replaced, // then the start+end values are out of order during the // buff.replace. // Reversing the list solves it - Collections.reverse( tokens ); + Collections.reverse(tokens); - for ( StringEntry token : tokens ) - { + for (StringEntry token : tokens) { int start = token.getIndex(); int end = token.getIndex() + find.length(); - buff.replace( start, end, replace ); - + buff.replace(start, end, replace); } return buff.toString(); @@ -665,19 +645,17 @@ private String xrLine( String line, String packageName, ClassType classType ) * @param line String * @return html encoded line */ - private String htmlFilter( String line ) - { - if ( line == null || line.equals( "" ) ) - { + private String htmlFilter(String line) { + if (line == null || line.equals("")) { return ""; } - line = line.replace( "&", "&" ) - .replace( "<", "<" ) - .replace( ">", ">" ) - .replace( "\\\\", "\\" ) - .replace( "\\\"", "\\"" ) - .replace( "'\"'", "'"'" ); - return ongoingMultiLineCommentFilter( line ); + line = line.replace("&", "&") + .replace("<", "<") + .replace(">", ">") + .replace("\\\\", "\\") + .replace("\\\"", "\\"") + .replace("'\"'", "'"'"); + return ongoingMultiLineCommentFilter(line); } /** @@ -688,42 +666,36 @@ private String htmlFilter( String line ) * @param line line * @return processed line */ - private String ongoingMultiLineCommentFilter( String line ) - { - if ( line == null || line.equals( "" ) ) - { + private String ongoingMultiLineCommentFilter(String line) { + if (line == null || line.equals("")) { return ""; } - final String[] tags = - inJavadocComment ? new String[] { JAVADOC_COMMENT_START, JAVADOC_COMMENT_END } - : inMultiLineComment ? new String[] { COMMENT_START, COMMENT_END } : null; + final String[] tags = inJavadocComment + ? new String[] {JAVADOC_COMMENT_START, JAVADOC_COMMENT_END} + : inMultiLineComment ? new String[] {COMMENT_START, COMMENT_END} : null; - if ( tags == null ) - { + if (tags == null) { // pass the line down to the next filter for processing. - return inlineCommentFilter( line ); + return inlineCommentFilter(line); } - int index = line.indexOf( "*/" ); + int index = line.indexOf("*/"); // only filter the portion without the end-of-comment, // since * and / seem to be valid URI characters - String comment = uriFilter( index < 0 ? line : line.substring( 0, index ) ); - if ( index >= 0 ) - { + String comment = uriFilter(index < 0 ? line : line.substring(0, index)); + if (index >= 0) { inJavadocComment = false; inMultiLineComment = false; } - StringBuilder buf = new StringBuilder( tags[0] ).append( comment ); + StringBuilder buf = new StringBuilder(tags[0]).append(comment); - if ( index >= 0 ) - { - buf.append( "*/" ); + if (index >= 0) { + buf.append("*/"); } - buf.append( tags[1] ); + buf.append(tags[1]); - if ( index >= 0 && line.length() > index + 2 ) - { - buf.append( inlineCommentFilter( line.substring( index + 2 ) ) ); + if (index >= 0 && line.length() > index + 2) { + buf.append(inlineCommentFilter(line.substring(index + 2))); } return buf.toString(); } @@ -737,23 +709,22 @@ private String ongoingMultiLineCommentFilter( String line ) * @param line line * @return processed line */ - private String inlineCommentFilter( String line ) - { + private String inlineCommentFilter(String line) { // assert !inJavadocComment; // assert !inMultiLineComment; - if ( line == null || line.equals( "" ) ) - { + if (line == null || line.equals("")) { return ""; } - int index = line.indexOf( "//" ); - if ( ( index >= 0 ) && !isInsideString( line, index ) ) - { - return beginMultiLineCommentFilter( line.substring( 0, index ) ) + COMMENT_START + line.substring( index ) + int index = line.indexOf("//"); + if ((index >= 0) && !isInsideString(line, index)) { + return beginMultiLineCommentFilter(line.substring(0, index)) + + COMMENT_START + + line.substring(index) + COMMENT_END; } - return beginMultiLineCommentFilter( line ); + return beginMultiLineCommentFilter(line); } /** @@ -763,41 +734,34 @@ private String inlineCommentFilter( String line ) * @param line line * @return processed line */ - private String beginMultiLineCommentFilter( String line ) - { + private String beginMultiLineCommentFilter(String line) { // assert !inJavadocComment; // assert !inMultiLineComment; - if ( line == null || line.equals( "" ) ) - { + if (line == null || line.equals("")) { return ""; } - int index = line.indexOf( "/*" ); + int index = line.indexOf("/*"); // check to see if a multi-line comment starts on this line: - if ( ( index > -1 ) && !isInsideString( line, index ) ) - { - String fromIndex = line.substring( index ); - if ( fromIndex.startsWith( "/**" ) && !( fromIndex.startsWith( "/**/" ) ) ) - { + if ((index > -1) && !isInsideString(line, index)) { + String fromIndex = line.substring(index); + if (fromIndex.startsWith("/**") && !(fromIndex.startsWith("/**/"))) { inJavadocComment = true; - } - else - { + } else { inMultiLineComment = true; } // Return result of other filters + everything after the start // of the multiline comment. We need to pass the through the // to the ongoing multiLineComment filter again in case the comment // ends on the same line. - return stringFilter( line.substring( 0, index ) ) + ongoingMultiLineCommentFilter( fromIndex ); + return stringFilter(line.substring(0, index)) + ongoingMultiLineCommentFilter(fromIndex); } // Otherwise, no useful multi-line comment information was found so // pass the line down to the next filter for processesing. - else - { - return stringFilter( line ); + else { + return stringFilter(line); } } @@ -807,44 +771,38 @@ private String beginMultiLineCommentFilter( String line ) * @param line line * @return processed line */ - private String stringFilter( String line ) - { - if ( line == null || line.equals( "" ) ) - { + private String stringFilter(String line) { + if (line == null || line.equals("")) { return ""; } StringBuilder buf = new StringBuilder(); - if ( line.indexOf( '"' ) <= -1 ) - { - return keywordFilter( line ); + if (line.indexOf('"') <= -1) { + return keywordFilter(line); } int start = 0; int startStringIndex = -1; int endStringIndex = -1; int tempIndex; // Keep moving through String characters until we want to stop... - while ( ( tempIndex = line.indexOf( '"' ) ) > -1 ) - { + while ((tempIndex = line.indexOf('"')) > -1) { // We found the beginning of a string - if ( startStringIndex == -1 ) - { + if (startStringIndex == -1) { startStringIndex = 0; - buf.append( stringFilter( line.substring( start, tempIndex ) ) ); - buf.append( STRING_START ).append( '"' ); - line = line.substring( tempIndex + 1 ); + buf.append(stringFilter(line.substring(start, tempIndex))); + buf.append(STRING_START).append('"'); + line = line.substring(tempIndex + 1); } // Must be at the end - else - { + else { startStringIndex = -1; endStringIndex = tempIndex; - buf.append( line, 0, endStringIndex + 1 ); - buf.append( STRING_END ); - line = line.substring( endStringIndex + 1 ); + buf.append(line, 0, endStringIndex + 1); + buf.append(STRING_END); + line = line.substring(endStringIndex + 1); } } - buf.append( keywordFilter( line ) ); + buf.append(keywordFilter(line)); return buf.toString(); } @@ -855,54 +813,45 @@ private String stringFilter( String line ) * @param line line * @return processed line */ - private String keywordFilter( String line ) - { + private String keywordFilter(String line) { final String classKeyword = "class"; - if ( line == null || line.equals( "" ) ) - { + if (line == null || line.equals("")) { return ""; } StringBuilder buf = new StringBuilder(); int i = 0; char ch; StringBuilder temp = new StringBuilder(); - while ( i < line.length() ) - { - temp.setLength( 0 ); - ch = line.charAt( i ); - while ( i < line.length() && ( ( ch >= 'a' && ch <= 'z' ) || ( ch >= 'A' && ch <= 'Z' ) ) ) - { - temp.append( ch ); + while (i < line.length()) { + temp.setLength(0); + ch = line.charAt(i); + while (i < line.length() && ((ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z'))) { + temp.append(ch); i++; - if ( i < line.length() ) - { - ch = line.charAt( i ); + if (i < line.length()) { + ch = line.charAt(i); } } String tempString = temp.toString(); // Special handling of css style class definitions - if ( classKeyword.equals( tempString ) && ch == '=' ) - { + if (classKeyword.equals(tempString) && ch == '=') { i++; - } - else if ( reservedWords.containsKey( tempString ) ) - { - line = line.substring( 0, i - tempString.length() ) + RESERVED_WORD_START + } else if (reservedWords.containsKey(tempString)) { + line = line.substring(0, i - tempString.length()) + + RESERVED_WORD_START + tempString + RESERVED_WORD_END - + line.substring( i ); - i += ( RESERVED_WORD_START.length() + RESERVED_WORD_END.length() ); - } - else - { + + line.substring(i); + i += (RESERVED_WORD_START.length() + RESERVED_WORD_END.length()); + } else { i++; } } - buf.append( line ); + buf.append(line); - return uriFilter( buf.toString() ); + return uriFilter(buf.toString()); } /** @@ -913,37 +862,31 @@ else if ( reservedWords.containsKey( tempString ) ) * @param position int * @return boolean */ - private boolean isInsideString( String line, int position ) - { - if ( line.indexOf( '"' ) < 0 ) - { + private boolean isInsideString(String line, int position) { + if (line.indexOf('"') < 0) { return false; } int index; - String left = line.substring( 0, position ); - String right = line.substring( position ); + String left = line.substring(0, position); + String right = line.substring(position); int leftCount = 0; int rightCount = 0; - while ( ( index = left.indexOf( '"' ) ) > -1 ) - { + while ((index = left.indexOf('"')) > -1) { leftCount++; - left = left.substring( index + 1 ); + left = left.substring(index + 1); } - while ( ( index = right.indexOf( '"' ) ) > -1 ) - { + while ((index = right.indexOf('"')) > -1) { rightCount++; - right = right.substring( index + 1 ); + right = right.substring(index + 1); } - return ( rightCount % 2 != 0 && leftCount % 2 != 0 ); + return (rightCount % 2 != 0 && leftCount % 2 != 0); } /** * @param oos ObjectOutputStream * @throws IOException on I/O error during write */ - final void writeObject( ObjectOutputStream oos ) - throws IOException - { + final void writeObject(ObjectOutputStream oos) throws IOException { oos.defaultWriteObject(); } @@ -952,9 +895,7 @@ final void writeObject( ObjectOutputStream oos ) * @throws ClassNotFoundException if the class of a serialized object could not be found. * @throws IOException on I/O error during read */ - final void readObject( ObjectInputStream ois ) - throws ClassNotFoundException, IOException - { + final void readObject(ObjectInputStream ois) throws ClassNotFoundException, IOException { ois.defaultReadObject(); } @@ -963,46 +904,38 @@ final void readObject( ObjectInputStream ois ) * * @return overview header */ - private String getFileOverview() - { + private String getFileOverview() { StringBuilder overview = new StringBuilder(); // only add the header if javadocs are present - if ( javadocLinkDir != null ) - { - overview.append( "
" ); + if (javadocLinkDir != null) { + overview.append("
"); // get the URI to get Javadoc info. Path javadocURI; - try - { - JavaFile jf = fileManager.getFile( this.getCurrentFilename() ); + try { + JavaFile jf = fileManager.getFile(this.getCurrentFilename()); - javadocURI = javadocLinkDir.resolve( jf.getPackageType().getName().replace( '.', '/' ) ) - ; + javadocURI = + javadocLinkDir.resolve(jf.getPackageType().getName().replace('.', '/')); // Use the name of the file instead of the class to handle inner classes properly String fileName; - if ( jf.getClassType() != null && jf.getClassType().getFilename() != null ) - { + if (jf.getClassType() != null && jf.getClassType().getFilename() != null) { fileName = jf.getClassType().getFilename(); - } - else - { + } else { fileName = jf.getFilename(); } - javadocURI = javadocURI.resolve( fileName + ".html" ); + javadocURI = javadocURI.resolve(fileName + ".html"); - String javadocHREF = "View Javadoc"; + String javadocHREF = "View Javadoc"; // get the generation time... - overview.append( javadocHREF ); - } - catch ( IOException e ) - { + overview.append(javadocHREF); + } catch (IOException e) { e.printStackTrace(); } - overview.append( "
" ); + overview.append("
"); } return overview.toString(); @@ -1014,18 +947,12 @@ private String getFileOverview() * @param linenumber int * @return blanks */ - private String getLineWidth( int linenumber ) - { - if ( linenumber < 10 ) - { + private String getLineWidth(int linenumber) { + if (linenumber < 10) { return " "; - } - else if ( linenumber < 100 ) - { + } else if (linenumber < 100) { return " "; - } - else - { + } else { return " "; } } @@ -1036,22 +963,17 @@ else if ( linenumber < 100 ) * @param line line * @return processed line */ - private String jxrFilter( String line ) - { + private String jxrFilter(String line) { JavaFile jf; - try - { + try { // if the current file isn't set then just return - if ( this.getCurrentFilename() == null ) - { + if (this.getCurrentFilename() == null) { return line; } - jf = fileManager.getFile( this.getCurrentFilename() ); - } - catch ( IOException e ) - { + jf = fileManager.getFile(this.getCurrentFilename()); + } catch (IOException e) { e.printStackTrace(); return line; } @@ -1059,32 +981,28 @@ private String jxrFilter( String line ) Set packages = new HashSet<>(); // get the imported packages - for ( ImportType importType : jf.getImportTypes() ) - { - packages.add( importType.getPackage() ); + for (ImportType importType : jf.getImportTypes()) { + packages.add(importType.getPackage()); } // add the current package. - packages.add( jf.getPackageType().getName() ); + packages.add(jf.getPackageType().getName()); - List words = SimpleWordTokenizer.tokenize( line ); + List words = SimpleWordTokenizer.tokenize(line); // go through each word and then match them to the correct class if necessary. - for ( StringEntry word : words ) - { - for ( String pkg : packages ) - { + for (StringEntry word : words) { + for (String pkg : packages) { // get the package from the PackageManager because this will hold // the version with the classes also. - PackageType currentImport = packageManager.getPackageType( pkg ); + PackageType currentImport = packageManager.getPackageType(pkg); // the package here might in fact be null because it wasn't parsed out // this might be something that is either not included or is part // of another package and wasn't parsed out. - if ( currentImport == null ) - { + if (currentImport == null) { continue; } @@ -1095,50 +1013,43 @@ private String jxrFilter( String line ) String wordName = word.toString(); - if ( wordName.indexOf( '.' ) != -1 ) - { + if (wordName.indexOf('.') != -1) { // if there is a "." in the string then we have to assume // it is a package. - String fqpnPackage = wordName.substring( 0, wordName.lastIndexOf( '.' ) ); - String fqpnClass = wordName.substring( wordName.lastIndexOf( '.' ) + 1 ); + String fqpnPackage = wordName.substring(0, wordName.lastIndexOf('.')); + String fqpnClass = wordName.substring(wordName.lastIndexOf('.') + 1); // note. since this is a reference to a full package then // it doesn't have to be explicitly imported so this information // is useless. Instead just see if it was parsed out. - PackageType pt = packageManager.getPackageType( fqpnPackage ); + PackageType pt = packageManager.getPackageType(fqpnPackage); - if ( pt != null ) - { - ClassType ct = pt.getClassType( fqpnClass ); + if (pt != null) { + ClassType ct = pt.getClassType(fqpnClass); - if ( ct != null ) - { + if (ct != null) { // OK. the user specified a full package to be imported // that is in the package manager so it is time to // link to it. - line = xrLine( line, pt.getName(), ct ); + line = xrLine(line, pt.getName(), ct); } } - if ( fqpnPackage.equals( currentImport.getName() ) - && currentImport.getClassType( fqpnClass ) != null ) - { + if (fqpnPackage.equals(currentImport.getName()) && currentImport.getClassType(fqpnClass) != null) { // then the package we are currently in is the one specified in the string // and the import class is correct. - line = xrLine( line, pkg, currentImport.getClassType( fqpnClass ) ); + line = xrLine(line, pkg, currentImport.getClassType(fqpnClass)); } - } - else if ( currentImport.getClassType( wordName ) != null ) - { - line = xrLine( line, pkg, currentImport.getClassType( wordName ) ); + } else if (currentImport.getClassType(wordName) != null) { + line = xrLine(line, pkg, currentImport.getClassType(wordName)); } } } - return importFilter( line ); + return importFilter(line); } /** @@ -1148,26 +1059,24 @@ else if ( currentImport.getClassType( wordName ) != null ) * @param jc class type * @return href */ - private String getHREF( String dest, ClassType jc ) - { + private String getHREF(String dest, ClassType jc) { StringBuilder href = new StringBuilder(); // find out how to go back to the root - href.append( this.getPackageRoot() ); + href.append(this.getPackageRoot()); // now find out how to get to the dest package - dest = dest.replace( ".*", "" ).replace( '.', '/' ); + dest = dest.replace(".*", "").replace('.', '/'); - href.append( dest ); + href.append(dest); // Now append filename.html - if ( jc != null ) - { - href.append( '/' ); - href.append( jc.getFilename() ); - href.append( ".html" ); - href.append( '#' ); - href.append( jc.getName() ); + if (jc != null) { + href.append('/'); + href.append(jc.getFilename()); + href.append(".html"); + href.append('#'); + href.append(jc.getName()); } return href.toString(); @@ -1179,9 +1088,8 @@ private String getHREF( String dest, ClassType jc ) * @param dest destination * @return href */ - private String getHREF( String dest ) - { - return getHREF( dest, null ); + private String getHREF(String dest) { + return getHREF(dest, null); } /** @@ -1195,22 +1103,18 @@ private String getHREF( String dest ) * @param packageName String * @return int */ - private int getPackageCount( String packageName ) - { - if ( packageName == null ) - { + private int getPackageCount(String packageName) { + if (packageName == null) { return 0; } int count = 0; int index = 0; - while ( true ) - { - index = packageName.indexOf( '.', index ); + while (true) { + index = packageName.indexOf('.', index); - if ( index == -1 ) - { + if (index == -1) { break; } ++index; @@ -1229,8 +1133,7 @@ private int getPackageCount( String packageName ) * @param line line * @return processed line */ - private String importFilter( String line ) - { + private String importFilter(String line) { int start = -1; /* @@ -1238,28 +1141,23 @@ private String importFilter( String line ) * - that this isn't a Class import so the full String is valid - that it WILL be on the disk since this is * based on the current - file. */ - boolean isPackage = line.trim().startsWith( "package " ); - boolean isImport = line.trim().startsWith( "import " ); + boolean isPackage = line.trim().startsWith("package "); + boolean isImport = line.trim().startsWith("import "); - if ( isImport || isPackage ) - { - start = line.trim().indexOf( ' ' ); + if (isImport || isPackage) { + start = line.trim().indexOf(' '); } - if ( start != -1 ) - { + if (start != -1) { // filter out this packagename... - String pkg = line.substring( start ).trim(); + String pkg = line.substring(start).trim(); // specify the classname of this import if any. String classname = null; - if (pkg.contains(".*")) - { - pkg = pkg.replace( ".*", "" ); - } - else if ( !isPackage ) - { + if (pkg.contains(".*")) { + pkg = pkg.replace(".*", ""); + } else if (!isPackage) { // this is an explicit Class import String packageLine = pkg; @@ -1272,42 +1170,35 @@ else if ( !isPackage ) // This breaks Jxr and won't be a problem when we hook // in the real parser. - int a = packageLine.lastIndexOf( '.' ) + 1; + int a = packageLine.lastIndexOf('.') + 1; int b = packageLine.length() - 1; - if ( a > b + 1 ) - { - classname = packageLine.substring( packageLine.lastIndexOf( '.' ) + 1, packageLine.length() - 1 ); + if (a > b + 1) { + classname = packageLine.substring(packageLine.lastIndexOf('.') + 1, packageLine.length() - 1); - int end = pkg.lastIndexOf( '.' ); - if ( end == -1 ) - { + int end = pkg.lastIndexOf('.'); + if (end == -1) { end = pkg.length() - 1; } - pkg = pkg.substring( 0, end ); + pkg = pkg.substring(0, end); } } - pkg = pkg.replace( ";", "" ); - String pkgHREF = getHREF( pkg ); + pkg = pkg.replace(";", ""); + String pkgHREF = getHREF(pkg); // if this package is within the PackageManager then you can create an HREF for it. - if ( packageManager.getPackageType( pkg ) != null || isPackage ) - { + if (packageManager.getPackageType(pkg) != null || isPackage) { // Create an HREF for explicit classname imports - if ( classname != null ) - { - line = line.replace( classname, "" + classname + "" ); + if (classname != null) { + line = line.replace( + classname, "" + classname + ""); } // now replace the given package with a href - line = - line.replace( pkg, "" + pkg - + "" ); + line = line.replace(pkg, "" + pkg + ""); } - } return line; @@ -1319,12 +1210,9 @@ else if ( !isPackage ) * @param c char to check against VALID_URI_CHARS list * @return {@code true} if c is a valid URI char */ - private boolean isInvalidURICharacter( char c ) - { - for ( char validUriChar : VALID_URI_CHARS ) - { - if ( validUriChar == c ) - { + private boolean isInvalidURICharacter(char c) { + for (char validUriChar : VALID_URI_CHARS) { + if (validUriChar == c) { return false; } } diff --git a/maven-jxr/src/main/java/org/apache/maven/jxr/JxrException.java b/maven-jxr/src/main/java/org/apache/maven/jxr/JxrException.java index 87716702..aed8ea37 100644 --- a/maven-jxr/src/main/java/org/apache/maven/jxr/JxrException.java +++ b/maven-jxr/src/main/java/org/apache/maven/jxr/JxrException.java @@ -1,5 +1,3 @@ -package org.apache.maven.jxr; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -18,17 +16,15 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.jxr; /** * Exception occurring in JXR. * * @author Brett Porter */ -public class JxrException - extends Exception -{ - public JxrException( String message, Exception e ) - { - super( message, e ); +public class JxrException extends Exception { + public JxrException(String message, Exception e) { + super(message, e); } } diff --git a/maven-jxr/src/main/java/org/apache/maven/jxr/ant/DirectoryScanner.java b/maven-jxr/src/main/java/org/apache/maven/jxr/ant/DirectoryScanner.java index d1380a95..ed4a175f 100644 --- a/maven-jxr/src/main/java/org/apache/maven/jxr/ant/DirectoryScanner.java +++ b/maven-jxr/src/main/java/org/apache/maven/jxr/ant/DirectoryScanner.java @@ -1,5 +1,3 @@ -package org.apache.maven.jxr.ant; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.jxr.ant; import java.io.File; @@ -26,23 +25,18 @@ * * @author Carlos Sanchez */ -public class DirectoryScanner - extends org.codehaus.plexus.util.DirectoryScanner -{ +public class DirectoryScanner extends org.codehaus.plexus.util.DirectoryScanner { @Override - public void addDefaultExcludes() - { + public void addDefaultExcludes() { super.addDefaultExcludes(); int excludesLength = excludes == null ? 0 : excludes.length; String[] newExcludes; newExcludes = new String[excludesLength + 1]; - if ( excludesLength > 0 ) - { - System.arraycopy( excludes, 0, newExcludes, 0, excludesLength ); + if (excludesLength > 0) { + System.arraycopy(excludes, 0, newExcludes, 0, excludesLength); } newExcludes[excludesLength] = "**" + File.separatorChar + "package-info.java"; excludes = newExcludes; } - } diff --git a/maven-jxr/src/main/java/org/apache/maven/jxr/pacman/BaseType.java b/maven-jxr/src/main/java/org/apache/maven/jxr/pacman/BaseType.java index 842abf3b..7cb2679f 100644 --- a/maven-jxr/src/main/java/org/apache/maven/jxr/pacman/BaseType.java +++ b/maven-jxr/src/main/java/org/apache/maven/jxr/pacman/BaseType.java @@ -1,5 +1,3 @@ -package org.apache.maven.jxr.pacman; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.jxr.pacman; import java.util.Objects; @@ -26,8 +25,7 @@ * * @author jvanzyl */ -public abstract class BaseType -{ +public abstract class BaseType { private final String name; /** @@ -35,9 +33,8 @@ public abstract class BaseType * * @param name type name */ - public BaseType( String name ) - { - this.name = Objects.requireNonNull( name ); + public BaseType(String name) { + this.name = Objects.requireNonNull(name); } /** @@ -45,16 +42,12 @@ public BaseType( String name ) * * @return The name value */ - public String getName() - { + public String getName() { return this.name; } @Override - public String toString() - { + public String toString() { return getClass().getSimpleName() + "[name=" + name + "]"; } - } - diff --git a/maven-jxr/src/main/java/org/apache/maven/jxr/pacman/ClassType.java b/maven-jxr/src/main/java/org/apache/maven/jxr/pacman/ClassType.java index 3291512a..04d48a11 100644 --- a/maven-jxr/src/main/java/org/apache/maven/jxr/pacman/ClassType.java +++ b/maven-jxr/src/main/java/org/apache/maven/jxr/pacman/ClassType.java @@ -1,5 +1,3 @@ -package org.apache.maven.jxr.pacman; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -18,13 +16,12 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.jxr.pacman; /** * Represents a Java class, interface, enum or record. */ -public class ClassType - extends BaseType -{ +public class ClassType extends BaseType { /** * The name of the file that this class resides in, without path or * extension. It might be different from the name of the class when dealing @@ -39,9 +36,8 @@ public class ClassType * @param name name */ @Deprecated - public ClassType( String name ) - { - this( name, null ); + public ClassType(String name) { + this(name, null); } /** @@ -50,21 +46,18 @@ public ClassType( String name ) * @param name name * @param filename file name */ - public ClassType( String name, String filename ) - { - super( name ); + public ClassType(String name, String filename) { + super(name); - this.setFilename( filename ); + this.setFilename(filename); } - /** * Returns the file name. * * @return file name */ - public String getFilename() - { + public String getFilename() { return filename; } @@ -73,8 +66,7 @@ public String getFilename() * * @param filename file name */ - public void setFilename( String filename ) - { + public void setFilename(String filename) { this.filename = filename; } } diff --git a/maven-jxr/src/main/java/org/apache/maven/jxr/pacman/FileManager.java b/maven-jxr/src/main/java/org/apache/maven/jxr/pacman/FileManager.java index 205b8861..9576dcc5 100644 --- a/maven-jxr/src/main/java/org/apache/maven/jxr/pacman/FileManager.java +++ b/maven-jxr/src/main/java/org/apache/maven/jxr/pacman/FileManager.java @@ -1,5 +1,3 @@ -package org.apache.maven.jxr.pacman; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.jxr.pacman; import java.io.IOException; import java.nio.file.Path; @@ -35,8 +34,7 @@ * Note. This assumes that the file will not be modified on disk while * Alexandria is running.

*/ -public class FileManager -{ +public class FileManager { private Map files = new HashMap<>(); private String encoding = null; @@ -49,16 +47,13 @@ public class FileManager * @return the {@link JavaFile} meta object for the specified file * @throws IOException on parsing failure */ - public JavaFile getFile( Path path ) - throws IOException - { + public JavaFile getFile(Path path) throws IOException { - JavaFile real = this.files.get( path ); + JavaFile real = this.files.get(path); - if ( real == null ) - { - real = new JavaFileImpl( path, this.getEncoding() ); - this.addFile( real ); + if (real == null) { + real = new JavaFileImpl(path, this.getEncoding()); + this.addFile(real); } return real; @@ -68,9 +63,8 @@ public JavaFile getFile( Path path ) * Add a file to this file manager. * @param file file to add */ - public void addFile( JavaFile file ) - { - this.files.put( file.getPath(), file ); + public void addFile(JavaFile file) { + this.files.put(file.getPath(), file); } /** @@ -78,8 +72,7 @@ public void addFile( JavaFile file ) * * @param encoding encoding of source files */ - public void setEncoding( String encoding ) - { + public void setEncoding(String encoding) { this.encoding = encoding; } @@ -88,8 +81,7 @@ public void setEncoding( String encoding ) * * @return encoding */ - public String getEncoding() - { + public String getEncoding() { return encoding; } } diff --git a/maven-jxr/src/main/java/org/apache/maven/jxr/pacman/ImportType.java b/maven-jxr/src/main/java/org/apache/maven/jxr/pacman/ImportType.java index d9d9f33c..bbdf36b8 100644 --- a/maven-jxr/src/main/java/org/apache/maven/jxr/pacman/ImportType.java +++ b/maven-jxr/src/main/java/org/apache/maven/jxr/pacman/ImportType.java @@ -1,5 +1,3 @@ -package org.apache.maven.jxr.pacman; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -18,13 +16,12 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.jxr.pacman; /** * Represents an entry in a java "import" statement */ -public class ImportType - extends BaseType -{ +public class ImportType extends BaseType { private boolean isclass = false; @@ -37,22 +34,19 @@ public class ImportType * * @param name name */ - public ImportType( String name ) - { - super( name ); + public ImportType(String name) { + super(name); - //compute member variables + // compute member variables - this.isclass = this.getName().indexOf( '*' ) == -1; + this.isclass = this.getName().indexOf('*') == -1; - this.ispackage = this.getName().indexOf( '*' ) != -1; + this.ispackage = this.getName().indexOf('*') != -1; - int end = this.getName().lastIndexOf( '.' ); - if ( end != -1 ) - { - this.packagename = this.getName().substring( 0, end ); + int end = this.getName().lastIndexOf('.'); + if (end != -1) { + this.packagename = this.getName().substring(0, end); } - } /** @@ -60,8 +54,7 @@ public ImportType( String name ) * * @return true if class import, false otherwise */ - public boolean isClass() - { + public boolean isClass() { return this.isclass; } @@ -70,8 +63,7 @@ public boolean isClass() * * @return true if package, false otherwise */ - public boolean isPackage() - { + public boolean isPackage() { return this.ispackage; } @@ -81,9 +73,7 @@ public boolean isPackage() * * @return package */ - public String getPackage() - { + public String getPackage() { return this.packagename; } - } diff --git a/maven-jxr/src/main/java/org/apache/maven/jxr/pacman/JavaFile.java b/maven-jxr/src/main/java/org/apache/maven/jxr/pacman/JavaFile.java index cb60edf0..6f0be940 100644 --- a/maven-jxr/src/main/java/org/apache/maven/jxr/pacman/JavaFile.java +++ b/maven-jxr/src/main/java/org/apache/maven/jxr/pacman/JavaFile.java @@ -1,5 +1,3 @@ -package org.apache.maven.jxr.pacman; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.jxr.pacman; import java.nio.file.Path; import java.util.ArrayList; @@ -31,8 +30,7 @@ * * @author Kevin A. Burton */ -public abstract class JavaFile -{ +public abstract class JavaFile { private Set imports = new HashSet<>(); private List classTypes = new ArrayList<>(); @@ -45,11 +43,10 @@ public abstract class JavaFile private final String encoding; - protected JavaFile( Path path, String encoding ) - { + protected JavaFile(Path path, String encoding) { this.path = path; this.encoding = encoding; - this.filename = getFilenameWithoutPathOrExtension( path ); + this.filename = getFilenameWithoutPathOrExtension(path); } /** @@ -57,25 +54,20 @@ protected JavaFile( Path path, String encoding ) * * @return import types */ - public Set getImportTypes() - { - return Collections.unmodifiableSet( imports ); + public Set getImportTypes() { + return Collections.unmodifiableSet(imports); } /** * Gets the name of this class. * @return class type */ - public ClassType getClassType() - { - if ( classTypes.isEmpty() ) - { + public ClassType getClassType() { + if (classTypes.isEmpty()) { return null; - } - else - { + } else { // to retain backward compatibility, return the first class - return this.classTypes.get( 0 ); + return this.classTypes.get(0); } } @@ -84,8 +76,7 @@ public ClassType getClassType() * * @return list of class types */ - public List getClassTypes() - { + public List getClassTypes() { return this.classTypes; } @@ -94,20 +85,17 @@ public List getClassTypes() * * @return package type */ - public PackageType getPackageType() - { + public PackageType getPackageType() { return this.packageType; } - /** * Add a class type to the current list of class types. * * @param classType class type */ - public void addClassType( ClassType classType ) - { - this.classTypes.add( classType ); + public void addClassType(ClassType classType) { + this.classTypes.add(classType); } /** @@ -115,9 +103,8 @@ public void addClassType( ClassType classType ) * * @param importType import type */ - public void addImportType( ImportType importType ) - { - this.imports.add( importType ); + public void addImportType(ImportType importType) { + this.imports.add(importType); } /** @@ -125,11 +112,10 @@ public void addImportType( ImportType importType ) * * @param classType class type */ - public void setClassType( ClassType classType ) - { + public void setClassType(ClassType classType) { // to retain backward compatibility, make sure the list contains only the supplied classType this.classTypes.clear(); - this.classTypes.add( classType ); + this.classTypes.add(classType); } /** @@ -137,8 +123,7 @@ public void setClassType( ClassType classType ) * * @param packageType package type */ - public void setPackageType( PackageType packageType ) - { + public void setPackageType(PackageType packageType) { this.packageType = packageType; } @@ -147,8 +132,7 @@ public void setPackageType( PackageType packageType ) * * @return path */ - public Path getPath() - { + public Path getPath() { return this.path; } @@ -157,8 +141,7 @@ public Path getPath() * * @return file name */ - public String getFilename() - { + public String getFilename() { return filename; } @@ -167,8 +150,7 @@ public String getFilename() * * @return encoding */ - public String getEncoding() - { + public String getEncoding() { return this.encoding; } @@ -178,16 +160,13 @@ public String getEncoding() * @param path path to modify * @return modified path */ - protected static String getFilenameWithoutPathOrExtension( Path path ) - { + protected static String getFilenameWithoutPathOrExtension(Path path) { String newFilename = path.getFileName().toString(); // Remove the ".java" extension from the filename, if it exists - int extensionIndex = newFilename.lastIndexOf( ".java" ); - if ( extensionIndex >= 0 ) - { - newFilename = newFilename.substring( 0, extensionIndex ); + int extensionIndex = newFilename.lastIndexOf(".java"); + if (extensionIndex >= 0) { + newFilename = newFilename.substring(0, extensionIndex); } return newFilename; } - } diff --git a/maven-jxr/src/main/java/org/apache/maven/jxr/pacman/JavaFileImpl.java b/maven-jxr/src/main/java/org/apache/maven/jxr/pacman/JavaFileImpl.java index 9c198793..05beb620 100644 --- a/maven-jxr/src/main/java/org/apache/maven/jxr/pacman/JavaFileImpl.java +++ b/maven-jxr/src/main/java/org/apache/maven/jxr/pacman/JavaFileImpl.java @@ -1,5 +1,3 @@ -package org.apache.maven.jxr.pacman; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.jxr.pacman; import java.io.FileInputStream; import java.io.FileReader; @@ -36,11 +35,9 @@ * * @author Kevin A. Burton */ -public class JavaFileImpl - extends JavaFile -{ +public class JavaFileImpl extends JavaFile { - private final List classTypes = Arrays.asList( "class", "interface", "enum", "record" ); + private final List classTypes = Arrays.asList("class", "interface", "enum", "record"); /** * Constructor of a new object that points to a given file. @@ -49,93 +46,71 @@ public class JavaFileImpl * @param encoding encoding of the file * @throws IOException on parsing failure */ - public JavaFileImpl( Path path, String encoding ) - throws IOException - { - super( path, encoding ); + public JavaFileImpl(Path path, String encoding) throws IOException { + super(path, encoding); - //always add java.lang.* to the package imports because the JVM always - //does this implicitly. Unless we add this to the ImportTypes JXR - //won't pick up on this. - this.addImportType( new ImportType( "java.lang.*" ) ); + // always add java.lang.* to the package imports because the JVM always + // does this implicitly. Unless we add this to the ImportTypes JXR + // won't pick up on this. + this.addImportType(new ImportType("java.lang.*")); - //now parse out this file. + // now parse out this file. this.parse(); } /** * Opens up the file and try to determine package, class and import statements. */ - private void parse() - throws IOException - { + private void parse() throws IOException { StreamTokenizer stok = null; - try ( Reader reader = getReader() ) - { - stok = this.getTokenizer( reader ); + try (Reader reader = getReader()) { + stok = this.getTokenizer(reader); - parseRecursive( "", stok ); - } - finally - { + parseRecursive("", stok); + } finally { stok = null; } } - private void parseRecursive( String nestedPrefix, StreamTokenizer stok ) - throws IOException - { + private void parseRecursive(String nestedPrefix, StreamTokenizer stok) throws IOException { int openBracesCount = 0; char prevttype = Character.MIN_VALUE; // previous token type boolean inTripleQuote = false; // used to toggle between inside/outside triple-quoted multi-line strings - while ( stok.nextToken() != StreamTokenizer.TT_EOF ) - { + while (stok.nextToken() != StreamTokenizer.TT_EOF) { - if ( stok.sval == null ) - { - if ( stok.ttype == '{' ) - { + if (stok.sval == null) { + if (stok.ttype == '{') { openBracesCount++; - } - else if ( stok.ttype == '}' ) - { - if ( --openBracesCount == 0 ) - { + } else if (stok.ttype == '}') { + if (--openBracesCount == 0) { // break out of recursive return; } } continue; - } - else - { - if ( '"' == stok.ttype && '"' == prevttype ) - { + } else { + if ('"' == stok.ttype && '"' == prevttype) { inTripleQuote = !inTripleQuote; } prevttype = (char) stok.ttype; - if ( inTripleQuote ) - { + if (inTripleQuote) { // skip content found inside triple-quoted multi-line Java 15 String continue; } } - //set the package - if ( "package".equals( stok.sval ) && stok.ttype != '\"' ) - { + // set the package + if ("package".equals(stok.sval) && stok.ttype != '\"') { stok.nextToken(); - if ( stok.sval != null ) - { - this.setPackageType( new PackageType( stok.sval ) ); + if (stok.sval != null) { + this.setPackageType(new PackageType(stok.sval)); } } - //set the imports - if ( "import".equals( stok.sval ) && stok.ttype != '\"' ) - { + // set the imports + if ("import".equals(stok.sval) && stok.ttype != '\"') { stok.nextToken(); String name = stok.sval; @@ -147,64 +122,52 @@ and packages that are imported with this (ex "test.*") will be stripped( and become "test." ). Here we need to test for this and if necessary re-add the char. */ - if ( name != null ) - { - if ( name.charAt( name.length() - 1 ) == '.' ) - { + if (name != null) { + if (name.charAt(name.length() - 1) == '.') { name = name + '*'; } - this.addImportType( new ImportType( name ) ); + this.addImportType(new ImportType(name)); } } // Add the class or classes. There can be several classes in one file so // continue with the while loop to get them all. - if ( classTypes.contains( stok.sval ) && stok.ttype != '"' ) - { + if (classTypes.contains(stok.sval) && stok.ttype != '"') { stok.nextToken(); - if ( stok.sval != null ) - { - this.addClassType( new ClassType( nestedPrefix + stok.sval, - getFilenameWithoutPathOrExtension( this.getPath() ) ) ); - parseRecursive( nestedPrefix + stok.sval + ".", stok ); + if (stok.sval != null) { + this.addClassType( + new ClassType(nestedPrefix + stok.sval, getFilenameWithoutPathOrExtension(this.getPath()))); + parseRecursive(nestedPrefix + stok.sval + ".", stok); } } - } } /** * Gets a {@link StreamTokenizer} for this file. */ - private StreamTokenizer getTokenizer( Reader reader ) - { - StreamTokenizer stok = new StreamTokenizer( reader ); + private StreamTokenizer getTokenizer(Reader reader) { + StreamTokenizer stok = new StreamTokenizer(reader); - stok.commentChar( '*' ); - stok.wordChars( '_', '_' ); + stok.commentChar('*'); + stok.wordChars('_', '_'); // set tokenizer to skip comments - stok.slashStarComments( true ); - stok.slashSlashComments( true ); + stok.slashStarComments(true); + stok.slashSlashComments(true); return stok; } - private Reader getReader() - throws IOException - { - if ( Files.notExists( this.getPath() ) ) - { - throw new IOException( this.getPath() + " does not exist!" ); + private Reader getReader() throws IOException { + if (Files.notExists(this.getPath())) { + throw new IOException(this.getPath() + " does not exist!"); } - if ( this.getEncoding() != null ) - { - return new InputStreamReader( new FileInputStream( this.getPath().toFile() ), this.getEncoding() ); - } - else - { - return new FileReader( this.getPath().toFile() ); + if (this.getEncoding() != null) { + return new InputStreamReader(new FileInputStream(this.getPath().toFile()), this.getEncoding()); + } else { + return new FileReader(this.getPath().toFile()); } } } diff --git a/maven-jxr/src/main/java/org/apache/maven/jxr/pacman/PackageManager.java b/maven-jxr/src/main/java/org/apache/maven/jxr/pacman/PackageManager.java index 347d17fc..38d67c2f 100644 --- a/maven-jxr/src/main/java/org/apache/maven/jxr/pacman/PackageManager.java +++ b/maven-jxr/src/main/java/org/apache/maven/jxr/pacman/PackageManager.java @@ -1,5 +1,3 @@ -package org.apache.maven.jxr.pacman; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -18,10 +16,7 @@ * specific language governing permissions and limitations * under the License. */ - -import org.codehaus.plexus.util.DirectoryScanner; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +package org.apache.maven.jxr.pacman; import java.io.IOException; import java.nio.file.Path; @@ -31,13 +26,16 @@ import java.util.Map; import java.util.Set; +import org.codehaus.plexus.util.DirectoryScanner; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + /** * Given a list of directories, parse them out and store them as rendered * packages, classes, imports, etc. */ -public class PackageManager -{ - private static final Logger LOGGER = LoggerFactory.getLogger( PackageManager.class ); +public class PackageManager { + private static final Logger LOGGER = LoggerFactory.getLogger(PackageManager.class); private final FileManager fileManager; @@ -53,7 +51,6 @@ public class PackageManager */ private PackageType defaultPackage = new PackageType(); - /** * The list of exclude patterns to use. */ @@ -62,10 +59,9 @@ public class PackageManager /** * The list of include patterns to use. */ - private String[] includes = { "**/*.java" }; + private String[] includes = {"**/*.java"}; - public PackageManager( FileManager fileManager ) - { + public PackageManager(FileManager fileManager) { this.fileManager = fileManager; } @@ -76,15 +72,13 @@ public PackageManager( FileManager fileManager ) * @param name name of package * @return package type if found or default package type */ - public PackageType getPackageType( String name ) - { - //return the default package if the name is null. - if ( name == null ) - { + public PackageType getPackageType(String name) { + // return the default package if the name is null. + if (name == null) { return defaultPackage; } - return this.packages.get( name ); + return this.packages.get(name); } /** @@ -92,9 +86,8 @@ public PackageType getPackageType( String name ) * * @param packageType package type to add */ - public void addPackageType( PackageType packageType ) - { - this.packages.put( packageType.getName(), packageType ); + public void addPackageType(PackageType packageType) { + this.packages.put(packageType.getName(), packageType); } /** @@ -102,101 +95,81 @@ public void addPackageType( PackageType packageType ) * * @return package types */ - public Collection getPackageTypes() - { + public Collection getPackageTypes() { return packages.values(); } /** * Parse out all the directories on which this depends. */ - private void parse( Path baseDir ) - { + private void parse(Path baseDir) { // Go through each directory and get the java source // files for this dir. - LOGGER.debug( "Scanning " + baseDir ); + LOGGER.debug("Scanning " + baseDir); DirectoryScanner directoryScanner = new DirectoryScanner(); - directoryScanner.setBasedir( baseDir.toFile() ); - directoryScanner.setExcludes( excludes ); - directoryScanner.setIncludes( includes ); + directoryScanner.setBasedir(baseDir.toFile()); + directoryScanner.setExcludes(excludes); + directoryScanner.setIncludes(includes); directoryScanner.scan(); - for ( String file : directoryScanner.getIncludedFiles() ) - { - LOGGER.debug( "parsing... " + file ); + for (String file : directoryScanner.getIncludedFiles()) { + LOGGER.debug("parsing... " + file); - //now parse out this file to get the packages/classname/etc - try - { - Path fileName = baseDir.resolve( file ); - JavaFile jfi = fileManager.getFile( fileName ); + // now parse out this file to get the packages/classname/etc + try { + Path fileName = baseDir.resolve(file); + JavaFile jfi = fileManager.getFile(fileName); // now that we have this parsed out blend its information // with the current package structure - PackageType jp = this.getPackageType( jfi.getPackageType().getName() ); + PackageType jp = this.getPackageType(jfi.getPackageType().getName()); - if ( jp == null ) - { - this.addPackageType( jfi.getPackageType() ); + if (jp == null) { + this.addPackageType(jfi.getPackageType()); jp = jfi.getPackageType(); } // Add the current file's class(es) to this global package. - if ( jfi.getClassTypes() != null && !jfi.getClassTypes().isEmpty() ) - { - for ( ClassType ct : jfi.getClassTypes() ) - { - jp.addClassType( ct ); + if (jfi.getClassTypes() != null && !jfi.getClassTypes().isEmpty()) { + for (ClassType ct : jfi.getClassTypes()) { + jp.addClassType(ct); } } - } - catch ( IOException e ) - { + } catch (IOException e) { e.printStackTrace(); } - } - } - public void process( Path directory ) - { - if ( this.directories.add( directory ) ) - { - this.parse( directory ); + public void process(Path directory) { + if (this.directories.add(directory)) { + this.parse(directory); } } /** * Dump the package information to STDOUT. FOR DEBUG ONLY */ - public void dump() - { + public void dump() { - LOGGER.debug( "Dumping out PackageManager structure" ); + LOGGER.debug("Dumping out PackageManager structure"); - for ( PackageType current : getPackageTypes() ) - { - LOGGER.debug( current.getName() ); + for (PackageType current : getPackageTypes()) { + LOGGER.debug(current.getName()); - //get the classes under the package and print those too. - for ( ClassType currentClass : current.getClassTypes() ) - { - LOGGER.debug( '\t' + currentClass.getName() ); + // get the classes under the package and print those too. + for (ClassType currentClass : current.getClassTypes()) { + LOGGER.debug('\t' + currentClass.getName()); } } } - public void setExcludes( String[] excludes ) - { + public void setExcludes(String[] excludes) { this.excludes = excludes; } - - public void setIncludes( String[] includes ) - { + public void setIncludes(String[] includes) { this.includes = includes; } } - diff --git a/maven-jxr/src/main/java/org/apache/maven/jxr/pacman/PackageType.java b/maven-jxr/src/main/java/org/apache/maven/jxr/pacman/PackageType.java index 0920adbc..79a7266e 100644 --- a/maven-jxr/src/main/java/org/apache/maven/jxr/pacman/PackageType.java +++ b/maven-jxr/src/main/java/org/apache/maven/jxr/pacman/PackageType.java @@ -1,5 +1,3 @@ -package org.apache.maven.jxr.pacman; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.jxr.pacman; import java.util.Collection; import java.util.HashMap; @@ -26,9 +25,7 @@ /** * Represents a Java package and its subclasses. */ -public class PackageType - extends BaseType -{ +public class PackageType extends BaseType { private Map classes = new HashMap<>(); @@ -37,17 +34,15 @@ public class PackageType * * @param name name of package */ - public PackageType( String name ) - { - super( name ); + public PackageType(String name) { + super(name); } /** * Creates a Java package with no name IE the default Java package. */ - public PackageType() - { - super( "" ); + public PackageType() { + super(""); } /** @@ -55,8 +50,7 @@ public PackageType() * * @return collection of class types */ - public Collection getClassTypes() - { + public Collection getClassTypes() { return classes.values(); } @@ -65,11 +59,9 @@ public Collection getClassTypes() * * @param classType class type to add */ - public void addClassType( ClassType classType ) - { - - this.classes.put( classType.getName(), classType ); + public void addClassType(ClassType classType) { + this.classes.put(classType.getName(), classType); } /** @@ -79,10 +71,8 @@ public void addClassType( ClassType classType ) * @param classType class type String * @return class type object */ - public ClassType getClassType( String classType ) - { + public ClassType getClassType(String classType) { - return this.classes.get( classType ); + return this.classes.get(classType); } - } diff --git a/maven-jxr/src/main/java/org/apache/maven/jxr/util/SimpleWordTokenizer.java b/maven-jxr/src/main/java/org/apache/maven/jxr/util/SimpleWordTokenizer.java index db392f45..8b800fd9 100644 --- a/maven-jxr/src/main/java/org/apache/maven/jxr/util/SimpleWordTokenizer.java +++ b/maven-jxr/src/main/java/org/apache/maven/jxr/util/SimpleWordTokenizer.java @@ -1,5 +1,3 @@ -package org.apache.maven.jxr.util; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.jxr.util; import java.util.ArrayList; import java.util.Collections; @@ -30,12 +29,11 @@ * considers clear words that are only ended with spaces as strings. EX: "Flight" would be a word but "Flight()" would * not. */ -public class SimpleWordTokenizer -{ +public class SimpleWordTokenizer { - private static final Pattern NONBREAKERS = Pattern.compile( "([^()\\[ {}]+)" ); + private static final Pattern NONBREAKERS = Pattern.compile("([^()\\[ {}]+)"); - private static final char[] BREAKERS = { '(', ')', '[', ' ', '{', '}' }; + private static final char[] BREAKERS = {'(', ')', '[', ' ', '{', '}'}; /** * Breaks the given line into multiple tokens. @@ -43,23 +41,21 @@ public class SimpleWordTokenizer * @param line line to tokenize * @return list of tokens */ - public static List tokenize( String line ) - { + public static List tokenize(String line) { /* * determine where to start processing this String... this could either be the start of the line or just keep * going until the first */ - int start = getStart( line ); + int start = getStart(line); // find the first non-BREAKER char and assume that is where you want to start - if ( line == null || line.length() == 0 || start == -1 ) - { + if (line == null || line.length() == 0 || start == -1) { return Collections.emptyList(); } - return tokenize( line, start ); + return tokenize(line, start); } /** @@ -69,19 +65,15 @@ public static List tokenize( String line ) * @param find String to match * @return list of matching tokens */ - public static List tokenize( String line, String find ) - { + public static List tokenize(String line, String find) { List foundTokens = new ArrayList<>(); - for ( StringEntry se : tokenize( line ) ) - { + for (StringEntry se : tokenize(line)) { - if ( se.toString().equals( find ) ) - { - foundTokens.add( se ); + if (se.toString().equals(find)) { + foundTokens.add(se); } - } return foundTokens; @@ -90,16 +82,14 @@ public static List tokenize( String line, String find ) /** * Internal impl. Specify the start and end. */ - private static List tokenize( String line, int start ) - { - Matcher matcher = NONBREAKERS.matcher( line.substring( start ) ); + private static List tokenize(String line, int start) { + Matcher matcher = NONBREAKERS.matcher(line.substring(start)); List words = new ArrayList<>(); - while ( matcher.find() ) - { - StringEntry entry = new StringEntry( matcher.group( 1 ), matcher.start() + start ); - words.add( entry ); + while (matcher.find()) { + StringEntry entry = new StringEntry(matcher.group(1), matcher.start() + start); + words.add(entry); } return words; @@ -108,17 +98,13 @@ private static List tokenize( String line, int start ) /** * Go through the list of BREAKERS and find the closes one. */ - private static int getStart( String string ) - { + private static int getStart(String string) { - for ( int i = 0; i < string.length(); ++i ) - { + for (int i = 0; i < string.length(); ++i) { - if ( !isBreaker( string.charAt( i ) ) ) - { + if (!isBreaker(string.charAt(i))) { return i; } - } return -1; @@ -127,20 +113,15 @@ private static int getStart( String string ) /** * Return true if the given char is considered a breaker. */ - private static boolean isBreaker( char c ) - { + private static boolean isBreaker(char c) { - for ( char breaker : BREAKERS ) - { + for (char breaker : BREAKERS) { - if ( breaker == c ) - { + if (breaker == c) { return true; } - } return false; } - } diff --git a/maven-jxr/src/main/java/org/apache/maven/jxr/util/StringEntry.java b/maven-jxr/src/main/java/org/apache/maven/jxr/util/StringEntry.java index 13c21c32..1da4b646 100644 --- a/maven-jxr/src/main/java/org/apache/maven/jxr/util/StringEntry.java +++ b/maven-jxr/src/main/java/org/apache/maven/jxr/util/StringEntry.java @@ -1,5 +1,3 @@ -package org.apache.maven.jxr.util; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -18,13 +16,13 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.jxr.util; /** * A StringEntry represents a value found by the tokenizer. The index is where * this StringEntry was found in the source string. */ -public final class StringEntry -{ +public final class StringEntry { private final String value; private final int index; @@ -35,8 +33,7 @@ public final class StringEntry * @param value value * @param index index */ - public StringEntry( String value, int index ) - { + public StringEntry(String value, int index) { this.value = value; this.index = index; } @@ -46,15 +43,12 @@ public StringEntry( String value, int index ) * * @return index */ - public int getIndex() - { + public int getIndex() { return this.index; } @Override - public String toString() - { + public String toString() { return this.value; } - } diff --git a/maven-jxr/src/test/java/org/apache/maven/jxr/DirectoryIndexerTest.java b/maven-jxr/src/test/java/org/apache/maven/jxr/DirectoryIndexerTest.java index 23251763..fd6d9e65 100644 --- a/maven-jxr/src/test/java/org/apache/maven/jxr/DirectoryIndexerTest.java +++ b/maven-jxr/src/test/java/org/apache/maven/jxr/DirectoryIndexerTest.java @@ -1,5 +1,3 @@ -package org.apache.maven.jxr; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -18,9 +16,7 @@ * specific language governing permissions and limitations * under the License. */ - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +package org.apache.maven.jxr; import java.nio.file.Paths; import java.util.Iterator; @@ -34,55 +30,54 @@ import org.junit.Before; import org.junit.Test; -public class DirectoryIndexerTest -{ +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +public class DirectoryIndexerTest { private DirectoryIndexer directoryIndexer; - + @Before - public void setUp() - { + public void setUp() { FileManager fileManager = new FileManager(); - PackageManager packageManager = new PackageManager( fileManager ); - packageManager.process( Paths.get( "src/test/resources/jxr68" ) ); + PackageManager packageManager = new PackageManager(fileManager); + packageManager.process(Paths.get("src/test/resources/jxr68")); - directoryIndexer = new DirectoryIndexer( packageManager, "" ); + directoryIndexer = new DirectoryIndexer(packageManager, ""); } - + /** * Parse the files in test/resources/jxr68 packages, ensure all are present in the allClasses Map, * in the correct order. */ @Test - public void testJXR_68() - { + public void testJXR_68() { ProjectInfo packageInfo = directoryIndexer.getProjectInfo(); final Map allPackages = packageInfo.getAllPackages(); assertEquals(3, allPackages.size()); - assertTrue( allPackages.containsKey( "(default package)" ) ); - assertTrue( allPackages.containsKey( "pkga" ) ); - assertTrue( allPackages.containsKey( "pkgb" ) ); + assertTrue(allPackages.containsKey("(default package)")); + assertTrue(allPackages.containsKey("pkga")); + assertTrue(allPackages.containsKey("pkgb")); final Map allClasses = packageInfo.getAllClasses(); - assertEquals( 6, allClasses.size() ); + assertEquals(6, allClasses.size()); final Iterator iterator = allClasses.values().iterator(); // #1: AClass - assertEquals( "AClass", iterator.next().getName() ); + assertEquals("AClass", iterator.next().getName()); // #2: BClass - assertEquals( "BClass", iterator.next().getName() ); + assertEquals("BClass", iterator.next().getName()); // #3: CClass - assertEquals( "CClass", iterator.next().getName() ); + assertEquals("CClass", iterator.next().getName()); // #4: SomeClass in default package ClassInfo classInfo = iterator.next(); - assertEquals( "SomeClass", classInfo.getName() ); - assertEquals( ".", classInfo.getDir() ); + assertEquals("SomeClass", classInfo.getName()); + assertEquals(".", classInfo.getDir()); // #5: SomeClass in "pkga" classInfo = iterator.next(); - assertEquals( "SomeClass", classInfo.getName() ); - assertEquals( "pkga", classInfo.getDir() ); + assertEquals("SomeClass", classInfo.getName()); + assertEquals("pkga", classInfo.getDir()); // #6: SomeClass in "pkgb" classInfo = iterator.next(); - assertEquals( "SomeClass", classInfo.getName() ); - assertEquals( "pkgb", classInfo.getDir() ); + assertEquals("SomeClass", classInfo.getName()); + assertEquals("pkgb", classInfo.getDir()); } - -} \ No newline at end of file +} diff --git a/maven-jxr/src/test/java/org/apache/maven/jxr/IncludeExcludeTest.java b/maven-jxr/src/test/java/org/apache/maven/jxr/IncludeExcludeTest.java index ca609323..22356ff6 100644 --- a/maven-jxr/src/test/java/org/apache/maven/jxr/IncludeExcludeTest.java +++ b/maven-jxr/src/test/java/org/apache/maven/jxr/IncludeExcludeTest.java @@ -1,5 +1,3 @@ -package org.apache.maven.jxr; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -18,9 +16,7 @@ * specific language governing permissions and limitations * under the License. */ - -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +package org.apache.maven.jxr; import java.nio.file.Files; import java.nio.file.Path; @@ -32,44 +28,42 @@ import org.junit.Before; import org.junit.Test; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + /** * Test include/exclude patterns. * * @author Dennis Lundberg */ -public class IncludeExcludeTest -{ +public class IncludeExcludeTest { private JXR jxr; @Before - public void setUp() - { + public void setUp() { FileManager fileManager = new FileManager(); - PackageManager packageManager = new PackageManager( fileManager ); - JavaCodeTransform codeTransform = new JavaCodeTransform( packageManager, fileManager ); + PackageManager packageManager = new PackageManager(fileManager); + JavaCodeTransform codeTransform = new JavaCodeTransform(packageManager, fileManager); - jxr = new JXR( packageManager, codeTransform ); - jxr.setDest( Paths.get( "target" ) ); - jxr.setInputEncoding( "ISO-8859-1" ); - jxr.setOutputEncoding( "ISO-8859-1" ); - jxr.setJavadocLinkDir( Paths.get( "." ) ); + jxr = new JXR(packageManager, codeTransform); + jxr.setDest(Paths.get("target")); + jxr.setInputEncoding("ISO-8859-1"); + jxr.setOutputEncoding("ISO-8859-1"); + jxr.setJavadocLinkDir(Paths.get(".")); } @Test - public void testIncludeExclude() - throws Exception - { + public void testIncludeExclude() throws Exception { String[] excludes = {"**/exclude/ExcludedClass.java"}; - jxr.setExcludes( excludes ); + jxr.setExcludes(excludes); String[] includes = {"**/exclude/*.java", "**/include/IncludedClass.java"}; - jxr.setIncludes( includes ); - jxr.xref( Collections.singletonList( "src/test/resources" ), "templates/jdk4", - "title", "title", "copyright" ); - Path excludedFile = Paths.get( "target/exclude/ExcludedClass.html" ); - assertFalse( Files.exists( excludedFile ) ); - Path includedFile = Paths.get( "target/include/IncludedClass.html" ); - assertTrue( Files.exists( includedFile ) ); - Path notIncludedFile = Paths.get( "target/include/NotIncludedClass.html" ); - assertFalse( Files.exists( notIncludedFile ) ); + jxr.setIncludes(includes); + jxr.xref(Collections.singletonList("src/test/resources"), "templates/jdk4", "title", "title", "copyright"); + Path excludedFile = Paths.get("target/exclude/ExcludedClass.html"); + assertFalse(Files.exists(excludedFile)); + Path includedFile = Paths.get("target/include/IncludedClass.html"); + assertTrue(Files.exists(includedFile)); + Path notIncludedFile = Paths.get("target/include/NotIncludedClass.html"); + assertFalse(Files.exists(notIncludedFile)); } } diff --git a/maven-jxr/src/test/java/org/apache/maven/jxr/JXR141Test.java b/maven-jxr/src/test/java/org/apache/maven/jxr/JXR141Test.java index 6b04be36..2b1a6f03 100644 --- a/maven-jxr/src/test/java/org/apache/maven/jxr/JXR141Test.java +++ b/maven-jxr/src/test/java/org/apache/maven/jxr/JXR141Test.java @@ -1,5 +1,3 @@ -package org.apache.maven.jxr; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -18,9 +16,7 @@ * specific language governing permissions and limitations * under the License. */ - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; +package org.apache.maven.jxr; import java.nio.charset.StandardCharsets; import java.nio.file.Files; @@ -33,51 +29,54 @@ import org.junit.Before; import org.junit.Test; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + /** * Simple unit-testtest that illustrates a line with more * than one "token" to replace */ -public class JXR141Test -{ +public class JXR141Test { private JXR jxr; @Before - public void setUp() - { + public void setUp() { FileManager fileManager = new FileManager(); - PackageManager packageManager = new PackageManager( fileManager ); - JavaCodeTransform codeTransform = new JavaCodeTransform( packageManager, fileManager ); - - jxr = new JXR( packageManager, codeTransform ); + PackageManager packageManager = new PackageManager(fileManager); + JavaCodeTransform codeTransform = new JavaCodeTransform(packageManager, fileManager); + + jxr = new JXR(packageManager, codeTransform); } - + @Test - public void testProcessPath() throws Exception - { - jxr.setDest( Paths.get("target/jxr-141" ) ); - jxr.setOutputEncoding( "UTF-8" ); - jxr.xref( Collections.singletonList( "src/test/resources/jxr141" ),"templates/jdk4", - "title", "title", "copyright" ); + public void testProcessPath() throws Exception { + jxr.setDest(Paths.get("target/jxr-141")); + jxr.setOutputEncoding("UTF-8"); + jxr.xref( + Collections.singletonList("src/test/resources/jxr141"), + "templates/jdk4", + "title", + "title", + "copyright"); - List lines = Files.readAllLines( Paths.get( "target/jxr-141/Test141.html" ), - StandardCharsets.UTF_8 ); + List lines = Files.readAllLines(Paths.get("target/jxr-141/Test141.html"), StandardCharsets.UTF_8); // Find line #27... String line27 = null; - for ( String line : lines ) - { - if ( line.contains( "#L27" ) ) - { + for (String line : lines) { + if (line.contains("#L27")) { line27 = line; break; } } - - assertNotNull( "Line #27 not found - has source of Test141.java changed?", line27 ); - assertEquals( "27 " + - "public static " + - "final " + - "Test141 instance = new " + - "Test141();" , line27 ); + + assertNotNull("Line #27 not found - has source of Test141.java changed?", line27); + assertEquals( + "27 " + + "public static " + + "final " + + "Test141 instance = new " + + "Test141();", + line27); } -} \ No newline at end of file +} diff --git a/maven-jxr/src/test/java/org/apache/maven/jxr/JavaCodeTransformTest.java b/maven-jxr/src/test/java/org/apache/maven/jxr/JavaCodeTransformTest.java index 8457aad8..84e46583 100644 --- a/maven-jxr/src/test/java/org/apache/maven/jxr/JavaCodeTransformTest.java +++ b/maven-jxr/src/test/java/org/apache/maven/jxr/JavaCodeTransformTest.java @@ -1,5 +1,3 @@ -package org.apache.maven.jxr; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.jxr; import java.nio.charset.StandardCharsets; import java.nio.file.Files; @@ -35,16 +34,14 @@ /** * JUnit test for {@link JavaCodeTransform}. */ -public class JavaCodeTransformTest -{ +public class JavaCodeTransformTest { /** JavaCodeTransform object under test */ private JavaCodeTransform codeTransform; @Before - public void setUp() - { + public void setUp() { FileManager fileManager = new FileManager(); - codeTransform = new JavaCodeTransform( new PackageManager( fileManager ), fileManager); + codeTransform = new JavaCodeTransform(new PackageManager(fileManager), fileManager); } /** @@ -52,90 +49,110 @@ public void setUp() */ @Test public void testTransform() - //test transforms its own sourcefile, so add some comments - throws Exception // single line despite /* - { - Path sourceFile = Paths.get( "src/test/java/org/apache/maven/jxr/JavaCodeTransformTest.java" ); - assertTrue( /* mid-line comment */ Files.exists( sourceFile ) ); /* + // test transforms its own sourcefile, so add some comments + throws Exception // single line despite /* + { + Path sourceFile = Paths.get("src/test/java/org/apache/maven/jxr/JavaCodeTransformTest.java"); + assertTrue(/* mid-line comment */ Files.exists(sourceFile)); /* multiline comment text - */ codeTransform.transform( sourceFile, Paths.get( "target/JavaCodeTransformTest.html" ) // additional comment - , Locale.ENGLISH, "ISO-8859-1", "ISO-8859-1", Paths.get( "./javadocs-test" ), "", "" ); - assertTrue( /**/ Files.exists( Paths.get( "target/JavaCodeTransformTest.html" ) ) ); - - byte[] bytes = Files.readAllBytes( Paths.get( "target/JavaCodeTransformTest.html" ) ); - String content = new String( bytes, StandardCharsets.ISO_8859_1 ); - assertTrue( content.contains( "JavaCodeTransformTest xref" ) ); - assertTrue( content.contains( "" - + "View Javadoc" ) ); + */ + codeTransform.transform( + sourceFile, + Paths.get("target/JavaCodeTransformTest.html") // additional comment + , + Locale.ENGLISH, + "ISO-8859-1", + "ISO-8859-1", + Paths.get("./javadocs-test"), + "", + ""); + assertTrue(/**/ Files.exists(Paths.get("target/JavaCodeTransformTest.html"))); + + byte[] bytes = Files.readAllBytes(Paths.get("target/JavaCodeTransformTest.html")); + String content = new String(bytes, StandardCharsets.ISO_8859_1); + assertTrue(content.contains("JavaCodeTransformTest xref")); + assertTrue(content.contains( + "" + "View Javadoc")); } /** * Test what happens with an empty sourcefile. */ @Test - public void testTransformWithEmptyClassFile() - throws Exception - { - Path sourceFile = Paths.get( "src/test/resources/EmptyClass.java" ); - assertTrue( Files.exists( sourceFile ) ); - - codeTransform.transform( sourceFile, Paths.get( "target/EmptyClass.html" ) - , Locale.ENGLISH, "ISO-8859-1", "ISO-8859-1", Paths.get( "javadocs" ), "", "" ); - assertTrue( Files.exists( Paths.get( "target/EmptyClass.html" ) ) ); - - byte[] bytes = Files.readAllBytes( Paths.get( "target/EmptyClass.html" ) ); - String content = new String( bytes, StandardCharsets.ISO_8859_1 ); - assertTrue( content.contains( "EmptyClass xref" ) ); - assertTrue( content.contains( "View Javadoc" ) ); + public void testTransformWithEmptyClassFile() throws Exception { + Path sourceFile = Paths.get("src/test/resources/EmptyClass.java"); + assertTrue(Files.exists(sourceFile)); + + codeTransform.transform( + sourceFile, + Paths.get("target/EmptyClass.html"), + Locale.ENGLISH, + "ISO-8859-1", + "ISO-8859-1", + Paths.get("javadocs"), + "", + ""); + assertTrue(Files.exists(Paths.get("target/EmptyClass.html"))); + + byte[] bytes = Files.readAllBytes(Paths.get("target/EmptyClass.html")); + String content = new String(bytes, StandardCharsets.ISO_8859_1); + assertTrue(content.contains("EmptyClass xref")); + assertTrue(content.contains("View Javadoc")); } /** * Test proper handling of link */ @Test - public void testLinkHandling() - throws Exception - { - Path sourceFile = Paths.get( "src/test/resources/ClassWithLink.java" ); - assertTrue( Files.exists( sourceFile ) ); - - codeTransform.transform( sourceFile, Paths.get( "target/ClassWithLink.html" ) - , Locale.ENGLISH, "ISO-8859-1", "ISO-8859-1", Paths.get( "." ), "", "" ); - assertTrue( Files.exists( Paths.get( "target/ClassWithLink.html" ) ) ); - - byte[] bytes = Files.readAllBytes( Paths.get( "target/ClassWithLink.html" ) ); - String content = new String( bytes, StandardCharsets.ISO_8859_1 ); + public void testLinkHandling() throws Exception { + Path sourceFile = Paths.get("src/test/resources/ClassWithLink.java"); + assertTrue(Files.exists(sourceFile)); + + codeTransform.transform( + sourceFile, + Paths.get("target/ClassWithLink.html"), + Locale.ENGLISH, + "ISO-8859-1", + "ISO-8859-1", + Paths.get("."), + "", + ""); + assertTrue(Files.exists(Paths.get("target/ClassWithLink.html"))); + + byte[] bytes = Files.readAllBytes(Paths.get("target/ClassWithLink.html")); + String content = new String(bytes, StandardCharsets.ISO_8859_1); // The proper link in its full length - assertTrue( content.contains( - "http://www.apache.org/licenses/LICENSE-2.0" ) ); + assertTrue(content.contains("http://www.apache.org/licenses/LICENSE-2.0")); // ...and the same link with https protocol - assertTrue( content.contains( - "https://www.apache.org/licenses/LICENSE-2.0" ) ); - + assertTrue(content.contains("https://www.apache.org/licenses/LICENSE-2.0")); } /** * Test what happens with unknown java type. */ @Test - public void testTransformWithUnknownJavaType() - throws Exception - { - Path sourceFile = Paths.get( "src/test/resources/UnknownType.java" ); - assertTrue( Files.exists( sourceFile ) ); - - codeTransform.transform( sourceFile, Paths.get( "target/UnknownType.html" ) - , Locale.ENGLISH, "ISO-8859-1", "ISO-8859-1", Paths.get( "javadocs" ), "", "" ); - assertTrue( Files.exists( Paths.get( "target/UnknownType.html" ) ) ); - - byte[] bytes = Files.readAllBytes( Paths.get( "target/UnknownType.html" ) ); - String content = new String( bytes, StandardCharsets.ISO_8859_1 ); - assertTrue( content.contains( "UnknownType xref" ) ); - assertTrue( content.contains( "View Javadoc" ) ); + public void testTransformWithUnknownJavaType() throws Exception { + Path sourceFile = Paths.get("src/test/resources/UnknownType.java"); + assertTrue(Files.exists(sourceFile)); + + codeTransform.transform( + sourceFile, + Paths.get("target/UnknownType.html"), + Locale.ENGLISH, + "ISO-8859-1", + "ISO-8859-1", + Paths.get("javadocs"), + "", + ""); + assertTrue(Files.exists(Paths.get("target/UnknownType.html"))); + + byte[] bytes = Files.readAllBytes(Paths.get("target/UnknownType.html")); + String content = new String(bytes, StandardCharsets.ISO_8859_1); + assertTrue(content.contains("UnknownType xref")); + assertTrue(content.contains("View Javadoc")); } - } diff --git a/maven-jxr/src/test/java/org/apache/maven/jxr/JxrBeanTest.java b/maven-jxr/src/test/java/org/apache/maven/jxr/JxrBeanTest.java index 10c75492..3e688c8b 100644 --- a/maven-jxr/src/test/java/org/apache/maven/jxr/JxrBeanTest.java +++ b/maven-jxr/src/test/java/org/apache/maven/jxr/JxrBeanTest.java @@ -1,5 +1,3 @@ -package org.apache.maven.jxr; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.jxr; import java.nio.file.Paths; import java.util.Collections; @@ -27,28 +26,23 @@ import org.junit.Before; import org.junit.Test; -public class JxrBeanTest -{ +public class JxrBeanTest { private JXR jxrBean; @Before - public void setUp() - { FileManager fileManager = new FileManager(); - PackageManager packageManager = new PackageManager( fileManager ); - JavaCodeTransform codeTransform = new JavaCodeTransform( packageManager, fileManager ); - jxrBean = new JXR( packageManager, codeTransform ); - jxrBean.setDest( Paths.get( "target" ) ); - jxrBean.setInputEncoding( "ISO-8859-1" ); - jxrBean.setOutputEncoding( "ISO-8859-1" ); - jxrBean.setJavadocLinkDir( Paths.get( "." ) ); + public void setUp() { + FileManager fileManager = new FileManager(); + PackageManager packageManager = new PackageManager(fileManager); + JavaCodeTransform codeTransform = new JavaCodeTransform(packageManager, fileManager); + jxrBean = new JXR(packageManager, codeTransform); + jxrBean.setDest(Paths.get("target")); + jxrBean.setInputEncoding("ISO-8859-1"); + jxrBean.setOutputEncoding("ISO-8859-1"); + jxrBean.setJavadocLinkDir(Paths.get(".")); } @Test - public void testXref() - throws Exception - { - jxrBean.xref( Collections.singletonList( "src/test/java" ), "templates/jdk4", - "title", "title", "copyright" ); + public void testXref() throws Exception { + jxrBean.xref(Collections.singletonList("src/test/java"), "templates/jdk4", "title", "title", "copyright"); } - } diff --git a/maven-jxr/src/test/java/org/apache/maven/jxr/pacman/JavaFileImplTest.java b/maven-jxr/src/test/java/org/apache/maven/jxr/pacman/JavaFileImplTest.java index 1764bdab..e3032a77 100644 --- a/maven-jxr/src/test/java/org/apache/maven/jxr/pacman/JavaFileImplTest.java +++ b/maven-jxr/src/test/java/org/apache/maven/jxr/pacman/JavaFileImplTest.java @@ -1,5 +1,3 @@ -package org.apache.maven.jxr.pacman; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -18,53 +16,56 @@ * specific language governing permissions and limitations * under the License. */ - -import org.junit.Test; +package org.apache.maven.jxr.pacman; import java.io.IOException; import java.nio.file.Paths; import java.util.Iterator; +import org.junit.Test; + import static org.junit.Assert.assertEquals; public class JavaFileImplTest { @Test - public void testJXR_135_lotsOfNested() throws IOException - { - JavaFileImpl javaFile = new JavaFileImpl( Paths.get( - "src/test/resources/jxr135/org/apache/maven/jxr/pacman/ClassWithNested.java" ), - "UTF-8" ); + public void testJXR_135_lotsOfNested() throws IOException { + JavaFileImpl javaFile = new JavaFileImpl( + Paths.get("src/test/resources/jxr135/org/apache/maven/jxr/pacman/ClassWithNested.java"), "UTF-8"); final Iterator classTypes = javaFile.getClassTypes().iterator(); - assertEquals( "ClassWithNested", classTypes.next().getName() ); - assertEquals( "ClassWithNested.NestedInterface", classTypes.next().getName() ); - assertEquals( "ClassWithNested.NestedClassWithEnum", classTypes.next().getName() ); - assertEquals( "ClassWithNested.NestedClassWithEnum.NestedEnum", classTypes.next().getName() ); - assertEquals( "ClassWithNested.NestedClassWithEnum.NestedClass2", classTypes.next().getName() ); - assertEquals( "ClassWithNested.NestedClassWithEnum2", classTypes.next().getName() ); - assertEquals( "ClassWithNested.NestedClassWithEnum2.NestedEnum", classTypes.next().getName() ); - assertEquals( "ClassWithNested.NestedClassWithEnum2.NestedClass2", classTypes.next().getName() ); - assertEquals( "NotNested", classTypes.next().getName() ); + assertEquals("ClassWithNested", classTypes.next().getName()); + assertEquals("ClassWithNested.NestedInterface", classTypes.next().getName()); + assertEquals("ClassWithNested.NestedClassWithEnum", classTypes.next().getName()); + assertEquals( + "ClassWithNested.NestedClassWithEnum.NestedEnum", + classTypes.next().getName()); + assertEquals( + "ClassWithNested.NestedClassWithEnum.NestedClass2", + classTypes.next().getName()); + assertEquals("ClassWithNested.NestedClassWithEnum2", classTypes.next().getName()); + assertEquals( + "ClassWithNested.NestedClassWithEnum2.NestedEnum", + classTypes.next().getName()); + assertEquals( + "ClassWithNested.NestedClassWithEnum2.NestedClass2", + classTypes.next().getName()); + assertEquals("NotNested", classTypes.next().getName()); } @Test - public void testJXR_170_multiLineString() throws IOException - { - JavaFileImpl javaFile = new JavaFileImpl( Paths.get( - "src/test/resources/jxr170/org/apache/maven/jxr/pacman/ClassWithMultiLineString.java" ), - "UTF-8" ); - assertEquals( 1, javaFile.getClassTypes().size() ); - assertEquals( "ClassWithMultiLineString", javaFile.getClassTypes().get(0).getName() ); - assertEquals( "[ImportType[name=java.lang.*]]", javaFile.getImportTypes().toString() ); + public void testJXR_170_multiLineString() throws IOException { + JavaFileImpl javaFile = new JavaFileImpl( + Paths.get("src/test/resources/jxr170/org/apache/maven/jxr/pacman/ClassWithMultiLineString.java"), + "UTF-8"); + assertEquals(1, javaFile.getClassTypes().size()); + assertEquals("ClassWithMultiLineString", javaFile.getClassTypes().get(0).getName()); + assertEquals("[ImportType[name=java.lang.*]]", javaFile.getImportTypes().toString()); } @Test - public void testJXR_175_java14Record() throws IOException - { - JavaFileImpl javaFile = new JavaFileImpl( Paths.get( - "src/test/resources/jxr175/org/apache/maven/jxr/pacman/Java14Record.java" ), - "UTF-8" ); - assertEquals( 1, javaFile.getClassTypes().size() ); - assertEquals( "Java14Record", javaFile.getClassTypes().get(0).getName() ); + public void testJXR_175_java14Record() throws IOException { + JavaFileImpl javaFile = new JavaFileImpl( + Paths.get("src/test/resources/jxr175/org/apache/maven/jxr/pacman/Java14Record.java"), "UTF-8"); + assertEquals(1, javaFile.getClassTypes().size()); + assertEquals("Java14Record", javaFile.getClassTypes().get(0).getName()); } - } diff --git a/maven-jxr/src/test/java/org/apache/maven/jxr/util/SimpleWordTokenizerTest.java b/maven-jxr/src/test/java/org/apache/maven/jxr/util/SimpleWordTokenizerTest.java index 16a5ec11..6f2d7c23 100644 --- a/maven-jxr/src/test/java/org/apache/maven/jxr/util/SimpleWordTokenizerTest.java +++ b/maven-jxr/src/test/java/org/apache/maven/jxr/util/SimpleWordTokenizerTest.java @@ -1,5 +1,3 @@ -package org.apache.maven.jxr.util; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -18,109 +16,104 @@ * specific language governing permissions and limitations * under the License. */ - -import static org.junit.Assert.assertEquals; +package org.apache.maven.jxr.util; import java.util.List; import org.junit.Test; -public class SimpleWordTokenizerTest -{ +import static org.junit.Assert.assertEquals; + +public class SimpleWordTokenizerTest { @Test - public void testCompact() - { - List entries = SimpleWordTokenizer.tokenize( "public void withApp1(App app)" ); - assertEquals( 5, entries.size() ); + public void testCompact() { + List entries = SimpleWordTokenizer.tokenize("public void withApp1(App app)"); + assertEquals(5, entries.size()); - assertEquals( "public", entries.get(0).toString() ); - assertEquals( 0, entries.get(0).getIndex() ); + assertEquals("public", entries.get(0).toString()); + assertEquals(0, entries.get(0).getIndex()); - assertEquals( "void", entries.get(1).toString() ); - assertEquals( 7, entries.get(1).getIndex() ); + assertEquals("void", entries.get(1).toString()); + assertEquals(7, entries.get(1).getIndex()); - assertEquals( "withApp1", entries.get(2).toString() ); - assertEquals( 12, entries.get(2).getIndex() ); + assertEquals("withApp1", entries.get(2).toString()); + assertEquals(12, entries.get(2).getIndex()); - assertEquals( "App", entries.get(3).toString() ); - assertEquals( 21, entries.get(3).getIndex() ); + assertEquals("App", entries.get(3).toString()); + assertEquals(21, entries.get(3).getIndex()); - assertEquals( "app", entries.get(4).toString() ); - assertEquals( 25, entries.get(4).getIndex() ); + assertEquals("app", entries.get(4).toString()); + assertEquals(25, entries.get(4).getIndex()); } - + @Test - public void testSpacesAroundParenOpen() - { - List entries = SimpleWordTokenizer.tokenize( "public void withApp2 ( App app)" ); - assertEquals( 5, entries.size() ); + public void testSpacesAroundParenOpen() { + List entries = SimpleWordTokenizer.tokenize("public void withApp2 ( App app)"); + assertEquals(5, entries.size()); - assertEquals( "public", entries.get(0).toString() ); - assertEquals( 0, entries.get(0).getIndex() ); + assertEquals("public", entries.get(0).toString()); + assertEquals(0, entries.get(0).getIndex()); - assertEquals( "void", entries.get(1).toString() ); - assertEquals( 7, entries.get(1).getIndex() ); + assertEquals("void", entries.get(1).toString()); + assertEquals(7, entries.get(1).getIndex()); - assertEquals( "withApp2", entries.get(2).toString() ); - assertEquals( 12, entries.get(2).getIndex() ); + assertEquals("withApp2", entries.get(2).toString()); + assertEquals(12, entries.get(2).getIndex()); - assertEquals( "App", entries.get(3).toString() ); - assertEquals( 23, entries.get(3).getIndex() ); + assertEquals("App", entries.get(3).toString()); + assertEquals(23, entries.get(3).getIndex()); - assertEquals( "app", entries.get(4).toString() ); - assertEquals( 27, entries.get(4).getIndex() ); + assertEquals("app", entries.get(4).toString()); + assertEquals(27, entries.get(4).getIndex()); } @Test - public void testSpaceBeforeParenOpen() - { - List entries = SimpleWordTokenizer.tokenize( "public void withApp3 (App app)" ); - assertEquals( 5, entries.size() ); + public void testSpaceBeforeParenOpen() { + List entries = SimpleWordTokenizer.tokenize("public void withApp3 (App app)"); + assertEquals(5, entries.size()); - assertEquals( "public", entries.get(0).toString() ); - assertEquals( 0, entries.get(0).getIndex() ); + assertEquals("public", entries.get(0).toString()); + assertEquals(0, entries.get(0).getIndex()); - assertEquals( "void", entries.get(1).toString() ); - assertEquals( 7, entries.get(1).getIndex() ); + assertEquals("void", entries.get(1).toString()); + assertEquals(7, entries.get(1).getIndex()); - assertEquals( "withApp3", entries.get(2).toString() ); - assertEquals( 12, entries.get(2).getIndex() ); + assertEquals("withApp3", entries.get(2).toString()); + assertEquals(12, entries.get(2).getIndex()); - assertEquals( "App", entries.get(3).toString() ); - assertEquals( 22, entries.get(3).getIndex() ); + assertEquals("App", entries.get(3).toString()); + assertEquals(22, entries.get(3).getIndex()); - assertEquals( "app", entries.get(4).toString() ); - assertEquals( 26, entries.get(4).getIndex() ); + assertEquals("app", entries.get(4).toString()); + assertEquals(26, entries.get(4).getIndex()); } @Test - public void testSpaceAfterParenOpen() - { - List entries = SimpleWordTokenizer.tokenize( "public void withApp4( App app)" ); - assertEquals( 5, entries.size() ); + public void testSpaceAfterParenOpen() { + List entries = SimpleWordTokenizer.tokenize("public void withApp4( App app)"); + assertEquals(5, entries.size()); - assertEquals( "public", entries.get(0).toString() ); - assertEquals( 0, entries.get(0).getIndex() ); + assertEquals("public", entries.get(0).toString()); + assertEquals(0, entries.get(0).getIndex()); - assertEquals( "void", entries.get(1).toString() ); - assertEquals( 7, entries.get(1).getIndex() ); + assertEquals("void", entries.get(1).toString()); + assertEquals(7, entries.get(1).getIndex()); - assertEquals( "withApp4", entries.get(2).toString() ); - assertEquals( 12, entries.get(2).getIndex() ); + assertEquals("withApp4", entries.get(2).toString()); + assertEquals(12, entries.get(2).getIndex()); - assertEquals( "App", entries.get(3).toString() ); - assertEquals( 22, entries.get(3).getIndex() ); + assertEquals("App", entries.get(3).toString()); + assertEquals(22, entries.get(3).getIndex()); - assertEquals( "app", entries.get(4).toString() ); - assertEquals( 26, entries.get(4).getIndex() ); + assertEquals("app", entries.get(4).toString()); + assertEquals(26, entries.get(4).getIndex()); } - + @Test - public void testWithIndent() - { - List entries = SimpleWordTokenizer.tokenize( " public void withApp3 (App app)", "App" ); - assertEquals( 1, entries.size() ); - - assertEquals( 26, entries.get(0).getIndex() ); + public void testWithIndent() { + List entries = SimpleWordTokenizer.tokenize(" public void withApp3 (App app)", "App"); + assertEquals(1, entries.size()); + + assertEquals(26, entries.get(0).getIndex()); } -} \ No newline at end of file +} diff --git a/pom.xml b/pom.xml index ed21e8bc..ea98f25f 100644 --- a/pom.xml +++ b/pom.xml @@ -1,5 +1,4 @@ - - 4.0.0 org.apache.maven maven-parent - 37 + 39 @@ -36,15 +34,29 @@ under the License. Maven JXR Parent + Source cross reference library + https://maven.apache.org/jxr/ - Source cross reference library + + + Alina Vasiljeva + + + Jesper Udby + + + + + maven-jxr + maven-jxr-plugin + scm:git:https://gitbox.apache.org/repos/asf/maven-jxr.git scm:git:https://gitbox.apache.org/repos/asf/maven-jxr.git - https://github.com/apache/maven-jxr/tree/${project.scm.tag} HEAD + https://github.com/apache/maven-jxr/tree/${project.scm.tag} @@ -72,20 +84,6 @@ under the License. 2022-08-16T10:28:45Z - - maven-jxr - maven-jxr-plugin - - - - - Alina Vasiljeva - - - Jesper Udby - - - @@ -180,9 +178,9 @@ under the License. aggregate - + - +