Skip to content

Commit 54039f4

Browse files
authored
fix: "Could not find artifact com.google.cloud.tools:dependencies-parent:pom:1.4.4-SNAPSHOT" in dashboard (#737)
* fix: 'Could not find artifact com.google.cloud.tools:dependencies-parent:pom:1.4.4-SNAPSHOT' in dashboard * remove module dashboard from bom, change dashboard script
1 parent ca83367 commit 54039f4

31 files changed

+2456
-22
lines changed

.kokoro/nightly/dashboard.sh

+1-2
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,13 @@ set -e
55
# Display commands being run.
66
set -x
77

8-
cd github/java-cloud-bom
8+
cd github/java-cloud-bom/dashboard
99
# M2_HOME is not used since Maven 3.5.0 https://maven.apache.org/docs/3.5.0/release-notes.html
1010
mvn -B clean install
1111

1212
# Running target of dashboard submodule
1313
# https://stackoverflow.com/questions/3459928/running-a-specific-maven-plugin-goal-from-the-command-line-in-a-sub-module-of-a/26448447#26448447
1414
# https://stackoverflow.com/questions/11091311/maven-execjava-goal-on-a-multi-module-project
15-
cd dashboard
1615

1716
# For all versions available in Maven Central and local repository
1817
mvn -B exec:java -Dexec.mainClass="com.google.cloud.tools.opensource.cloudbomdashboard.DashboardMain" \

dashboard/pom.xml

+62-5
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@
66
<parent>
77
<groupId>com.google.cloud.tools</groupId>
88
<artifactId>dependencies-parent</artifactId>
9-
<version>1.4.4-SNAPSHOT</version>
9+
<version>1.4.3</version>
1010
</parent>
1111
<artifactId>google-cloud-bom-dashboard</artifactId>
12+
<version>0.0.1-SNAPSHOT</version>
1213

1314
<name>Cloud Tools Open Source Code Hygiene Dashboard</name>
1415
<url>https://github.com/GoogleCloudPlatform/cloud-opensource-java/dashboard</url>
@@ -36,16 +37,72 @@
3637
<artifactId>freemarker</artifactId>
3738
<version>2.3.30</version>
3839
</dependency>
40+
<dependency>
41+
<groupId>org.apache.bcel</groupId>
42+
<artifactId>bcel</artifactId>
43+
<version>6.5.0</version>
44+
</dependency>
45+
<dependency>
46+
<groupId>org.apache.maven</groupId>
47+
<artifactId>maven-core</artifactId>
48+
</dependency>
49+
<dependency>
50+
<!-- required to create PlexusContainer in RepositoryUtility-->
51+
<groupId>org.apache.maven</groupId>
52+
<artifactId>maven-compat</artifactId>
53+
<version>${maven.version}</version>
54+
</dependency>
55+
<dependency>
56+
<groupId>org.apache.maven</groupId>
57+
<artifactId>maven-resolver-provider</artifactId>
58+
</dependency>
59+
<dependency>
60+
<groupId>org.apache.maven.resolver</groupId>
61+
<artifactId>maven-resolver-transport-http</artifactId>
62+
</dependency>
63+
<dependency>
64+
<groupId>org.apache.maven.resolver</groupId>
65+
<artifactId>maven-resolver-transport-file</artifactId>
66+
</dependency>
67+
<dependency>
68+
<groupId>org.apache.maven.resolver</groupId>
69+
<artifactId>maven-resolver-connector-basic</artifactId>
70+
</dependency>
71+
<dependency>
72+
<groupId>org.apache.httpcomponents</groupId>
73+
<artifactId>httpclient</artifactId>
74+
<version>4.5.12</version>
75+
</dependency>
76+
<dependency>
77+
<groupId>org.relaxng</groupId>
78+
<artifactId>jing</artifactId>
79+
<version>20181222</version>
80+
</dependency>
81+
<dependency>
82+
<groupId>isorelax</groupId>
83+
<artifactId>isorelax</artifactId>
84+
<version>20030108</version>
85+
</dependency>
86+
<dependency>
87+
<groupId>commons-cli</groupId>
88+
<artifactId>commons-cli</artifactId>
89+
<version>1.4</version>
90+
</dependency>
3991
<dependency>
4092
<groupId>com.google.guava</groupId>
4193
<artifactId>guava</artifactId>
4294
</dependency>
95+
4396
<dependency>
44-
<groupId>${project.groupId}</groupId>
45-
<artifactId>dependencies</artifactId>
46-
<version>${project.version}</version>
97+
<groupId>com.google.truth.extensions</groupId>
98+
<artifactId>truth-java8-extension</artifactId>
99+
<scope>test</scope>
100+
</dependency>
101+
<dependency>
102+
<groupId>com.google.guava</groupId>
103+
<artifactId>guava-testlib</artifactId>
104+
<scope>test</scope>
47105
</dependency>
48-
49106
<dependency>
50107
<groupId>xom</groupId>
51108
<artifactId>xom</artifactId>

dashboard/src/main/java/com/google/cloud/tools/opensource/cloudbomdashboard/ArtifactCache.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
import org.eclipse.aether.artifact.Artifact;
2323

24-
import com.google.cloud.tools.opensource.dependencies.DependencyGraph;
24+
import com.google.cloud.tools.opensource.cloudbomdashboard.dependencies.DependencyGraph;
2525

2626
/**
2727
* Unified return type to bundle a lot of information about multiple artifacts together.

dashboard/src/main/java/com/google/cloud/tools/opensource/cloudbomdashboard/ArtifactInfo.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
import org.eclipse.aether.RepositoryException;
2020

21-
import com.google.cloud.tools.opensource.dependencies.DependencyGraph;
21+
import com.google.cloud.tools.opensource.cloudbomdashboard.dependencies.DependencyGraph;
2222

2323
/**
2424
* Cache of info looked up for an artifact.

dashboard/src/main/java/com/google/cloud/tools/opensource/cloudbomdashboard/ArtifactResults.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
import org.eclipse.aether.artifact.Artifact;
2525

26-
import com.google.cloud.tools.opensource.dependencies.Artifacts;
26+
import com.google.cloud.tools.opensource.cloudbomdashboard.dependencies.Artifacts;
2727

2828
/**
2929
* Collection of test results for a single artifact.

dashboard/src/main/java/com/google/cloud/tools/opensource/cloudbomdashboard/DashboardMain.java

+16-11
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@
1616

1717
package com.google.cloud.tools.opensource.cloudbomdashboard;
1818

19-
20-
import com.google.cloud.tools.opensource.dependencies.*;
19+
import com.google.cloud.tools.opensource.cloudbomdashboard.dependencies.*;
2120
import com.google.common.annotations.VisibleForTesting;
2221
import com.google.common.base.Splitter;
2322
import com.google.common.collect.ImmutableList;
@@ -82,7 +81,7 @@ public static void main(String[] arguments)
8281

8382
private static void generateAllVersions(String versionlessCoordinates)
8483
throws IOException, TemplateException, RepositoryException, URISyntaxException,
85-
MavenRepositoryException {
84+
MavenRepositoryException {
8685
List<String> elements = Splitter.on(':').splitToList(versionlessCoordinates);
8786
checkArgument(
8887
elements.size() == 2,
@@ -309,7 +308,7 @@ static void generateDashboard(
309308
throws IOException, TemplateException {
310309
TreeSet<String> artifacts = new TreeSet<>();
311310
Map<String, String> currentVersion = new HashMap<>();
312-
Map<String, String> currentPomURL = new HashMap<>();
311+
Map<String, String> sharedDepsPosition = new HashMap<>();
313312
Map<String, String> newestVersion = new HashMap<>();
314313
Map<String, String> newestPomURL = new HashMap<>();
315314
Map<String, String> sharedDepsVersion = new HashMap<>();
@@ -322,10 +321,9 @@ static void generateDashboard(
322321
String version = info.getKey().getVersion();
323322
artifacts.add(artifactId);
324323
currentVersion.put(artifactId,version);
325-
currentPomURL.put(artifactId, getPomFileURL(groupId, artifactId, version));
326324
newestVersion.put(artifactId, latestVersion(info.getKey()));
327325
newestPomURL.put(artifactId, getPomFileURL(groupId, artifactId, newestVersion.get(artifactId)));
328-
sharedDepsVersion.put(artifactId, sharedDependencyVersion(info.getKey()));
326+
sharedDepsVersion.put(artifactId, sharedDependencyVersion(info.getKey(), sharedDepsPosition));
329327
updatedTime.put(artifactId, updatedTime(info.getKey()));
330328
metadataURL.put(artifactId, getMetadataURL(info.getKey()));
331329
}
@@ -334,7 +332,7 @@ static void generateDashboard(
334332
templateData.put("table", table);
335333
templateData.put("lastUpdated", LocalDateTime.now());
336334
templateData.put("currentVersion", currentVersion);
337-
templateData.put("currentPomURL", currentPomURL);
335+
templateData.put("sharedDepsPosition", sharedDepsPosition);
338336
templateData.put("newestVersion", newestVersion);
339337
templateData.put("newestPomURL", newestPomURL);
340338
templateData.put("sharedDepsVersion", sharedDepsVersion);
@@ -410,7 +408,7 @@ public static long countFailures(List<ArtifactResults> table, String columnName)
410408
.count();
411409
}
412410

413-
private static String sharedDependencyVersion(Artifact artifact) {
411+
private static String sharedDependencyVersion(Artifact artifact, Map<String, String> sharedDepsPosition) {
414412
String groupPath = artifact.getGroupId().replace('.', '/');
415413
String pomPath = getPomFileURL(artifact.getGroupId(), artifact.getArtifactId(),artifact.getVersion());
416414
String parentPath = basePath + "/" + groupPath
@@ -422,14 +420,21 @@ private static String sharedDependencyVersion(Artifact artifact) {
422420
+ "/" + artifact.getVersion()
423421
+ "/" + artifact.getArtifactId() + "-deps-bom-" + artifact.getVersion() + ".pom";
424422
String version = getSharedDepsVersionFromURL(parentPath);
425-
if (version != null)
423+
if (version != null) {
424+
sharedDepsPosition.put(artifact.getArtifactId(), parentPath);
426425
return version;
426+
}
427427
version = getSharedDepsVersionFromURL(pomPath);
428-
if (version != null)
428+
if (version != null) {
429+
sharedDepsPosition.put(artifact.getArtifactId(), pomPath);
429430
return version;
431+
}
430432
version = getSharedDepsVersionFromURL(depsBomPath);
431-
if (version != null)
433+
if (version != null) {
434+
sharedDepsPosition.put(artifact.getArtifactId(), depsBomPath);
432435
return version;
436+
}
437+
sharedDepsPosition.put(artifact.getArtifactId(), "");
433438
return "";
434439
}
435440
private static String getSharedDepsVersionFromURL(String pomURL) {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
/*
2+
* Copyright 2020 Google LLC.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package com.google.cloud.tools.opensource.cloudbomdashboard.dependencies;
18+
19+
import static com.google.common.base.Preconditions.checkNotNull;
20+
import static com.google.common.base.Verify.verify;
21+
import static com.google.common.collect.ImmutableList.toImmutableList;
22+
23+
import com.google.common.base.Joiner;
24+
import com.google.common.collect.ImmutableList;
25+
import com.google.common.collect.ImmutableListMultimap;
26+
import com.google.common.collect.Iterables;
27+
import com.google.common.collect.Multimaps;
28+
import java.util.List;
29+
import java.util.Objects;
30+
import org.eclipse.aether.artifact.Artifact;
31+
import org.eclipse.aether.graph.Dependency;
32+
import org.eclipse.aether.graph.DependencyNode;
33+
34+
/** Problem in a Maven artifact in a dependency tree. */
35+
public abstract class ArtifactProblem {
36+
37+
protected final Artifact artifact;
38+
39+
protected final ImmutableList<DependencyNode> dependencyPath;
40+
41+
// todo since the artifact is the last element in the list, there's really no
42+
// reason to pass the artifact here.
43+
protected ArtifactProblem(Artifact artifact, List<DependencyNode> dependencyPath) {
44+
this.artifact = checkNotNull(artifact);
45+
this.dependencyPath = ImmutableList.copyOf(dependencyPath);
46+
}
47+
48+
/**
49+
* Returns the dependency path to the artifact from the root of the dependency tree. An empty list
50+
* if the path is unknown.
51+
*/
52+
protected String getPath() {
53+
return Joiner.on(" > ").join(dependencyPath);
54+
}
55+
56+
/** Returns the Maven artifact that has the problem. */
57+
public Artifact getArtifact() {
58+
return artifact;
59+
}
60+
61+
/**
62+
* Returns formatted string describing {@code problems} by removing similar problems per artifact.
63+
*/
64+
public static String formatProblems(Iterable<ArtifactProblem> problems) {
65+
ImmutableListMultimap<Artifact, ArtifactProblem> artifactToProblems =
66+
Multimaps.index(problems, ArtifactProblem::getArtifact);
67+
68+
StringBuilder output = new StringBuilder();
69+
for (Artifact artifact : artifactToProblems.keySet()) {
70+
ImmutableList<ArtifactProblem> artifactProblems = artifactToProblems.get(artifact);
71+
int otherCount = artifactProblems.size() - 1;
72+
verify(otherCount >= 0, "artifactToProblems should have at least one value for one key");
73+
ArtifactProblem firstProblem = Iterables.getFirst(artifactProblems, null);
74+
output.append(firstProblem);
75+
if (otherCount == 1) {
76+
output.append(" and a problem on the same artifact.");
77+
} else if (otherCount > 1) {
78+
output.append(" and " + otherCount + " problems on the same artifact.");
79+
}
80+
output.append("\n");
81+
}
82+
return output.toString();
83+
}
84+
85+
@Override
86+
public boolean equals(Object other) {
87+
if (this == other) {
88+
return true;
89+
}
90+
if (other == null || getClass() != other.getClass()) {
91+
return false;
92+
}
93+
94+
ArtifactProblem otherProblem = (ArtifactProblem) other;
95+
return Objects.equals(artifact, otherProblem.artifact)
96+
&& equalsOnDependencies(dependencyPath, otherProblem.dependencyPath);
97+
}
98+
99+
private static boolean equalsOnDependencies(
100+
List<DependencyNode> listA, List<DependencyNode> listB) {
101+
int size = listA.size();
102+
if (listB.size() != size) {
103+
return false;
104+
}
105+
106+
for (int i = 0; i < size; i++) {
107+
DependencyNode nodeA = listA.get(i);
108+
DependencyNode nodeB = listB.get(i);
109+
Dependency dependencyA = nodeA.getDependency();
110+
Dependency dependencyB = nodeB.getDependency();
111+
if (!Objects.equals(dependencyA, dependencyB)) {
112+
return false;
113+
}
114+
}
115+
return true;
116+
}
117+
118+
@Override
119+
public int hashCode() {
120+
ImmutableList<Dependency> dependencyList =
121+
dependencyPath.stream()
122+
.map(DependencyNode::getDependency)
123+
.filter(Objects::nonNull) // root may not have a dependency
124+
.collect(toImmutableList());
125+
return Objects.hash(artifact, dependencyList);
126+
}
127+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/*
2+
* Copyright 2018 Google LLC.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package com.google.cloud.tools.opensource.cloudbomdashboard.dependencies;
18+
19+
import org.eclipse.aether.artifact.Artifact;
20+
21+
/**
22+
* Common utilities for operating on {@code org.eclipse.aether.artifact.Artifact} objects.
23+
*/
24+
public final class Artifacts {
25+
26+
private Artifacts() {
27+
}
28+
29+
/**
30+
* Returns the artifact's Maven coordinates in the form groupId:artifactId:version. Repo and
31+
* packaging are not included.
32+
*/
33+
public static String toCoordinates(Artifact artifact) {
34+
return (artifact.getGroupId() + ":" + artifact.getArtifactId() + ":" + artifact.getVersion());
35+
}
36+
37+
public static String makeKey(Artifact artifact) {
38+
return (artifact.getGroupId() + ":" + artifact.getArtifactId());
39+
}
40+
41+
}

0 commit comments

Comments
 (0)