[
https://jira.codehaus.org/browse/SUREFIRE-1132?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=360935#comment-360935
]
Alexander Ashitkin edited comment on SUREFIRE-1132 at 1/8/15 1:38 AM:
----------------------------------------------------------------------
Hi Tibor
with additional logging in
org.apache.maven.plugin.surefire.AbstractSurefireMojo#generateTestClasspath i
captured what indeed {code}Set<Artifact> classpathArtifacts =
getProject().getArtifacts();{code} in a case of failure returns empty set. My
log output is :
{code}
Project artifacts: []
Project classpath:
[D:\jenkins\work\workspace\sf-2.18.1-test\my-server\target\test-classes,
D:\jenkins\work\workspace\sf-2.18.1-test\my-server\target\classes]
{code}
The code to capture data, as following:
{code}
Classpath generateTestClasspath()
throws InvalidVersionSpecificationException, MojoFailureException,
ArtifactResolutionException,
ArtifactNotFoundException, MojoExecutionException
{
List<String> classpath = new ArrayList<String>( 2 +
getProject().getArtifacts().size() );
classpath.add( getTestClassesDirectory().getAbsolutePath() );
classpath.add( getClassesDirectory().getAbsolutePath() );
@SuppressWarnings( "unchecked" ) Set<Artifact> classpathArtifacts =
getProject().getArtifacts();
System.out.println( "Project artifacts: " + classpathArtifacts );
if ( getClasspathDependencyScopeExclude() != null &&
!getClasspathDependencyScopeExclude().equals( "" ) )
{
ArtifactFilter dependencyFilter = new ScopeArtifactFilter(
getClasspathDependencyScopeExclude() );
classpathArtifacts = this.filterArtifacts( classpathArtifacts,
dependencyFilter );
}
if ( getClasspathDependencyExcludes() != null )
{
ArtifactFilter dependencyFilter =
new PatternIncludesArtifactFilter( Arrays.asList(
getClasspathDependencyExcludes() ) );
classpathArtifacts = this.filterArtifacts( classpathArtifacts,
dependencyFilter );
}
for ( Artifact artifact : classpathArtifacts )
{
if ( artifact.getArtifactHandler().isAddedToClasspath() )
{
File file = artifact.getFile();
if ( file != null )
{
classpath.add( file.getPath() );
}
}
}
// Add additional configured elements to the classpath
if ( getAdditionalClasspathElements() != null )
{
for ( String classpathElement : getAdditionalClasspathElements() )
{
if ( classpathElement != null )
{
classpath.add( classpathElement );
}
}
}
// adding TestNG MethodSelector to the classpath
// Todo: move
if ( getTestNgArtifact() != null )
{
addTestNgUtilsArtifacts( classpath );
}
System.out.println( "Project classpath: " + classpath );
return new Classpath( classpath );
}
{code}
At this point surefire issue could be closed and i will look forward to raise
it aganist maven core
thank you
was (Author: alex_ashitkin):
Hi Tibor
with additional logging in
org.apache.maven.plugin.surefire.AbstractSurefireMojo#generateTestClasspath i
captured what indeed {code}Set<Artifact> classpathArtifacts =
getProject().getArtifacts();{code} in a case of failure returns nothing. My log
output is :
{code}
Project artifacts: []
Project classpath:
[D:\jenkins\work\workspace\sf-2.18.1-test\my-server\target\test-classes,
D:\jenkins\work\workspace\sf-2.18.1-test\my-server\target\classes]
{code}
The code to capture data, as following:
{code}
Classpath generateTestClasspath()
throws InvalidVersionSpecificationException, MojoFailureException,
ArtifactResolutionException,
ArtifactNotFoundException, MojoExecutionException
{
List<String> classpath = new ArrayList<String>( 2 +
getProject().getArtifacts().size() );
classpath.add( getTestClassesDirectory().getAbsolutePath() );
classpath.add( getClassesDirectory().getAbsolutePath() );
@SuppressWarnings( "unchecked" ) Set<Artifact> classpathArtifacts =
getProject().getArtifacts();
System.out.println( "Project artifacts: " + classpathArtifacts );
if ( getClasspathDependencyScopeExclude() != null &&
!getClasspathDependencyScopeExclude().equals( "" ) )
{
ArtifactFilter dependencyFilter = new ScopeArtifactFilter(
getClasspathDependencyScopeExclude() );
classpathArtifacts = this.filterArtifacts( classpathArtifacts,
dependencyFilter );
}
if ( getClasspathDependencyExcludes() != null )
{
ArtifactFilter dependencyFilter =
new PatternIncludesArtifactFilter( Arrays.asList(
getClasspathDependencyExcludes() ) );
classpathArtifacts = this.filterArtifacts( classpathArtifacts,
dependencyFilter );
}
for ( Artifact artifact : classpathArtifacts )
{
if ( artifact.getArtifactHandler().isAddedToClasspath() )
{
File file = artifact.getFile();
if ( file != null )
{
classpath.add( file.getPath() );
}
}
}
// Add additional configured elements to the classpath
if ( getAdditionalClasspathElements() != null )
{
for ( String classpathElement : getAdditionalClasspathElements() )
{
if ( classpathElement != null )
{
classpath.add( classpathElement );
}
}
}
// adding TestNG MethodSelector to the classpath
// Todo: move
if ( getTestNgArtifact() != null )
{
addTestNgUtilsArtifacts( classpath );
}
System.out.println( "Project classpath: " + classpath );
return new Classpath( classpath );
}
{code}
At this point surefire issue could be closed and i will look forward to raise
it aganist maven core
thank you
> Surefire: regular isolated classloader failures in parallelbuild
> ----------------------------------------------------------------
>
> Key: SUREFIRE-1132
> URL: https://jira.codehaus.org/browse/SUREFIRE-1132
> Project: Maven Surefire
> Issue Type: Bug
> Components: classloading
> Affects Versions: 2.17, 2.18.1
> Environment: SLES 3.0.80-0.7-default SMP x86_64 GNU/Linux
> windows server 2008 x64
> Maven 3.2.2, 3.2.3, 3.2.5
> Oracle HotSpot JDK 7u25/7u65/8u25
> Reporter: Alexander Ashitkin
> Assignee: Tibor Digana
> Attachments: consoleText-1.txt, consoleText-2.txt, consoleText-3.txt
>
>
> We have a large project of 300+ modules which regularly fails with different
> kind of classloading issues in different places in surefire plugin. The issue
> is reproduced only with parallel build and is not reproduced in single
> threaded. This is a main contributor in build instability for us. All the not
> loaded dependnecies are actually present in dependency tree. I attached 3
> different samples of how build fails.
> Surefire config:
> {code}
> <configuration>
> <forkCount>0</forkCount>
> <!--doesnt work in parrallel build. Causes build
> failures with error java.io.IOException: Stream Closed-->
> <redirectTestOutputToFile>false</redirectTestOutputToFile>
> <useManifestOnlyJar>false</useManifestOnlyJar>
> </configuration>
> {code}
> maven cmd is like install -T 10
> Please advise how to sort this out - ready to run any provided diagnostic
> and evaluate any options.
> Thanks in advance, Alexander
--
This message was sent by Atlassian JIRA
(v6.1.6#6162)