1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 package org.jdtaus.core.container.mojo;
22
23 import java.io.File;
24 import org.apache.maven.plugin.MojoExecutionException;
25 import org.apache.maven.plugin.MojoFailureException;
26 import org.jdtaus.core.container.ContainerError;
27 import org.jdtaus.core.container.ContextError;
28 import org.jdtaus.core.container.Implementation;
29 import org.jdtaus.core.container.ModelError;
30 import org.jdtaus.core.container.ModelFactory;
31 import org.jdtaus.core.container.Module;
32
33
34
35
36
37
38
39
40
41
42 public class JavaCommitTestsMojo extends JavaCommitMojo
43 {
44
45
46 public JavaCommitTestsMojo()
47 {
48 super();
49 }
50
51 public void execute() throws MojoExecutionException, MojoFailureException
52 {
53 final ClassLoader mavenLoader = Thread.currentThread().
54 getContextClassLoader();
55
56 try
57 {
58 Thread.currentThread().setContextClassLoader(
59 this.getTestClassLoader( mavenLoader ) );
60
61 enableThreadContextClassLoader();
62
63 final Module module = this.getTestModule();
64 if ( module != null )
65 {
66 for ( int i = module.getImplementations().size() - 1; i >= 0;
67 i-- )
68 {
69 final Implementation impl = module.getImplementations().
70 getImplementation( i );
71
72 this.commitImplementation(
73 ModelFactory.newModel(), impl,
74 new File( this.getMavenProject().getBuild().
75 getTestOutputDirectory() ) );
76
77 }
78 }
79 }
80 catch ( final ContextError e )
81 {
82 throw new MojoExecutionException( e.getMessage(), e );
83 }
84 catch ( final ContainerError e )
85 {
86 throw new MojoExecutionException( e.getMessage(), e );
87 }
88 catch ( final ModelError e )
89 {
90 throw new MojoExecutionException( e.getMessage(), e );
91 }
92 catch ( final Exception e )
93 {
94 throw new MojoExecutionException( e.getMessage(), e );
95 }
96 finally
97 {
98 disableThreadContextClassLoader();
99 Thread.currentThread().setContextClassLoader( mavenLoader );
100 }
101 }
102
103 }