Skip to content

Commit

Permalink
Merge pull request #1 from jcarsique/master
Browse files Browse the repository at this point in the history
JENKINS-32983: Parsing Maven Invoker results from slave
  • Loading branch information
olamy committed Feb 18, 2016
2 parents 1e08175 + 900891e commit 3cfbd3b
Show file tree
Hide file tree
Showing 13 changed files with 206 additions and 198 deletions.
160 changes: 89 additions & 71 deletions pom.xml
@@ -1,30 +1,31 @@
<?xml version='1.0' encoding='UTF-8'?>

<!--
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
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.
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.
-->
<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">
<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>1.424</version>
<!-- which version of Jenkins is this plugin built against? -->
<version>2.3</version>
<relativePath />
</parent>

<groupId>org.jenkins-ci.plugins</groupId>
Expand All @@ -43,31 +44,95 @@ under the License.
<tag>HEAD</tag>
</scm>

<properties>
<mavenVersion>3.1.0</mavenVersion>
</properties>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.jenkins-ci.main</groupId>
<artifactId>maven-plugin</artifactId>
<version>2.12.1</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.1</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpcore</artifactId>
<version>4.4.4</version>
</dependency>
<dependency>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-invoker-plugin</artifactId>
<version>2.0.0</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.4</version>
</dependency>
<dependency>
<groupId>commons-beanutils</groupId>
<artifactId>commons-beanutils</artifactId>
<version>1.9.2</version>
</dependency>
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.6</version>
</dependency>
<dependency>
<groupId>org.kohsuke.stapler</groupId>
<artifactId>stapler</artifactId>
<version>1.237</version>
</dependency>
</dependencies>
</dependencyManagement>

<dependencies>
<dependency>
<groupId>org.jenkins-ci.main</groupId>
<artifactId>maven-plugin</artifactId>
<version>1.424</version>
<scope>compile</scope>
</dependency>
<!-- Undeclared dependencies transitively retrieved from maven-plugin because their tricky configuration and exclusions: -->
<!-- org.eclipse.sisu:org.eclipse.sisu.plexus which needs exclusions -->
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-core</artifactId>
<version>${mavenVersion}</version>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-compat</artifactId>
<version>${mavenVersion}</version>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-model</artifactId>
<version>${mavenVersion}</version>
</dependency>
<dependency>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-invoker-plugin</artifactId>
<version>1.6</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.2</version>
</dependency>
<dependency>
<groupId>commons-beanutils</groupId>
<artifactId>commons-beanutils</artifactId>
<version>1.8.3</version>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
</dependency>
<dependency>
<groupId>org.kohsuke.stapler</groupId>
<artifactId>stapler</artifactId>
</dependency>
</dependencies>

<!-- get every artifact through repo.jenkins-ci.org, which proxies all the artifacts that we need -->
<repositories>
<repository>
<id>repo.jenkins-ci.org</id>
Expand All @@ -82,51 +147,4 @@ under the License.
</pluginRepository>
</pluginRepositories>

<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.jenkins-ci.tools</groupId>
<artifactId>maven-hpi-plugin</artifactId>
<version>1.85</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.12</version>
<configuration>
<systemPropertyVariables>
<java.awt.headless>true</java.awt.headless>
</systemPropertyVariables>
</configuration>

</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>2.3.2</version>
</plugin>
</plugins>
</pluginManagement>
</build>

<profiles>
<profile>
<id>mvn-debug</id>
<build>
<plugins>
<plugin>
<groupId>org.jenkins-ci.tools</groupId>
<artifactId>maven-hpi-plugin</artifactId>
<version>1.85</version>
<configuration>
<systemProperties>
<hudson.maven.debugPort>5005</hudson.maven.debugPort>
</systemProperties>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
12 changes: 12 additions & 0 deletions src/findbugs/excludesFilter.xml
@@ -0,0 +1,12 @@
<FindBugsFilter>
<Match>
<Class name="org.jenkinsci.plugins.maveninvoker.MavenInvokerArchiver$2" />
<Method name="call" />
<Bug pattern="NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE" />
</Match>
<Match>
<Class name="org.jenkinsci.plugins.maveninvoker.MavenInvokerBuildAction" />
<Method name="getMavenInvokerResults" />
<Bug pattern="NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE" />
</Match>
</FindBugsFilter>
@@ -1,4 +1,5 @@
package org.jenkinsci.plugins.maveninvoker;

/*
* Copyright (c) Olivier Lamy
* Licensed to the Apache Software Foundation (ASF) under one
Expand All @@ -24,17 +25,17 @@
import hudson.maven.MavenBuild;
import hudson.maven.MavenModule;
import hudson.maven.MavenModuleSet;
import hudson.model.AbstractBuild;
import hudson.model.Action;
import org.jenkinsci.plugins.maveninvoker.results.MavenInvokerResult;
import org.jenkinsci.plugins.maveninvoker.results.MavenInvokerResults;
import hudson.model.AbstractBuild;

import java.util.ArrayList;
import java.util.Collections;
import java.io.Serializable;
import java.util.Comparator;
import java.util.List;
import java.util.Map;

import org.jenkinsci.plugins.maveninvoker.results.MavenInvokerResult;
import org.jenkinsci.plugins.maveninvoker.results.MavenInvokerResults;

/**
* @author Olivier Lamy
*/
Expand All @@ -55,33 +56,36 @@ public InvokerMavenAggregatedReport( AbstractBuild<?, ?> build )
super( build );
}

@Override
public void update( Map<MavenModule, List<MavenBuild>> moduleBuilds, MavenBuild newBuild )
{
InvokerReport invokerReport = newBuild.getAction( InvokerReport.class );

if ( invokerReport != null )
{
MavenInvokerResults mavenInvokerResults = invokerReport.getMavenInvokerResults();
if ( mavenInvokerResults != null )
MavenInvokerResults miResults = invokerReport.getMavenInvokerResults();
if ( miResults != null )
{
List<MavenInvokerResult> results = mavenInvokerResults.mavenInvokerResults;
this.mavenInvokerResults.mavenInvokerResults.addAll( results );
initTestCountsFields( this.mavenInvokerResults );
List<MavenInvokerResult> results = miResults.mavenInvokerResults;
mavenInvokerResults.mavenInvokerResults.addAll( results );
initTestCountsFields( mavenInvokerResults );
}
}
}

@Override
public MavenInvokerResults getMavenInvokerResults()
{
return this.mavenInvokerResults;
return mavenInvokerResults;
}

@Override
public Class<? extends AggregatableAction> getIndividualActionType()
{
return InvokerReport.class;
}

@Override
public Action getProjectAction( MavenModuleSet moduleSet )
{
return this;
Expand All @@ -90,6 +94,8 @@ public Action getProjectAction( MavenModuleSet moduleSet )
public static class MavenInvokerAggregatedBuildAction
extends MavenInvokerBuildAction
{
private static final long serialVersionUID = 1L;

MavenInvokerResults mavenInvokerResults;

public MavenInvokerAggregatedBuildAction( AbstractBuild<?, ?> build, MavenInvokerResults mavenInvokerResults )
Expand All @@ -101,7 +107,7 @@ public MavenInvokerAggregatedBuildAction( AbstractBuild<?, ?> build, MavenInvoke
@Override
public MavenInvokerResults getMavenInvokerResults()
{
return this.mavenInvokerResults;
return mavenInvokerResults;
}

@Override
Expand All @@ -116,8 +122,11 @@ protected Object readResolve()
public static final MavenInvokerResultComparator COMPARATOR_INSTANCE = new MavenInvokerResultComparator();

public static class MavenInvokerResultComparator
implements Comparator<MavenInvokerResult>
implements Comparator<MavenInvokerResult>, Serializable
{
private static final long serialVersionUID = 1L;

@Override
public int compare( MavenInvokerResult mavenInvokerResult, MavenInvokerResult mavenInvokerResult1 )
{
if ( mavenInvokerResult.mavenModuleName == null )
Expand Down
34 changes: 13 additions & 21 deletions src/main/java/org/jenkinsci/plugins/maveninvoker/InvokerReport.java
@@ -1,4 +1,5 @@
package org.jenkinsci.plugins.maveninvoker;

/*
* Copyright (c) Olivier Lamy
* Licensed to the Apache Software Foundation (ASF) under one
Expand Down Expand Up @@ -38,6 +39,8 @@ public class InvokerReport
implements AggregatableAction
{

private static final long serialVersionUID = 1L;

private MavenInvokerResults mavenInvokerResults;

public InvokerReport( AbstractBuild<?, ?> build, MavenInvokerResults mavenInvokerResults )
Expand All @@ -46,30 +49,19 @@ public InvokerReport( AbstractBuild<?, ?> build, MavenInvokerResults mavenInvoke
this.mavenInvokerResults = mavenInvokerResults;
}

@Override
public MavenAggregatedReport createAggregatedAction( MavenModuleSetBuild build,
Map<MavenModule, List<MavenBuild>> moduleBuilds )
{

/*for ( Map.Entry<MavenModule, List<MavenBuild>> entry : moduleBuilds.entrySet() )
{
for ( MavenBuild mavenBuild : entry.getValue() )
{
MavenInvokerBuildAction mavenInvokerBuildAction = mavenBuild.getAction( MavenInvokerBuildAction.class );
if ( mavenInvokerBuildAction != null )
{
MavenInvokerResults mavenInvokerResults = mavenInvokerBuildAction.getMavenInvokerResults();
if ( mavenInvokerResults != null )
{
List<MavenInvokerResult> results = mavenInvokerResults.mavenInvokerResults;
if ( results != null )
{
this.mavenInvokerResults.mavenInvokerResults.addAll( results );
}
}
}
}
}*/
/*
* for ( Map.Entry<MavenModule, List<MavenBuild>> entry : moduleBuilds.entrySet() ) { for ( MavenBuild
* mavenBuild : entry.getValue() ) { MavenInvokerBuildAction mavenInvokerBuildAction = mavenBuild.getAction(
* MavenInvokerBuildAction.class ); if ( mavenInvokerBuildAction != null ) { MavenInvokerResults
* mavenInvokerResults = mavenInvokerBuildAction.getMavenInvokerResults(); if ( mavenInvokerResults != null ) {
* List<MavenInvokerResult> results = mavenInvokerResults.mavenInvokerResults; if ( results != null ) {
* this.mavenInvokerResults.mavenInvokerResults.addAll( results ); } } } } }
*/
InvokerMavenAggregatedReport invokerMavenAggregatedReport =
build.getAction( InvokerMavenAggregatedReport.class );
if ( invokerMavenAggregatedReport != null )
Expand All @@ -82,6 +74,6 @@ public MavenAggregatedReport createAggregatedAction( MavenModuleSetBuild build,
@Override
public MavenInvokerResults getMavenInvokerResults()
{
return this.mavenInvokerResults;
return mavenInvokerResults;
}
}

0 comments on commit 3cfbd3b

Please sign in to comment.