20
20
*/
21
21
22
22
import java .io .File ;
23
+ import java .util .ArrayList ;
23
24
import java .util .List ;
24
25
import java .util .Map ;
25
26
26
27
import org .apache .maven .RepositoryUtils ;
27
28
import org .apache .maven .execution .MavenSession ;
29
+ import org .apache .maven .model .Plugin ;
30
+ import org .apache .maven .model .PluginExecution ;
28
31
import org .apache .maven .plugin .AbstractMojo ;
29
32
import org .apache .maven .plugin .MojoExecutionException ;
30
33
import org .apache .maven .plugin .MojoFailureException ;
@@ -134,9 +137,11 @@ public void execute()
134
137
}
135
138
}
136
139
137
- if ( allProjectsMarked () )
140
+ List <MavenProject > allProjectsUsingPlugin = getAllProjectsUsingPlugin ();
141
+
142
+ if ( allProjectsMarked ( allProjectsUsingPlugin ) )
138
143
{
139
- for ( MavenProject reactorProject : reactorProjects )
144
+ for ( MavenProject reactorProject : allProjectsUsingPlugin )
140
145
{
141
146
State state = getState ( reactorProject );
142
147
if ( state == State .TO_BE_INSTALLED )
@@ -147,9 +152,9 @@ public void execute()
147
152
}
148
153
}
149
154
150
- private boolean allProjectsMarked ()
155
+ private boolean allProjectsMarked ( List < MavenProject > allProjectsUsingPlugin )
151
156
{
152
- for ( MavenProject reactorProject : reactorProjects )
157
+ for ( MavenProject reactorProject : allProjectsUsingPlugin )
153
158
{
154
159
if ( !hasState ( reactorProject ) )
155
160
{
@@ -159,6 +164,36 @@ private boolean allProjectsMarked()
159
164
return true ;
160
165
}
161
166
167
+ private List <MavenProject > getAllProjectsUsingPlugin ()
168
+ {
169
+ ArrayList <MavenProject > result = new ArrayList <>();
170
+ for ( MavenProject reactorProject : reactorProjects )
171
+ {
172
+ if ( hasExecution ( reactorProject .getPlugin ( "org.apache.maven.plugins:maven-install-plugin" ) ) )
173
+ {
174
+ result .add ( reactorProject );
175
+ }
176
+ }
177
+ return result ;
178
+ }
179
+
180
+ private boolean hasExecution ( Plugin plugin )
181
+ {
182
+ if ( plugin == null )
183
+ {
184
+ return false ;
185
+ }
186
+
187
+ for ( PluginExecution execution : plugin .getExecutions () )
188
+ {
189
+ if ( !execution .getGoals ().isEmpty () && !"none" .equalsIgnoreCase ( execution .getPhase () ) )
190
+ {
191
+ return true ;
192
+ }
193
+ }
194
+ return false ;
195
+ }
196
+
162
197
private void installProject ( MavenProject project ) throws MojoExecutionException , MojoFailureException
163
198
{
164
199
try
0 commit comments