You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "slawekjaranowski (via GitHub)" <gi...@apache.org> on 2025/02/19 22:34:02 UTC
[PR] [MPIR-478] Allow to save avatars images for team report during project build [maven-project-info-reports-plugin]
slawekjaranowski opened a new pull request, #97:
URL: https://github.com/apache/maven-project-info-reports-plugin/pull/97
https://issues.apache.org/jira/browse/MPIR-478
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [MPIR-478] Allow to save avatars images for team report during project build [maven-project-info-reports-plugin]
Posted by "slawekjaranowski (via GitHub)" <gi...@apache.org>.
slawekjaranowski commented on code in PR #97:
URL: https://github.com/apache/maven-project-info-reports-plugin/pull/97#discussion_r1962486132
##########
src/main/java/org/apache/maven/report/projectinfo/TeamReport.java:
##########
@@ -288,32 +334,13 @@ private void renderTeamMember(Contributor member, Map<String, Boolean> headersMa
sink.tableRow_();
}
- private static final String AVATAR_SIZE = "s=60";
-
- private String getSpacerGravatarUrl() {
- return protocol + "://www.gravatar.com/avatar/00000000000000000000000000000000?d=blank&f=y&" + AVATAR_SIZE;
- }
-
- private String getGravatarUrl(String email) {
- if (email == null) {
- return null;
- }
- email = StringUtils.trim(email);
- email = email.toLowerCase();
- MessageDigest md;
+ private String getExternalAvatarUrl(String email) {
Review Comment:
This is used in `renderTeamMember` and next in `renderBody` method.
- `renderBody` method is implementation of `org.apache.maven.reporting.AbstractMavenReportRenderer`
- `renderBody` can not throw any exception
so when exception should be catch and what we can do with it ...?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [MPIR-478] Allow to save avatars images for team report during project build [maven-project-info-reports-plugin]
Posted by "elharo (via GitHub)" <gi...@apache.org>.
elharo commented on code in PR #97:
URL: https://github.com/apache/maven-project-info-reports-plugin/pull/97#discussion_r1963942715
##########
src/main/java/org/apache/maven/report/projectinfo/TeamReport.java:
##########
@@ -288,32 +334,13 @@ private void renderTeamMember(Contributor member, Map<String, Boolean> headersMa
sink.tableRow_();
}
- private static final String AVATAR_SIZE = "s=60";
-
- private String getSpacerGravatarUrl() {
- return protocol + "://www.gravatar.com/avatar/00000000000000000000000000000000?d=blank&f=y&" + AVATAR_SIZE;
- }
-
- private String getGravatarUrl(String email) {
- if (email == null) {
- return null;
- }
- email = StringUtils.trim(email);
- email = email.toLowerCase();
- MessageDigest md;
+ private String getExternalAvatarUrl(String email) {
Review Comment:
That doesn't sound right. This is a private method so something in this class should be calling it.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [MPIR-478] Allow to save avatars images for team report during project build [maven-project-info-reports-plugin]
Posted by "slawekjaranowski (via GitHub)" <gi...@apache.org>.
slawekjaranowski commented on code in PR #97:
URL: https://github.com/apache/maven-project-info-reports-plugin/pull/97#discussion_r1963638576
##########
src/main/java/org/apache/maven/report/projectinfo/TeamReport.java:
##########
@@ -288,32 +334,13 @@ private void renderTeamMember(Contributor member, Map<String, Boolean> headersMa
sink.tableRow_();
}
- private static final String AVATAR_SIZE = "s=60";
-
- private String getSpacerGravatarUrl() {
- return protocol + "://www.gravatar.com/avatar/00000000000000000000000000000000?d=blank&f=y&" + AVATAR_SIZE;
- }
-
- private String getGravatarUrl(String email) {
- if (email == null) {
- return null;
- }
- email = StringUtils.trim(email);
- email = email.toLowerCase();
- MessageDigest md;
+ private String getExternalAvatarUrl(String email) {
Review Comment:
from team report perspective fetching images can be interpreted as one of report feature - so it can be important
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [MPIR-478] Allow to save avatars images for team report during project build [maven-project-info-reports-plugin]
Posted by "slawekjaranowski (via GitHub)" <gi...@apache.org>.
slawekjaranowski commented on code in PR #97:
URL: https://github.com/apache/maven-project-info-reports-plugin/pull/97#discussion_r1963580007
##########
src/main/java/org/apache/maven/report/projectinfo/TeamReport.java:
##########
@@ -288,32 +334,13 @@ private void renderTeamMember(Contributor member, Map<String, Boolean> headersMa
sink.tableRow_();
}
- private static final String AVATAR_SIZE = "s=60";
-
- private String getSpacerGravatarUrl() {
- return protocol + "://www.gravatar.com/avatar/00000000000000000000000000000000?d=blank&f=y&" + AVATAR_SIZE;
- }
-
- private String getGravatarUrl(String email) {
- if (email == null) {
- return null;
- }
- email = StringUtils.trim(email);
- email = email.toLowerCase();
- MessageDigest md;
+ private String getExternalAvatarUrl(String email) {
Review Comment:
we can not throw `MavenReportException` from `renderBody` method ...
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [MPIR-478] Allow to save avatars images for team report during project build [maven-project-info-reports-plugin]
Posted by "slawekjaranowski (via GitHub)" <gi...@apache.org>.
slawekjaranowski commented on code in PR #97:
URL: https://github.com/apache/maven-project-info-reports-plugin/pull/97#discussion_r1963589779
##########
src/main/java/org/apache/maven/report/projectinfo/TeamReport.java:
##########
@@ -83,9 +116,22 @@ public boolean canGenerateReport() throws MavenReportException {
}
@Override
- public void executeReport(Locale locale) {
- ProjectTeamRenderer r =
- new ProjectTeamRenderer(getSink(), project.getModel(), getI18N(locale), locale, showAvatarImages);
+ public void executeReport(Locale locale) throws MavenReportException {
+ AvatarsProvider avatarsProvider = avatarsProviders.get(avatarProviderName);
+ if (avatarsProvider == null) {
+ throw new MavenReportException("No AvatarsProvider found for name " + avatarProviderName);
Review Comment:
It is two different case wrong configuration - not existing provider and not available image server.
In both case we should break a build to prevent of unwanted result
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [MPIR-478] Allow to save avatars images for team report during project build [maven-project-info-reports-plugin]
Posted by "elharo (via GitHub)" <gi...@apache.org>.
elharo commented on code in PR #97:
URL: https://github.com/apache/maven-project-info-reports-plugin/pull/97#discussion_r1962539448
##########
src/main/java/org/apache/maven/report/projectinfo/TeamReport.java:
##########
@@ -83,9 +116,22 @@ public boolean canGenerateReport() throws MavenReportException {
}
@Override
- public void executeReport(Locale locale) {
- ProjectTeamRenderer r =
- new ProjectTeamRenderer(getSink(), project.getModel(), getI18N(locale), locale, showAvatarImages);
+ public void executeReport(Locale locale) throws MavenReportException {
+ AvatarsProvider avatarsProvider = avatarsProviders.get(avatarProviderName);
+ if (avatarsProvider == null) {
+ throw new MavenReportException("No AvatarsProvider found for name " + avatarProviderName);
+ }
+ avatarsProvider.setBaseUrl(avatarBaseUrl);
+ avatarsProvider.setOutputDirectory(getReportOutputDirectory());
+
+ ProjectTeamRenderer r = new ProjectTeamRenderer(
Review Comment:
r --> renderer
##########
src/main/java/org/apache/maven/report/projectinfo/TeamReport.java:
##########
@@ -288,32 +334,13 @@ private void renderTeamMember(Contributor member, Map<String, Boolean> headersMa
sink.tableRow_();
}
- private static final String AVATAR_SIZE = "s=60";
-
- private String getSpacerGravatarUrl() {
- return protocol + "://www.gravatar.com/avatar/00000000000000000000000000000000?d=blank&f=y&" + AVATAR_SIZE;
- }
-
- private String getGravatarUrl(String email) {
- if (email == null) {
- return null;
- }
- email = StringUtils.trim(email);
- email = email.toLowerCase();
- MessageDigest md;
+ private String getExternalAvatarUrl(String email) {
Review Comment:
This doesn't handle the exception, just pretends it's not going to happen. Checked or unchecked it needs to be handled. I don't think it can be handled here, so throw the IOException and handle a failure where it's called from.
##########
src/main/java/org/apache/maven/report/projectinfo/TeamReport.java:
##########
@@ -226,10 +276,7 @@ private void renderTeamMember(Contributor member, Map<String, Boolean> headersMa
Properties properties = member.getProperties();
String picUrl = properties.getProperty("picUrl");
if (picUrl == null || picUrl.isEmpty()) {
- picUrl = getGravatarUrl(member.getEmail());
- }
- if (picUrl == null || picUrl.isEmpty()) {
- picUrl = getSpacerGravatarUrl();
+ picUrl = getExternalAvatarUrl(member.getEmail());
Review Comment:
What do you want to do here when getExternalAvatarUrl( fails and throws an exception? Probably just don't call sink.figureGraphics below.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [MPIR-478] Allow to save avatars images for team report during project build [maven-project-info-reports-plugin]
Posted by "elharo (via GitHub)" <gi...@apache.org>.
elharo commented on code in PR #97:
URL: https://github.com/apache/maven-project-info-reports-plugin/pull/97#discussion_r1962473942
##########
src/main/java/org/apache/maven/report/projectinfo/avatars/AvatarsProvider.java:
##########
@@ -0,0 +1,59 @@
+/*
+ * 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.report.projectinfo.avatars;
+
+import java.io.File;
+import java.io.IOException;
+
+/**
+ * Avatar provider API.
+ */
+public interface AvatarsProvider {
+
+ /**
+ * Set a base url for provider
+ *
+ * @param baseUrl for provider
+ */
+ void setBaserUrl(String baseUrl);
+
+ /**
+ * Set site output directory. Used to store avatar images in project.
+ *
+ * @param outputDirectory a site output directory
+ */
+ void setOutputDirectory(File outputDirectory);
+
+ /**
+ * Return an external url for gravatar image.
Review Comment:
URL
##########
src/main/java/org/apache/maven/report/projectinfo/avatars/AvatarsProvider.java:
##########
@@ -0,0 +1,59 @@
+/*
+ * 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.report.projectinfo.avatars;
+
+import java.io.File;
+import java.io.IOException;
+
+/**
+ * Avatar provider API.
+ */
+public interface AvatarsProvider {
+
+ /**
+ * Set a base url for provider
+ *
+ * @param baseUrl for provider
+ */
+ void setBaserUrl(String baseUrl);
Review Comment:
setBaseUrl, not setBaserUrl
##########
src/main/java/org/apache/maven/report/projectinfo/TeamReport.java:
##########
@@ -52,19 +53,50 @@ public class TeamReport extends AbstractProjectInfoReport {
/**
* Shows avatar images for team members that have a) properties/picUrl set b) An avatar at gravatar.com for their
* email address
- * <p/>
- * Future versions of this plugin may implement different strategies for resolving avatar images, possibly
- * using different providers.
- *<p>
- *<strong>Note</strong>: This property will be renamed to {@code tteam.showAvatarImages} in 3.0.
+ *
* @since 2.6
*/
@Parameter(property = "teamlist.showAvatarImages", defaultValue = "true")
private boolean showAvatarImages;
+ /**
+ * Indicate if external url should be used for avatar images.
+ * <p>
+ * If set to <code>true</code> images will be downloaded and attached to report during build.
+ *
+ * @since 3.9.0
+ */
+ @Parameter(property = "teamlist.externalAvatarImages", defaultValue = "true")
+ private boolean externalAvatarImages;
+
+ /**
+ * Base url for avatar provider.
Review Comment:
URL
##########
src/main/java/org/apache/maven/report/projectinfo/TeamReport.java:
##########
@@ -288,32 +334,13 @@ private void renderTeamMember(Contributor member, Map<String, Boolean> headersMa
sink.tableRow_();
}
- private static final String AVATAR_SIZE = "s=60";
-
- private String getSpacerGravatarUrl() {
- return protocol + "://www.gravatar.com/avatar/00000000000000000000000000000000?d=blank&f=y&" + AVATAR_SIZE;
- }
-
- private String getGravatarUrl(String email) {
- if (email == null) {
- return null;
- }
- email = StringUtils.trim(email);
- email = email.toLowerCase();
- MessageDigest md;
+ private String getExternalAvatarUrl(String email) {
Review Comment:
This should just throw IOException
##########
src/main/java/org/apache/maven/report/projectinfo/TeamReport.java:
##########
@@ -52,19 +53,50 @@ public class TeamReport extends AbstractProjectInfoReport {
/**
* Shows avatar images for team members that have a) properties/picUrl set b) An avatar at gravatar.com for their
* email address
- * <p/>
- * Future versions of this plugin may implement different strategies for resolving avatar images, possibly
- * using different providers.
- *<p>
- *<strong>Note</strong>: This property will be renamed to {@code tteam.showAvatarImages} in 3.0.
+ *
* @since 2.6
*/
@Parameter(property = "teamlist.showAvatarImages", defaultValue = "true")
private boolean showAvatarImages;
+ /**
+ * Indicate if external url should be used for avatar images.
+ * <p>
+ * If set to <code>true</code> images will be downloaded and attached to report during build.
+ *
+ * @since 3.9.0
+ */
+ @Parameter(property = "teamlist.externalAvatarImages", defaultValue = "true")
+ private boolean externalAvatarImages;
+
+ /**
+ * Base url for avatar provider.
+ *
+ * @since 3.9.0
+ */
+ @Parameter(property = "teamlist.avatarBaseUrl", defaultValue = "https://www.gravatar.com/avatar/")
+ private String avatarBaseUrl;
+
+ /**
+ * Provider name for avatar images.
+ * <p>
+ * Report has one implementation for gravatar.com. Users can provide other by implementing {@link AvatarsProvider}
Review Comment:
Period at end
##########
src/main/java/org/apache/maven/report/projectinfo/TeamReport.java:
##########
@@ -52,19 +53,50 @@ public class TeamReport extends AbstractProjectInfoReport {
/**
* Shows avatar images for team members that have a) properties/picUrl set b) An avatar at gravatar.com for their
* email address
- * <p/>
- * Future versions of this plugin may implement different strategies for resolving avatar images, possibly
- * using different providers.
- *<p>
- *<strong>Note</strong>: This property will be renamed to {@code tteam.showAvatarImages} in 3.0.
+ *
* @since 2.6
*/
@Parameter(property = "teamlist.showAvatarImages", defaultValue = "true")
private boolean showAvatarImages;
+ /**
+ * Indicate if external url should be used for avatar images.
Review Comment:
URL.
Is there an internal URL? If not, delete "external" here or rewrite
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [MPIR-478] Allow to save avatars images for team report during project build [maven-project-info-reports-plugin]
Posted by "slawekjaranowski (via GitHub)" <gi...@apache.org>.
slawekjaranowski commented on code in PR #97:
URL: https://github.com/apache/maven-project-info-reports-plugin/pull/97#discussion_r1963032322
##########
src/main/java/org/apache/maven/report/projectinfo/TeamReport.java:
##########
@@ -288,32 +334,13 @@ private void renderTeamMember(Contributor member, Map<String, Boolean> headersMa
sink.tableRow_();
}
- private static final String AVATAR_SIZE = "s=60";
-
- private String getSpacerGravatarUrl() {
- return protocol + "://www.gravatar.com/avatar/00000000000000000000000000000000?d=blank&f=y&" + AVATAR_SIZE;
- }
-
- private String getGravatarUrl(String email) {
- if (email == null) {
- return null;
- }
- email = StringUtils.trim(email);
- email = email.toLowerCase();
- MessageDigest md;
+ private String getExternalAvatarUrl(String email) {
Review Comment:
ok, what should happen on such exception, how do you want to handle it in report?
Now it be handled by Maven itself and build will be break.
I hope it will not often exception.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [MPIR-478] Allow to save avatars images for team report during project build [maven-project-info-reports-plugin]
Posted by "elharo (via GitHub)" <gi...@apache.org>.
elharo commented on code in PR #97:
URL: https://github.com/apache/maven-project-info-reports-plugin/pull/97#discussion_r1964045784
##########
src/main/java/org/apache/maven/report/projectinfo/avatars/GravatarProvider.java:
##########
@@ -0,0 +1,112 @@
+/*
+ * 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.report.projectinfo.avatars;
+
+import javax.inject.Named;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
+import java.util.Locale;
+
+import org.codehaus.plexus.util.IOUtil;
+
+/**
+ * Provider for user avatar from gravatar.com
+ * <p>
+ * <a href="https://docs.gravatar.com/api/avatars/images/">Gravatar API</a>
+ */
+@Named("gravatar")
+class GravatarProvider implements AvatarsProvider {
+
+ private static final String AVATAR_SIZE = "s=60";
+
+ private static final String AVATAR_DIRECTORY = "avatars";
+
+ private String baseUrl = "https://www.gravatar.com/avatar/";
+
+ private Path outputDirectory;
+
+ @Override
+ public void setBaseUrl(String baseUrl) {
+ this.baseUrl = baseUrl.endsWith("/") ? baseUrl : baseUrl + "/";
+ }
+
+ @Override
+ public void setOutputDirectory(File outputDirectory) {
+ this.outputDirectory = outputDirectory.toPath();
+ }
+
+ public String getExternalAvatarUrl(String email) {
+
+ if (email == null || email.isEmpty()) {
+ return getSpacerGravatarUrl();
+ }
+
+ try {
+ email = email.trim().toLowerCase(Locale.ROOT);
+ MessageDigest md;
+ md = MessageDigest.getInstance("MD5");
+ md.update(email.getBytes());
+ byte[] byteData = md.digest();
+ StringBuilder sb = new StringBuilder();
+ final int lowerEightBitsOnly = 0xff;
+ for (byte aByteData : byteData) {
+ sb.append(Integer.toString((aByteData & lowerEightBitsOnly) + 0x100, 16)
+ .substring(1));
+ }
+ return baseUrl + sb + ".jpg?d=mp&" + AVATAR_SIZE;
+ } catch (NoSuchAlgorithmException e) {
+ return getSpacerGravatarUrl();
+ }
+ }
+
+ @Override
+ public String getLocalAvatarPath(String email) throws IOException {
+ String externalAvatarUrl = getExternalAvatarUrl(email);
+ try {
+ URL url = new URI(externalAvatarUrl).toURL();
+ Path name = Paths.get(url.getPath()).getFileName();
+ Path outputPath = outputDirectory.resolve(AVATAR_DIRECTORY).resolve(name);
+ if (!Files.exists(outputPath)) {
+ Files.createDirectories(outputPath.getParent());
+ try (InputStream in = url.openStream();
+ OutputStream out = Files.newOutputStream(outputPath)) {
+ IOUtil.copy(in, out);
+ }
+ }
+ return AVATAR_DIRECTORY + "/" + name;
+ } catch (URISyntaxException e) {
+ throw new IOException(e);
+ }
+ }
+
+ private String getSpacerGravatarUrl() {
Review Comment:
You can probably make this non-private and use this in cases where the provider fails.
##########
src/main/java/org/apache/maven/report/projectinfo/avatars/GravatarProvider.java:
##########
@@ -0,0 +1,112 @@
+/*
+ * 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.report.projectinfo.avatars;
+
+import javax.inject.Named;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
+import java.util.Locale;
+
+import org.codehaus.plexus.util.IOUtil;
+
+/**
+ * Provider for user avatar from gravatar.com
+ * <p>
+ * <a href="https://docs.gravatar.com/api/avatars/images/">Gravatar API</a>
+ */
+@Named("gravatar")
+class GravatarProvider implements AvatarsProvider {
+
+ private static final String AVATAR_SIZE = "s=60";
+
+ private static final String AVATAR_DIRECTORY = "avatars";
+
+ private String baseUrl = "https://www.gravatar.com/avatar/";
+
+ private Path outputDirectory;
+
+ @Override
+ public void setBaseUrl(String baseUrl) {
+ this.baseUrl = baseUrl.endsWith("/") ? baseUrl : baseUrl + "/";
+ }
+
+ @Override
+ public void setOutputDirectory(File outputDirectory) {
+ this.outputDirectory = outputDirectory.toPath();
+ }
+
+ public String getExternalAvatarUrl(String email) {
+
+ if (email == null || email.isEmpty()) {
+ return getSpacerGravatarUrl();
+ }
+
+ try {
+ email = email.trim().toLowerCase(Locale.ROOT);
+ MessageDigest md;
Review Comment:
combine this with next line
##########
src/main/java/org/apache/maven/report/projectinfo/TeamReport.java:
##########
@@ -288,32 +334,13 @@ private void renderTeamMember(Contributor member, Map<String, Boolean> headersMa
sink.tableRow_();
}
- private static final String AVATAR_SIZE = "s=60";
-
- private String getSpacerGravatarUrl() {
- return protocol + "://www.gravatar.com/avatar/00000000000000000000000000000000?d=blank&f=y&" + AVATAR_SIZE;
- }
-
- private String getGravatarUrl(String email) {
- if (email == null) {
- return null;
- }
- email = StringUtils.trim(email);
- email = email.toLowerCase();
- MessageDigest md;
+ private String getExternalAvatarUrl(String email) {
Review Comment:
so handle the IOException there, not here.
Also, if renderBody cannot throw any exception, then don't throw an exception in renderBody. Make sure that whatever code you call inside renderBody does not throw any exception, runtime exceptions included. Instead call all the code that might throw exceptions before you ever call renderBody, load up all the URLs or pics or whatever in memory at the beginning of executeReport, and only start rendering once all the resources are loaded and will not throw any exceptions during rendering.
Though in this case I really think it's simpler and easier to just use the default spacer image.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [MPIR-478] Allow to save avatars images for team report during project build [maven-project-info-reports-plugin]
Posted by "slawekjaranowski (via GitHub)" <gi...@apache.org>.
slawekjaranowski commented on PR #97:
URL: https://github.com/apache/maven-project-info-reports-plugin/pull/97#issuecomment-2672790771
@elharo please look now
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [MPIR-478] Allow to save avatars images for team report during project build [maven-project-info-reports-plugin]
Posted by "slawekjaranowski (via GitHub)" <gi...@apache.org>.
slawekjaranowski commented on code in PR #97:
URL: https://github.com/apache/maven-project-info-reports-plugin/pull/97#discussion_r1964024075
##########
src/main/java/org/apache/maven/report/projectinfo/TeamReport.java:
##########
@@ -226,10 +276,7 @@ private void renderTeamMember(Contributor member, Map<String, Boolean> headersMa
Properties properties = member.getProperties();
String picUrl = properties.getProperty("picUrl");
if (picUrl == null || picUrl.isEmpty()) {
- picUrl = getGravatarUrl(member.getEmail());
- }
- if (picUrl == null || picUrl.isEmpty()) {
- picUrl = getSpacerGravatarUrl();
+ picUrl = getExternalAvatarUrl(member.getEmail());
Review Comment:
I know that I can catch and skip exception, and use default images - but I don't want.
As you know one step of release new component is publishing new documentation ... I don't want to add next manual task to verify team page during release. Maybe you have another experience with releasing new components ...
Some context of change - look at our team pages: https://maven.apache.org/team.html the same are on many other ASF projects.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [MPIR-478] Allow to save avatars images for team report during project build [maven-project-info-reports-plugin]
Posted by "slawekjaranowski (via GitHub)" <gi...@apache.org>.
slawekjaranowski commented on code in PR #97:
URL: https://github.com/apache/maven-project-info-reports-plugin/pull/97#discussion_r1966507864
##########
src/main/java/org/apache/maven/report/projectinfo/avatars/GravatarProvider.java:
##########
@@ -0,0 +1,156 @@
+/*
+ * 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.report.projectinfo.avatars;
+
+import javax.inject.Named;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
+import java.util.Locale;
+
+import org.codehaus.plexus.util.IOUtil;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Provider for user avatar from gravatar.com
+ * <p>
+ * <a href="https://docs.gravatar.com/api/avatars/images/">Gravatar API</a>
+ */
+@Named("gravatar")
+class GravatarProvider implements AvatarsProvider {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(GravatarProvider.class);
+
+ private static final String AVATAR_SIZE = "s=60";
+
+ private static final String AVATAR_DIRECTORY = "avatars";
+
+ private static final String AVATAR_DEFAULT_FILE_NAME = "00000000000000000000000000000000.jpg";
Review Comment:
I don't know if it default value ... it is used as hash for that we don't have an avatar and gravatar return a default image for it.
Also when we use different value which has not avatar connected will be the same.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [MPIR-478] Allow to save avatars images for team report during project build [maven-project-info-reports-plugin]
Posted by "Bukama (via GitHub)" <gi...@apache.org>.
Bukama commented on code in PR #97:
URL: https://github.com/apache/maven-project-info-reports-plugin/pull/97#discussion_r1966504959
##########
src/main/java/org/apache/maven/report/projectinfo/avatars/GravatarProvider.java:
##########
@@ -0,0 +1,156 @@
+/*
+ * 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.report.projectinfo.avatars;
+
+import javax.inject.Named;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
+import java.util.Locale;
+
+import org.codehaus.plexus.util.IOUtil;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Provider for user avatar from gravatar.com
+ * <p>
+ * <a href="https://docs.gravatar.com/api/avatars/images/">Gravatar API</a>
+ */
+@Named("gravatar")
+class GravatarProvider implements AvatarsProvider {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(GravatarProvider.class);
+
+ private static final String AVATAR_SIZE = "s=60";
+
+ private static final String AVATAR_DIRECTORY = "avatars";
+
+ private static final String AVATAR_DEFAULT_FILE_NAME = "00000000000000000000000000000000.jpg";
Review Comment:
Maybe add a short Javadoc info that this strange looking name is really the default from Gravatar API? At least my google search brought SO questions up stating this
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [MPIR-478] Allow to save avatars images for team report during project build [maven-project-info-reports-plugin]
Posted by "slawekjaranowski (via GitHub)" <gi...@apache.org>.
slawekjaranowski commented on code in PR #97:
URL: https://github.com/apache/maven-project-info-reports-plugin/pull/97#discussion_r1963035788
##########
src/main/java/org/apache/maven/report/projectinfo/TeamReport.java:
##########
@@ -226,10 +276,7 @@ private void renderTeamMember(Contributor member, Map<String, Boolean> headersMa
Properties properties = member.getProperties();
String picUrl = properties.getProperty("picUrl");
if (picUrl == null || picUrl.isEmpty()) {
- picUrl = getGravatarUrl(member.getEmail());
- }
- if (picUrl == null || picUrl.isEmpty()) {
- picUrl = getSpacerGravatarUrl();
+ picUrl = getExternalAvatarUrl(member.getEmail());
Review Comment:
I want break a build, because images in report can be missing.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [MPIR-478] Allow to save avatars images for team report during project build [maven-project-info-reports-plugin]
Posted by "slawekjaranowski (via GitHub)" <gi...@apache.org>.
slawekjaranowski commented on code in PR #97:
URL: https://github.com/apache/maven-project-info-reports-plugin/pull/97#discussion_r1963645943
##########
src/main/java/org/apache/maven/report/projectinfo/TeamReport.java:
##########
@@ -288,32 +334,13 @@ private void renderTeamMember(Contributor member, Map<String, Boolean> headersMa
sink.tableRow_();
}
- private static final String AVATAR_SIZE = "s=60";
-
- private String getSpacerGravatarUrl() {
- return protocol + "://www.gravatar.com/avatar/00000000000000000000000000000000?d=blank&f=y&" + AVATAR_SIZE;
- }
-
- private String getGravatarUrl(String email) {
- if (email == null) {
- return null;
- }
- email = StringUtils.trim(email);
- email = email.toLowerCase();
- MessageDigest md;
+ private String getExternalAvatarUrl(String email) {
Review Comment:
`renderBody` method is defined in `AbstractMavenReportRenderer` from `maven-reporting-impl` so can not be changed in this PR.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [MPIR-478] Allow to save avatars images for team report during project build [maven-project-info-reports-plugin]
Posted by "slawekjaranowski (via GitHub)" <gi...@apache.org>.
slawekjaranowski commented on code in PR #97:
URL: https://github.com/apache/maven-project-info-reports-plugin/pull/97#discussion_r1963577377
##########
src/main/java/org/apache/maven/report/projectinfo/TeamReport.java:
##########
@@ -226,10 +276,7 @@ private void renderTeamMember(Contributor member, Map<String, Boolean> headersMa
Properties properties = member.getProperties();
String picUrl = properties.getProperty("picUrl");
if (picUrl == null || picUrl.isEmpty()) {
- picUrl = getGravatarUrl(member.getEmail());
- }
- if (picUrl == null || picUrl.isEmpty()) {
- picUrl = getSpacerGravatarUrl();
+ picUrl = getExternalAvatarUrl(member.getEmail());
Review Comment:
when user doesn't have an avatar default one will be returned by gravatar
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [MPIR-478] Allow to save avatars images for team report during project build [maven-project-info-reports-plugin]
Posted by "slawekjaranowski (via GitHub)" <gi...@apache.org>.
slawekjaranowski commented on code in PR #97:
URL: https://github.com/apache/maven-project-info-reports-plugin/pull/97#discussion_r1963954194
##########
src/main/java/org/apache/maven/report/projectinfo/TeamReport.java:
##########
@@ -288,32 +334,13 @@ private void renderTeamMember(Contributor member, Map<String, Boolean> headersMa
sink.tableRow_();
}
- private static final String AVATAR_SIZE = "s=60";
-
- private String getSpacerGravatarUrl() {
- return protocol + "://www.gravatar.com/avatar/00000000000000000000000000000000?d=blank&f=y&" + AVATAR_SIZE;
- }
-
- private String getGravatarUrl(String email) {
- if (email == null) {
- return null;
- }
- email = StringUtils.trim(email);
- email = email.toLowerCase();
- MessageDigest md;
+ private String getExternalAvatarUrl(String email) {
Review Comment:
There is use, line 279:
```
picUrl = getExternalAvatarUrl(member.getEmail());
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [MPIR-478] Allow to save avatars images for team report during project build [maven-project-info-reports-plugin]
Posted by "slawekjaranowski (via GitHub)" <gi...@apache.org>.
slawekjaranowski commented on PR #97:
URL: https://github.com/apache/maven-project-info-reports-plugin/pull/97#issuecomment-2676149144
Added support for default images in case of IOException or not existing avatar for given email
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [MPIR-478] Allow to save avatars images for team report during project build [maven-project-info-reports-plugin]
Posted by "elharo (via GitHub)" <gi...@apache.org>.
elharo commented on code in PR #97:
URL: https://github.com/apache/maven-project-info-reports-plugin/pull/97#discussion_r1962763705
##########
src/main/java/org/apache/maven/report/projectinfo/TeamReport.java:
##########
@@ -83,9 +116,22 @@ public boolean canGenerateReport() throws MavenReportException {
}
@Override
- public void executeReport(Locale locale) {
- ProjectTeamRenderer r =
- new ProjectTeamRenderer(getSink(), project.getModel(), getI18N(locale), locale, showAvatarImages);
+ public void executeReport(Locale locale) throws MavenReportException {
+ AvatarsProvider avatarsProvider = avatarsProviders.get(avatarProviderName);
+ if (avatarsProvider == null) {
+ throw new MavenReportException("No AvatarsProvider found for name " + avatarProviderName);
Review Comment:
Would it make sense to instead simply not show avatars in the report?
##########
src/main/java/org/apache/maven/report/projectinfo/avatars/GravatarProvider.java:
##########
@@ -0,0 +1,112 @@
+/*
+ * 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.report.projectinfo.avatars;
+
+import javax.inject.Named;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
+import java.util.Locale;
+
+import org.codehaus.plexus.util.IOUtil;
+
+/**
+ * Provider for user avatar from gravatar.com
+ * <p>
+ * <a href="https://docs.gravatar.com/api/avatars/images/">Gravatar API</a>
+ */
+@Named("gravatar")
+class GravatarProvider implements AvatarsProvider {
+
+ private static final String AVATAR_SIZE = "s=60";
+
+ private static final String AVATAR_DIRECTORY = "avatars";
+
+ private String baseUrl = "https://www.gravatar.com/avatar/";
+
+ private Path outputDirectory;
+
+ @Override
+ public void setBaseUrl(String baseUrl) {
+ this.baseUrl = baseUrl.endsWith("/") ? baseUrl : baseUrl + "/";
+ }
+
+ @Override
+ public void setOutputDirectory(File outputDirectory) {
+ this.outputDirectory = outputDirectory.toPath();
+ }
+
+ public String getExternalAvatarUrl(String email) {
+
+ if (email == null || email.isEmpty()) {
+ return getSpacerGravatarUrl();
+ }
+
+ email = email.trim().toLowerCase(Locale.ROOT);
+ MessageDigest md;
Review Comment:
This can move into the try block, I think.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [MPIR-478] Allow to save avatars images for team report during project build [maven-project-info-reports-plugin]
Posted by "elharo (via GitHub)" <gi...@apache.org>.
elharo commented on code in PR #97:
URL: https://github.com/apache/maven-project-info-reports-plugin/pull/97#discussion_r1963524553
##########
src/main/java/org/apache/maven/report/projectinfo/TeamReport.java:
##########
@@ -288,32 +334,13 @@ private void renderTeamMember(Contributor member, Map<String, Boolean> headersMa
sink.tableRow_();
}
- private static final String AVATAR_SIZE = "s=60";
-
- private String getSpacerGravatarUrl() {
- return protocol + "://www.gravatar.com/avatar/00000000000000000000000000000000?d=blank&f=y&" + AVATAR_SIZE;
- }
-
- private String getGravatarUrl(String email) {
- if (email == null) {
- return null;
- }
- email = StringUtils.trim(email);
- email = email.toLowerCase();
- MessageDigest md;
+ private String getExternalAvatarUrl(String email) {
Review Comment:
If breaking the build is the right answer — though I'm not sure it is — then that should happen higher up, likely with a MavenReportException or something like that. It shouldn't be a runtime exception from deep inside the code, whihc would indicate a bug in the code. An avatar service being unreachable is not a bug in the code, so just use a regular IOException here.
##########
src/main/java/org/apache/maven/report/projectinfo/TeamReport.java:
##########
@@ -83,9 +116,22 @@ public boolean canGenerateReport() throws MavenReportException {
}
@Override
- public void executeReport(Locale locale) {
- ProjectTeamRenderer r =
- new ProjectTeamRenderer(getSink(), project.getModel(), getI18N(locale), locale, showAvatarImages);
+ public void executeReport(Locale locale) throws MavenReportException {
+ AvatarsProvider avatarsProvider = avatarsProviders.get(avatarProviderName);
+ if (avatarsProvider == null) {
+ throw new MavenReportException("No AvatarsProvider found for name " + avatarProviderName);
Review Comment:
I suggest message then, and not breaking the report. You could also add a default image used when the server can't be reached.
##########
src/main/java/org/apache/maven/report/projectinfo/TeamReport.java:
##########
@@ -226,10 +276,7 @@ private void renderTeamMember(Contributor member, Map<String, Boolean> headersMa
Properties properties = member.getProperties();
String picUrl = properties.getProperty("picUrl");
if (picUrl == null || picUrl.isEmpty()) {
- picUrl = getGravatarUrl(member.getEmail());
- }
- if (picUrl == null || picUrl.isEmpty()) {
- picUrl = getSpacerGravatarUrl();
+ picUrl = getExternalAvatarUrl(member.getEmail());
Review Comment:
What if a user doesn't have an avatar? I don't think I do, for instance.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [MPIR-478] Allow to save avatars images for team report during project build [maven-project-info-reports-plugin]
Posted by "slawekjaranowski (via GitHub)" <gi...@apache.org>.
slawekjaranowski commented on code in PR #97:
URL: https://github.com/apache/maven-project-info-reports-plugin/pull/97#discussion_r1963038490
##########
src/main/java/org/apache/maven/report/projectinfo/TeamReport.java:
##########
@@ -83,9 +116,22 @@ public boolean canGenerateReport() throws MavenReportException {
}
@Override
- public void executeReport(Locale locale) {
- ProjectTeamRenderer r =
- new ProjectTeamRenderer(getSink(), project.getModel(), getI18N(locale), locale, showAvatarImages);
+ public void executeReport(Locale locale) throws MavenReportException {
+ AvatarsProvider avatarsProvider = avatarsProviders.get(avatarProviderName);
+ if (avatarsProvider == null) {
+ throw new MavenReportException("No AvatarsProvider found for name " + avatarProviderName);
Review Comment:
user want to show avatars, and probably misconfigured plugin - so we should not hide such case
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [MPIR-478] Allow to save avatars images for team report during project build [maven-project-info-reports-plugin]
Posted by "slawekjaranowski (via GitHub)" <gi...@apache.org>.
slawekjaranowski merged PR #97:
URL: https://github.com/apache/maven-project-info-reports-plugin/pull/97
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [MPIR-478] Allow to save avatars images for team report during project build [maven-project-info-reports-plugin]
Posted by "slawekjaranowski (via GitHub)" <gi...@apache.org>.
slawekjaranowski commented on code in PR #97:
URL: https://github.com/apache/maven-project-info-reports-plugin/pull/97#discussion_r1962494622
##########
src/main/java/org/apache/maven/report/projectinfo/TeamReport.java:
##########
@@ -52,19 +53,50 @@ public class TeamReport extends AbstractProjectInfoReport {
/**
* Shows avatar images for team members that have a) properties/picUrl set b) An avatar at gravatar.com for their
* email address
- * <p/>
- * Future versions of this plugin may implement different strategies for resolving avatar images, possibly
- * using different providers.
- *<p>
- *<strong>Note</strong>: This property will be renamed to {@code tteam.showAvatarImages} in 3.0.
+ *
* @since 2.6
*/
@Parameter(property = "teamlist.showAvatarImages", defaultValue = "true")
private boolean showAvatarImages;
+ /**
+ * Indicate if external url should be used for avatar images.
Review Comment:
I've rewritten a little here ...
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [MPIR-478] Allow to save avatars images for team report during project build [maven-project-info-reports-plugin]
Posted by "slawekjaranowski (via GitHub)" <gi...@apache.org>.
slawekjaranowski commented on code in PR #97:
URL: https://github.com/apache/maven-project-info-reports-plugin/pull/97#discussion_r1963584508
##########
src/main/java/org/apache/maven/report/projectinfo/TeamReport.java:
##########
@@ -288,32 +334,13 @@ private void renderTeamMember(Contributor member, Map<String, Boolean> headersMa
sink.tableRow_();
}
- private static final String AVATAR_SIZE = "s=60";
-
- private String getSpacerGravatarUrl() {
- return protocol + "://www.gravatar.com/avatar/00000000000000000000000000000000?d=blank&f=y&" + AVATAR_SIZE;
- }
-
- private String getGravatarUrl(String email) {
- if (email == null) {
- return null;
- }
- email = StringUtils.trim(email);
- email = email.toLowerCase();
- MessageDigest md;
+ private String getExternalAvatarUrl(String email) {
Review Comment:
If we think in this way, we should not break a Maven build when artifact cannot be fetched from remote repository due to IOException ... but we break a build
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [MPIR-478] Allow to save avatars images for team report during project build [maven-project-info-reports-plugin]
Posted by "elharo (via GitHub)" <gi...@apache.org>.
elharo commented on code in PR #97:
URL: https://github.com/apache/maven-project-info-reports-plugin/pull/97#discussion_r1963599494
##########
src/main/java/org/apache/maven/report/projectinfo/TeamReport.java:
##########
@@ -288,32 +334,13 @@ private void renderTeamMember(Contributor member, Map<String, Boolean> headersMa
sink.tableRow_();
}
- private static final String AVATAR_SIZE = "s=60";
-
- private String getSpacerGravatarUrl() {
- return protocol + "://www.gravatar.com/avatar/00000000000000000000000000000000?d=blank&f=y&" + AVATAR_SIZE;
- }
-
- private String getGravatarUrl(String email) {
- if (email == null) {
- return null;
- }
- email = StringUtils.trim(email);
- email = email.toLowerCase();
- MessageDigest md;
+ private String getExternalAvatarUrl(String email) {
Review Comment:
Not fetching an artifact is far more serious than not fetching a user pic. It's reasonable that one breaks the build and the other doesn't.
If you can't throw MavenReportException from renderBody then pass the IOException up the stack to something that can. Or change the method signature so it can throw, though here I really think the exception can simply be handled by dropping the image. Perhaps this exception can be handled by using the default image.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [MPIR-478] Allow to save avatars images for team report during project build [maven-project-info-reports-plugin]
Posted by "elharo (via GitHub)" <gi...@apache.org>.
elharo commented on code in PR #97:
URL: https://github.com/apache/maven-project-info-reports-plugin/pull/97#discussion_r1963958745
##########
src/main/java/org/apache/maven/report/projectinfo/TeamReport.java:
##########
@@ -226,10 +276,7 @@ private void renderTeamMember(Contributor member, Map<String, Boolean> headersMa
Properties properties = member.getProperties();
String picUrl = properties.getProperty("picUrl");
if (picUrl == null || picUrl.isEmpty()) {
- picUrl = getGravatarUrl(member.getEmail());
- }
- if (picUrl == null || picUrl.isEmpty()) {
- picUrl = getSpacerGravatarUrl();
+ picUrl = getExternalAvatarUrl(member.getEmail());
Review Comment:
Looks like you can handle the IOException in this method. It doesn't need tonescape this class. Just wrap lines 277 through 285 in a try-catch block. The catch block can be empty or it can fill in a default image.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org