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

[MCHANGES-434] @Component --> @Inject #44

Merged
merged 9 commits into from
Nov 22, 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
12 changes: 0 additions & 12 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -392,18 +392,6 @@ under the License.
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-component-metadata</artifactId>
<version>2.2.0</version>
<executions>
<execution>
<goals>
<goal>generate-metadata</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- workaround to remove timestamp inserted by Modello 1.0.1 into generated .java and .xsd -->
<plugin>
<groupId>org.codehaus.gmaven</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
*/
package org.apache.maven.plugins.announcement;

import javax.inject.Inject;

import java.io.File;
import java.io.FileOutputStream;
import java.io.OutputStreamWriter;
Expand All @@ -28,7 +30,6 @@
import java.util.Map;

import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugins.annotations.Component;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.plugins.changes.ChangesXML;
Expand Down Expand Up @@ -77,7 +78,7 @@ public class AnnouncementMojo extends AbstractAnnouncementMojo {
private static final String GIT_HUB = "GitHub";

/**
* The name of the file which will contain the generated announcement. If no value is specified the plugin will use
* The name of the file which will contain the generated announcement. If no value is specified, the plugin will use
* the name of the template.
*
* @since 2.4
Expand Down Expand Up @@ -229,18 +230,6 @@ public class AnnouncementMojo extends AbstractAnnouncementMojo {
@Parameter
private String urlDownload;

/**
* Velocity Component.
*/
@Component
private VelocityComponent velocity;

/**
* Component used to decrypt server information.
*/
@Component
private SettingsDecrypter settingsDecrypter;

/**
* Version of the artifact.
*/
Expand Down Expand Up @@ -320,9 +309,6 @@ public class AnnouncementMojo extends AbstractAnnouncementMojo {

/**
* The maximum number of issues to fetch from JIRA.
* <p>
* <b>Note:</b> In versions 2.0-beta-3 and earlier this parameter was called "nbEntries".
* </p>
*/
@Parameter(property = "changes.maxEntries", defaultValue = "25", required = true)
private int maxEntries;
Expand All @@ -346,9 +332,6 @@ public class AnnouncementMojo extends AbstractAnnouncementMojo {
/**
* Include issues from JIRA with these status ids. Multiple status ids can be specified as a comma separated list of
* ids.
* <p>
* <b>Note:</b> In versions 2.0-beta-3 and earlier this parameter was called "statusId".
* </p>
*/
@Parameter(property = "changes.statusIds", defaultValue = "Closed")
private String statusIds;
Expand Down Expand Up @@ -467,10 +450,26 @@ public class AnnouncementMojo extends AbstractAnnouncementMojo {
@Parameter(defaultValue = "false")
private boolean includeOpenIssues;

private ReleaseUtils releaseUtils = new ReleaseUtils(getLog());
private final ReleaseUtils releaseUtils = new ReleaseUtils(getLog());

private ChangesXML xml;

/**
* Velocity Component.
*/
private VelocityComponent velocity;

/**
* Component used to decrypt server information.
*/
private final SettingsDecrypter settingsDecrypter;

@Inject
public AnnouncementMojo(VelocityComponent velocity, SettingsDecrypter settingsDecrypter) {
this.velocity = velocity;
this.settingsDecrypter = settingsDecrypter;
}

// =======================================//
// announcement-generate execution //
// =======================================//
Expand Down Expand Up @@ -881,14 +880,6 @@ public void setUrlDownload(String urlDownload) {
this.urlDownload = urlDownload;
}

public VelocityComponent getVelocity() {
return velocity;
}

public void setVelocity(VelocityComponent velocity) {
this.velocity = velocity;
}

public String getVersion() {
return version;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
*/
package org.apache.maven.plugins.changes;

import javax.inject.Inject;

import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
Expand All @@ -35,7 +37,6 @@

import org.apache.commons.collections.map.CaseInsensitiveMap;
import org.apache.commons.io.input.XmlStreamReader;
import org.apache.maven.plugins.annotations.Component;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.plugins.changes.model.Release;
Expand Down Expand Up @@ -126,12 +127,6 @@ public class ChangesReport extends AbstractChangesReport {
@Parameter
private Map<String, String> issueLinkTemplatePerSystem;

/**
* @since 2.2
*/
@Component
private MavenFileFilter mavenFileFilter;

/**
* Format to use for publishDate. The value will be available with the following expression ${publishDate}
*
Expand Down Expand Up @@ -195,6 +190,13 @@ public class ChangesReport extends AbstractChangesReport {

private CaseInsensitiveMap caseInsensitiveIssueLinkTemplatePerSystem;

private MavenFileFilter mavenFileFilter;

@Inject
public ChangesReport(MavenFileFilter mavenFileFilter) {
this.mavenFileFilter = mavenFileFilter;
}

/* --------------------------------------------------------------------- */
/* Public methods */
/* --------------------------------------------------------------------- */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,12 @@
*/
package org.apache.maven.plugins.changes;

import javax.inject.Inject;

import java.io.File;
import java.util.List;

import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugins.annotations.Component;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.plugins.changes.schema.ChangesSchemaValidator;
Expand All @@ -40,19 +41,14 @@
@Mojo(name = "changes-validate", threadSafe = true)
public class ChangesValidatorMojo extends AbstractChangesMojo {

/**
*/
@Component(role = ChangesSchemaValidator.class, hint = "default")
private ChangesSchemaValidator changesSchemaValidator;

/**
* The changes xsd version.
*/
@Parameter(property = "changes.xsdVersion", defaultValue = "1.0.0")
private String changesXsdVersion;

/**
* Mojo failure if validation failed. If not and validation failed only a warning will be logged.
* Mojo failure if validation failed. If not and validation failed, only a warning will be logged.
*/
@Parameter(property = "changes.validate.failed", defaultValue = "false")
private boolean failOnError;
Expand All @@ -63,6 +59,13 @@ public class ChangesValidatorMojo extends AbstractChangesMojo {
@Parameter(property = "changes.xmlPath", defaultValue = "src/changes/changes.xml")
private File xmlPath;

private ChangesSchemaValidator changesSchemaValidator;

@Inject
public ChangesValidatorMojo(ChangesSchemaValidator changesSchemaValidator) {
this.changesSchemaValidator = changesSchemaValidator;
}

/**
* @see org.apache.maven.plugin.Mojo#execute()
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
*/
package org.apache.maven.plugins.changes.schema;

import javax.inject.Named;
import javax.inject.Singleton;
import javax.xml.transform.stream.StreamSource;
import javax.xml.validation.Schema;
import javax.xml.validation.SchemaFactory;
Expand All @@ -31,15 +33,15 @@
import java.util.Map;

import org.apache.commons.io.input.XmlStreamReader;
import org.codehaus.plexus.component.annotations.Component;
import org.xml.sax.SAXException;

/**
* @author Olivier Lamy
* @since 28 juil. 2008
* @version $Id$
*/
@Component(role = ChangesSchemaValidator.class, hint = "default")
@Named
@Singleton
public class DefaultChangesSchemaValidator implements ChangesSchemaValidator {

/** property schema */
Expand Down
27 changes: 16 additions & 11 deletions src/main/java/org/apache/maven/plugins/github/GitHubReport.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,15 @@
*/
package org.apache.maven.plugins.github;

import javax.inject.Inject;

import java.net.MalformedURLException;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.ResourceBundle;

import org.apache.maven.plugins.annotations.Component;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.plugins.changes.AbstractChangesReport;
Expand Down Expand Up @@ -64,12 +65,6 @@ public class GitHubReport extends AbstractChangesReport {
githubColumns.put("Updated", IssuesReportHelper.COLUMN_UPDATED);
}

/**
* Component used to decrypt server information.
*/
@Component
private SettingsDecrypter settingsDecrypter;

/**
* Sets the column names that you want to show in the report. The columns will appear in the report in the same
* order as you specify them here. Multiple values can be separated by commas.
Expand Down Expand Up @@ -125,6 +120,20 @@ public class GitHubReport extends AbstractChangesReport {
@Parameter(defaultValue = "false")
private boolean onlyCurrentVersion;

/**
* Component used to decrypt server information.
*/
private SettingsDecrypter settingsDecrypter;

@Inject
public GitHubReport(SettingsDecrypter settingsDecrypter) {
this.settingsDecrypter = settingsDecrypter;
}

/* --------------------------------------------------------------------- */
/* Public methods */
/* --------------------------------------------------------------------- */

@Override
public String getOutputName() {
return "github-report";
Expand All @@ -140,10 +149,6 @@ public String getDescription(Locale locale) {
return getBundle(locale).getString("report.issues.description");
}

/* --------------------------------------------------------------------- */
/* Public methods */
/* --------------------------------------------------------------------- */

/**
* @see org.apache.maven.reporting.AbstractMavenReport#canGenerateReport()
*/
Expand Down