Skip to content

Commit

Permalink
Removed Folder plugin dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
balakine committed Aug 8, 2024
1 parent ae14236 commit 03dce5a
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 109 deletions.
144 changes: 71 additions & 73 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -1,80 +1,78 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>plugin</artifactId>
<version>4.86</version>
<relativePath />
</parent>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>plugin</artifactId>
<version>4.86</version>
<relativePath/>
</parent>

<artifactId>global-build-stats</artifactId>
<version>${changelist}</version>
<name>Jenkins global-build-stats plugin</name>
<packaging>hpi</packaging>
<url>https://github.com/jenkinsci/global-build-stats-plugin</url>
<artifactId>global-build-stats</artifactId>
<version>${changelist}</version>
<name>Jenkins global-build-stats plugin</name>
<packaging>hpi</packaging>
<url>https://github.com/jenkinsci/global-build-stats-plugin</url>

<developers>
<developer>
<id>dhinske</id>
<name>David Hinske</name>
<email>[email protected]</email>
</developer>
<developer>
<id>fcamblor</id>
<name>Frederic Camblor</name>
<email>[email protected]</email>
</developer>
</developers>

<dependencies>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>cloudbees-folder</artifactId>
</dependency>
<dependency>
<groupId>io.jenkins.plugins</groupId>
<artifactId>ionicons-api</artifactId>
</dependency>
<dependency>
<groupId>io.jenkins.plugins</groupId>
<artifactId>flatpickr-api</artifactId>
<version>4.6.13-5.v534d8025a_a_59</version>
</dependency> </dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>io.jenkins.tools.bom</groupId>
<artifactId>bom-2.440.x</artifactId>
<version>3221.ve8f7b_fdd149d</version>
<scope>import</scope>
<type>pom</type>
</dependency>
</dependencies>
</dependencyManagement>
<developers>
<developer>
<id>dhinske</id>
<name>David Hinske</name>
<email>[email protected]</email>
</developer>
<developer>
<id>fcamblor</id>
<name>Frederic Camblor</name>
<email>[email protected]</email>
</developer>
</developers>

<repositories>
<repository>
<id>repo.jenkins-ci.org</id>
<url>https://repo.jenkins-ci.org/public/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>io.jenkins.plugins</groupId>
<artifactId>ionicons-api</artifactId>
</dependency>
<dependency>
<groupId>io.jenkins.plugins</groupId>
<artifactId>flatpickr-api</artifactId>
<version>4.6.13-5.v534d8025a_a_59</version>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>io.jenkins.tools.bom</groupId>
<artifactId>bom-2.440.x</artifactId>
<version>3221.ve8f7b_fdd149d</version>
<scope>import</scope>
<type>pom</type>
</dependency>
</dependencies>
</dependencyManagement>

<pluginRepositories>
<pluginRepository>
<id>repo.jenkins-ci.org</id>
<url>https://repo.jenkins-ci.org/public/</url>
</pluginRepository>
</pluginRepositories>
<repositories>
<repository>
<id>repo.jenkins-ci.org</id>
<url>https://repo.jenkins-ci.org/public/</url>
</repository>
</repositories>

<properties>
<changelist>999999-SNAPSHOT</changelist>
<jenkins.version>2.440.3</jenkins.version>
</properties>
<pluginRepositories>
<pluginRepository>
<id>repo.jenkins-ci.org</id>
<url>https://repo.jenkins-ci.org/public/</url>
</pluginRepository>
</pluginRepositories>

<scm>
<connection>scm:git:https://github.com/jenkinsci/global-build-stats-plugin.git</connection>
<developerConnection>scm:git:[email protected]:jenkinsci/global-build-stats-plugin.git</developerConnection>
<url>https://github.com/jenkinsci/global-build-stats-plugin</url>
<tag>${scmTag}</tag>
</scm>
<properties>
<changelist>999999-SNAPSHOT</changelist>
<jenkins.version>2.440.3</jenkins.version>
</properties>

<scm>
<connection>scm:git:https://github.com/jenkinsci/global-build-stats-plugin.git</connection>
<developerConnection>scm:git:[email protected]:jenkinsci/global-build-stats-plugin.git</developerConnection>
<url>https://github.com/jenkinsci/global-build-stats-plugin</url>
<tag>${scmTag}</tag>
</scm>
</project>
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
package hudson.plugins.global_build_stats.business;

import hudson.model.TopLevelItem;
import hudson.model.AbstractProject;
import hudson.model.Hudson;
import hudson.model.Item;
import hudson.model.Job;
import hudson.model.Run;
import hudson.plugins.global_build_stats.GlobalBuildStatsPlugin;
Expand Down Expand Up @@ -35,8 +32,6 @@
import org.jfree.ui.RectangleEdge;
import org.jfree.ui.RectangleInsets;

import com.cloudbees.hudson.plugins.folder.Folder;

public class GlobalBuildStatsBusiness {

private static final Logger LOGGER = Logger.getLogger(GlobalBuildStatsBusiness.class.getName());
Expand Down Expand Up @@ -96,31 +91,20 @@ public void recordBuildInfos() throws IOException {
@Override
public void changePluginStateBeforeSavingIt(GlobalBuildStatsPlugin plugin) {

List<JobBuildResult> jobBuildResultsRead = new ArrayList<JobBuildResult>();
for (TopLevelItem item : Hudson.getInstance().getItems()) {
if (item instanceof Folder){
Folder f = (Folder)item;
for (TopLevelItem i : f.getItems()){
handleItem(jobBuildResultsRead,i);
}
}
if (item instanceof AbstractProject) {
handleItem(jobBuildResultsRead, item);
}
}
List<JobBuildResult> jobBuildResultsRead = Hudson.get().getAllItems(Job.class).stream()
// Cast to Job<?, ?> is necessary due to raw type returned from getAllItems
.map(job -> (Job<?, ?>) job)
.map(Job::getBuilds)
.flatMap(Collection::stream)
.map(JobBuildResultFactory.INSTANCE::createJobBuildResult)
.collect(java.util.stream.Collectors.toList());

plugin.getJobBuildResultsSharder().queueResultsToAdd(
CollectionsUtil.<JobBuildResult>minus(jobBuildResultsRead, plugin.getJobBuildResults()));
}
});
}

public void handleItem(List<JobBuildResult> results, TopLevelItem item){
if (item instanceof AbstractProject){
addBuildsFrom(results, (AbstractProject)item);
}
}

public JFreeChart createChart(BuildStatConfiguration config){
List<AbstractBuildStatChartDimension> dimensions = createDataSetBuilder(config);
return createChart(dimensions, config.getBuildStatTitle());
Expand Down Expand Up @@ -367,19 +351,6 @@ public List<AbstractBuildStatChartDimension> createDataSetBuilder(BuildStatConfi
return dimensions;
}

private static void addBuild(List<JobBuildResult> jobBuildResultsRead, Run<?, ?> build){
jobBuildResultsRead.add(JobBuildResultFactory.INSTANCE.createJobBuildResult(build));
}

private static void addBuildsFrom(List<JobBuildResult> jobBuildResultsRead, AbstractProject project){
List<Run<?, ?>> builds = project.getBuilds();
Iterator<Run<?, ?>> buildIterator = builds.iterator();

while (buildIterator.hasNext()) {
addBuild(jobBuildResultsRead, buildIterator.next());
}
}

protected static List<JobBuildResult> mergeJobBuildResults(List<JobBuildResult> existingJobResults, List<JobBuildResult> jobResultsToMerge){
List<JobBuildResult> mergedJobResultsList = new ArrayList<JobBuildResult>(existingJobResults);

Expand Down

0 comments on commit 03dce5a

Please sign in to comment.