Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump org.codehaus.mojo:mojo-parent from 78 to 80 #28

Merged
merged 2 commits into from
Mar 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>org.codehaus.mojo</groupId>
<artifactId>mojo-parent</artifactId>
<version>78</version>
<version>80</version>
</parent>

<artifactId>jdepend-maven-plugin</artifactId>
Expand Down Expand Up @@ -63,11 +63,9 @@
<url>https://github.com/mojohaus/jdepend-maven-plugin/issues</url>
</issueManagement>


<properties>
<mavenVersion>3.6.3</mavenVersion>
<jdependVersion>2.9.1</jdependVersion>
<mojo.java.target>8</mojo.java.target>
<scmpublish.content>target/staging/${project.artifactId}</scmpublish.content>
</properties>

Expand Down Expand Up @@ -131,7 +129,6 @@
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>license-maven-plugin</artifactId>
<version>2.4.0</version>
<configuration>
<licenseName>asf-2.0</licenseName>
<licenseResolver>${project.baseUri}/src/license</licenseResolver>
Expand Down
159 changes: 64 additions & 95 deletions src/main/java/org/codehaus/mojo/jdepend/AbstractJDependMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Expand All @@ -20,6 +20,12 @@
* #L%
*/

import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import java.util.ResourceBundle;

import jdepend.xmlui.JDepend;
import org.apache.maven.doxia.sink.Sink;
import org.apache.maven.doxia.siterenderer.Renderer;
Expand All @@ -28,51 +34,44 @@
import org.apache.maven.project.MavenProject;
import org.apache.maven.reporting.AbstractMavenReport;
import org.apache.maven.reporting.MavenReportException;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import java.util.ResourceBundle;

/**
* @author Karl-Heinz Marbaise
*/
public abstract class AbstractJDependMojo
extends AbstractMavenReport
{
public abstract class AbstractJDependMojo extends AbstractMavenReport {
JDependXMLReportParser xmlParser;

@Parameter( defaultValue = "${project}", readonly = true, required = true )
@Parameter(defaultValue = "${project}", readonly = true, required = true)
private MavenProject project;

/**
* Directory where the generated output site files will be located.
*/
@Parameter( defaultValue = "${project.build.directory}/site", property = "jdepend.outputDirectory", required = true )
@Parameter(defaultValue = "${project.build.directory}/site", property = "jdepend.outputDirectory", required = true)
private String outputDirectory;

/**
* Directory of the project.
*/
@Parameter( defaultValue = "${basedir}", property = "jdepend.projectDirectory" )
@Parameter(defaultValue = "${basedir}", property = "jdepend.projectDirectory")
private String projectDirectory;

/**
* Directory containing the class files.
*/
@Parameter( defaultValue = "${project.build.outputDirectory}", property = "jdepend.classDirectory", required = true )
@Parameter(defaultValue = "${project.build.outputDirectory}", property = "jdepend.classDirectory", required = true)
private String classDirectory;

/**
* Location of the generated JDepend xml report.
*/
@Parameter( defaultValue = "${project.build.directory}/jdepend-report.xml", required = true, readonly = true )
@Parameter(defaultValue = "${project.build.directory}/jdepend-report.xml", required = true, readonly = true)
private String reportFile;

/**
* Skip execution of the plugin.
*/
@Parameter( defaultValue = "false", property = "jdepend.skip" )
@Parameter(defaultValue = "false", property = "jdepend.skip")
private boolean skip;

/**
Expand All @@ -85,203 +84,173 @@ public abstract class AbstractJDependMojo
* (non-Javadoc)
* @see org.apache.maven.reporting.AbstractMavenReport#executeReport(java.util.Locale)
*/
public void executeReport( Locale locale )
throws MavenReportException
{
if ( skip )
{
getLog().info( "Skipping execution on behalf of user" );
public void executeReport(Locale locale) throws MavenReportException {
if (skip) {
getLog().info("Skipping execution on behalf of user");
return;
}

try
{
File outputDirFile = new File( outputDirectory );
try {
File outputDirFile = new File(outputDirectory);

if ( !outputDirFile.exists() )
{
if (!outputDirFile.exists()) {
boolean success = outputDirFile.mkdirs();
if ( !success )
{
throw new MavenReportException( "Could not create directory " + outputDirectory );
if (!success) {
throw new MavenReportException("Could not create directory " + outputDirectory);
}
}

JDepend.main( getArgumentList( getArgument(), getReportFile(), getClassDirectory() ) );
JDepend.main(getArgumentList(getArgument(), getReportFile(), getClassDirectory()));

xmlParser = new JDependXMLReportParser( new File( getReportFile() ) );
xmlParser = new JDependXMLReportParser(new File(getReportFile()));

generateReport( locale );
}
catch ( Exception e )
{
throw new MavenReportException( "Failed to execute JDepend", e );
generateReport(locale);
} catch (Exception e) {
throw new MavenReportException("Failed to execute JDepend", e);
}
}

/*
* (non-Javadoc)
* @see org.apache.maven.reporting.AbstractMavenReport#canGenerateReport()
*/
public boolean canGenerateReport()
{
return new File( classDirectory ).exists();
public boolean canGenerateReport() {
return new File(classDirectory).exists();
}

/**
* Sets and get the arguments passed for the JDepend.
*
*
* @param argument Accepts parameter with "-file" string.
* @param locationXMLreportFile Accepts the location of the generated JDepend xml report file.
* @param classDir Accepts the location of the classes.
* @return String[] Returns the array to be pass as parameters for JDepend.
*/
private String[] getArgumentList( String argument, String locationXMLreportFile, String classDir )
{
private String[] getArgumentList(String argument, String locationXMLreportFile, String classDir) {
List<String> argList = new ArrayList<>();

argList.add( argument );
argList.add(argument);

argList.add( locationXMLreportFile );
argList.add(locationXMLreportFile);

argList.add( classDir );
argList.add(classDir);

return argList.toArray( new String[0] );
return argList.toArray(new String[0]);
}

public void generateReport( Locale locale )
throws MavenReportException
{
public void generateReport(Locale locale) throws MavenReportException {
Sink sink;
ReportGenerator report = new ReportGenerator();
try
{
try {
sink = getSink();

report.doGenerateReport( getBundle( locale ), sink, xmlParser );
}
catch ( Exception e )
{
throw new MavenReportException( "Failed to generate JDepend report", e );
report.doGenerateReport(getBundle(locale), sink, xmlParser);
} catch (Exception e) {
throw new MavenReportException("Failed to generate JDepend report", e);
}
}

/*
* (non-Javadoc)
* @see org.apache.maven.reporting.MavenReport#getDescription(java.util.Locale)
*/
public String getDescription( Locale locale )
{
return getBundle( locale ).getString( "report.jdepend.description" );
public String getDescription(Locale locale) {
return getBundle(locale).getString("report.jdepend.description");
}

/*
* (non-Javadoc)
* @see org.apache.maven.reporting.MavenReport#getName(java.util.Locale)
*/
public String getName( Locale locale )
{
return getBundle( locale ).getString( "report.jdepend.name" );
public String getName(Locale locale) {
return getBundle(locale).getString("report.jdepend.name");
}

private ResourceBundle getBundle( Locale locale )
{
return ResourceBundle.getBundle( "org.codehaus.mojo.jdepend.jdepend-report", locale,
this.getClass().getClassLoader() );
private ResourceBundle getBundle(Locale locale) {
return ResourceBundle.getBundle(
"org.codehaus.mojo.jdepend.jdepend-report",
locale,
this.getClass().getClassLoader());
}

/*
* (non-Javadoc)
* @see org.apache.maven.reporting.MavenReport#getOutputName()
*/
public String getOutputName()
{
public String getOutputName() {
return "jdepend-report";
}

/*
* (non-Javadoc)
* @see org.apache.maven.reporting.AbstractMavenReport#getProject()
*/
public MavenProject getProject()
{
public MavenProject getProject() {
return project;
}

/**
* @param project
*/
public void setProject( MavenProject project )
{
public void setProject(MavenProject project) {
this.project = project;
}

/*
* (non-Javadoc)
* @see org.apache.maven.reporting.AbstractMavenReport#getOutputDirectory()
*/
public String getOutputDirectory()
{
public String getOutputDirectory() {
return outputDirectory;
}

public void setOutputDirectory( String outputDirectory )
{
public void setOutputDirectory(String outputDirectory) {
this.outputDirectory = outputDirectory;
}

/**
* @return The argument.
*/
public String getArgument()
{
public String getArgument() {
return "-file";
}

/**
* @return
*/
public String getReportFile()
{
public String getReportFile() {
return reportFile;
}

public void setReportFile( String reportFile )
{
public void setReportFile(String reportFile) {
this.reportFile = reportFile;
}

/*
* (non-Javadoc)
* @see org.apache.maven.reporting.AbstractMavenReport#getSiteRenderer()
*/
public Renderer getSiteRenderer()
{
public Renderer getSiteRenderer() {
return siteRenderer;
}

public void setSiteRenderer( Renderer siteRenderer )
{
public void setSiteRenderer(Renderer siteRenderer) {
this.siteRenderer = siteRenderer;
}

public String getProjectDirectory()
{
public String getProjectDirectory() {
return projectDirectory;
}

public void setProjectDirectory( String projectDirectory )
{
public void setProjectDirectory(String projectDirectory) {
this.projectDirectory = projectDirectory;
}

public String getClassDirectory()
{
public String getClassDirectory() {
return classDirectory;
}

public void setClassDirectory( String classDirectory )
{
public void setClassDirectory(String classDirectory) {
this.classDirectory = classDirectory;
}
}
15 changes: 6 additions & 9 deletions src/main/java/org/codehaus/mojo/jdepend/JDependMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Expand All @@ -26,13 +26,10 @@

/**
* Run JDepend and generate a site report. Goal which generate the JDepend metrics.
*
*
* @author aramirez@exist.com
* @version $Id$
*/
@Mojo( name = "generate" )
@Execute( phase = LifecyclePhase.COMPILE )
public class JDependMojo
extends AbstractJDependMojo
{
}
@Mojo(name = "generate")
@Execute(phase = LifecyclePhase.COMPILE)
public class JDependMojo extends AbstractJDependMojo {}
Loading