View Javadoc

1   package org.apache.maven.continuum;
2   
3   /*
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use this file except in compliance
10   * with the License.  You may obtain a copy of the License at
11   *
12   *   http://www.apache.org/licenses/LICENSE-2.0
13   *
14   * Unless required by applicable law or agreed to in writing,
15   * software distributed under the License is distributed on an
16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17   * KIND, either express or implied.  See the License for the
18   * specific language governing permissions and limitations
19   * under the License.
20   */
21  
22  import org.apache.continuum.buildagent.NoBuildAgentException;
23  import org.apache.continuum.buildagent.NoBuildAgentInGroupException;
24  import org.apache.continuum.builder.distributed.manager.DistributedBuildManager;
25  import org.apache.continuum.buildmanager.BuildsManager;
26  import org.apache.continuum.model.project.ProjectGroupSummary;
27  import org.apache.continuum.model.project.ProjectScmRoot;
28  import org.apache.continuum.model.release.ContinuumReleaseResult;
29  import org.apache.continuum.purge.ContinuumPurgeManager;
30  import org.apache.continuum.purge.PurgeConfigurationService;
31  import org.apache.continuum.release.distributed.manager.DistributedReleaseManager;
32  import org.apache.continuum.repository.RepositoryService;
33  import org.apache.continuum.taskqueue.manager.TaskQueueManager;
34  import org.apache.continuum.utils.build.BuildTrigger;
35  import org.apache.maven.continuum.builddefinition.BuildDefinitionService;
36  import org.apache.maven.continuum.configuration.ConfigurationService;
37  import org.apache.maven.continuum.installation.InstallationService;
38  import org.apache.maven.continuum.model.project.BuildDefinition;
39  import org.apache.maven.continuum.model.project.BuildQueue;
40  import org.apache.maven.continuum.model.project.BuildResult;
41  import org.apache.maven.continuum.model.project.Project;
42  import org.apache.maven.continuum.model.project.ProjectGroup;
43  import org.apache.maven.continuum.model.project.ProjectNotifier;
44  import org.apache.maven.continuum.model.project.Schedule;
45  import org.apache.maven.continuum.model.scm.ChangeSet;
46  import org.apache.maven.continuum.profile.ProfileService;
47  import org.apache.maven.continuum.project.builder.ContinuumProjectBuildingResult;
48  import org.apache.maven.continuum.release.ContinuumReleaseManager;
49  
50  import java.io.File;
51  import java.util.Collection;
52  import java.util.Date;
53  import java.util.List;
54  import java.util.Map;
55  
56  /**
57   * @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
58   * @author <a href="mailto:trygvis@inamo.no">Trygve Laugst&oslash;l</a>
59   * @version $Id: Continuum.java 1372260 2012-08-13 04:29:09Z brett $
60   */
61  public interface Continuum
62  {
63      String ROLE = Continuum.class.getName();
64  
65      // ----------------------------------------------------------------------
66      // Project Groups
67      // ----------------------------------------------------------------------
68  
69      public ProjectGroup getProjectGroup( int projectGroupId )
70          throws ContinuumException;
71  
72      public List<ProjectGroup> getAllProjectGroupsWithBuildDetails();
73  
74      public List<ProjectGroup> getAllProjectGroups();
75  
76      public ProjectGroup getProjectGroupByProjectId( int projectId )
77          throws ContinuumException;
78  
79      public Collection<Project> getProjectsInGroup( int projectGroupId )
80          throws ContinuumException;
81  
82      public Collection<Project> getProjectsInGroupWithDependencies( int projectGroupId )
83          throws ContinuumException;
84  
85      public void removeProjectGroup( int projectGroupId )
86          throws ContinuumException;
87  
88      public void addProjectGroup( ProjectGroup projectGroup )
89          throws ContinuumException;
90  
91      public ProjectGroup getProjectGroupWithProjects( int projectGroupId )
92          throws ContinuumException;
93  
94      public ProjectGroup getProjectGroupWithBuildDetails( int projectGroupId )
95          throws ContinuumException;
96  
97      public ProjectGroup getProjectGroupByGroupId( String groupId )
98          throws ContinuumException;
99  
100     public ProjectGroup getProjectGroupByGroupIdWithBuildDetails( String groupId )
101         throws ContinuumException;
102 
103     public List<ProjectGroup> getAllProjectGroupsWithRepository( int repositoryId );
104 
105     // ----------------------------------------------------------------------
106     // Project
107     // ----------------------------------------------------------------------
108 
109     void removeProject( int projectId )
110         throws ContinuumException;
111 
112 
113     /**
114      * @param projectId
115      * @throws ContinuumException
116      * @deprecated
117      */
118     @Deprecated
119     void checkoutProject( int projectId )
120         throws ContinuumException;
121 
122     Project getProject( int projectId )
123         throws ContinuumException;
124 
125     Project getProjectWithBuildDetails( int projectId )
126         throws ContinuumException;
127 
128     Collection<Project> getProjects()
129         throws ContinuumException;
130 
131     Collection<Project> getProjectsWithDependencies()
132         throws ContinuumException;
133 
134     BuildResult getLatestBuildResultForProject( int projectId );
135 
136     Map<Integer, BuildResult> getLatestBuildResults( int projectGroupId );
137 
138     Map<Integer, BuildResult> getBuildResultsInSuccess( int projectGroupId );
139 
140     Map<Integer, ProjectGroupSummary> getProjectsSummaryByGroups();
141 
142     // ----------------------------------------------------------------------
143     // Building
144     // ----------------------------------------------------------------------
145 
146     /**
147      * take a collection of projects and sort for order
148      *
149      * @param projects
150      * @return
151      */
152     List<Project> getProjectsInBuildOrder( Collection<Project> projects );
153 
154     void buildProjects( String username )
155         throws ContinuumException, NoBuildAgentException, NoBuildAgentInGroupException;
156 
157     void buildProjectsWithBuildDefinition( List<Project> projects, List<BuildDefinition> bds )
158         throws ContinuumException, NoBuildAgentException, NoBuildAgentInGroupException;
159 
160     void buildProjectsWithBuildDefinition( List<Project> projects, int buildDefinitionId )
161         throws ContinuumException, NoBuildAgentException, NoBuildAgentInGroupException;
162 
163     void buildProjects( BuildTrigger buildTrigger )
164         throws ContinuumException, NoBuildAgentException, NoBuildAgentInGroupException;
165 
166     void buildProjects( Schedule schedule )
167         throws ContinuumException;
168 
169     void buildProject( int projectId, String username )
170         throws ContinuumException, NoBuildAgentException, NoBuildAgentInGroupException;
171 
172     void buildProject( int projectId, BuildTrigger buildTrigger )
173         throws ContinuumException, NoBuildAgentException, NoBuildAgentInGroupException;
174 
175     void buildProjectWithBuildDefinition( int projectId, int buildDefinitionId, BuildTrigger buildTrigger )
176         throws ContinuumException, NoBuildAgentException, NoBuildAgentInGroupException;
177 
178     void buildProject( int projectId, int buildDefinitionId, BuildTrigger buildTrigger )
179         throws ContinuumException, NoBuildAgentException, NoBuildAgentInGroupException;
180 
181     public void buildProjectGroup( int projectGroupId, BuildTrigger buildTrigger )
182         throws ContinuumException, NoBuildAgentException, NoBuildAgentInGroupException;
183 
184     public void buildProjectGroupWithBuildDefinition( int projectGroupId, int buildDefinitionId,
185                                                       BuildTrigger buildTrigger )
186         throws ContinuumException, NoBuildAgentException, NoBuildAgentInGroupException;
187 
188     // ----------------------------------------------------------------------
189     // Build information
190     // ----------------------------------------------------------------------
191 
192     BuildResult getBuildResult( int buildId )
193         throws ContinuumException;
194 
195     BuildResult getBuildResultByBuildNumber( int projectId, int buildNumber )
196         throws ContinuumException;
197 
198     String getBuildOutput( int projectId, int buildId )
199         throws ContinuumException;
200 
201     long getNbBuildResultsForProject( int projectId );
202 
203     Collection<BuildResult> getBuildResultsForProject( int projectId )
204         throws ContinuumException;
205 
206     List<ChangeSet> getChangesSinceLastSuccess( int projectId, int buildResultId )
207         throws ContinuumException;
208 
209     void removeBuildResult( int buildId )
210         throws ContinuumException;
211 
212     List<BuildResult> getBuildResultsInRange( int projectGroupId, Date fromDate, Date toDate, int state,
213                                               String triggeredBy );
214 
215     // ----------------------------------------------------------------------
216     // Projects
217     // ----------------------------------------------------------------------
218 
219     /**
220      * Add a project to the list of building projects (ant, shell,...)
221      *
222      * @param project        the project to add
223      * @param executorId     the id of an {@link org.apache.maven.continuum.execution.ContinuumBuildExecutor}, eg. <code>ant</code> or <code>shell</code>
224      * @param projectGroupId
225      * @return id of the project
226      * @throws ContinuumException
227      */
228     int addProject( Project project, String executorId, int projectGroupId )
229         throws ContinuumException;
230 
231     /**
232      * Add a project to the list of building projects (ant, shell,...)
233      *
234      * @param project        the project to add
235      * @param executorId     the id of an {@link org.apache.maven.continuum.execution.ContinuumBuildExecutor}, eg. <code>ant</code> or <code>shell</code>
236      * @param projectGroupId
237      * @return id of the project
238      * @throws ContinuumException
239      */
240     int addProject( Project project, String executorId, int projectGroupId, int buildDefintionTemplateId )
241         throws ContinuumException;
242 
243     /**
244      * Add a Maven 2 project to the list of projects.
245      *
246      * @param metadataUrl url of the pom.xml
247      * @return a holder with the projects, project groups and errors occurred during the project adding
248      * @throws ContinuumException
249      */
250     ContinuumProjectBuildingResult addMavenTwoProject( String metadataUrl )
251         throws ContinuumException;
252 
253     /**
254      * Add a Maven 2 project to the list of projects.
255      *
256      * @param metadataUrl   url of the pom.xml
257      * @param checkProtocol check if the protocol is allowed, use false if the pom is uploaded
258      * @return a holder with the projects, project groups and errors occurred during the project adding
259      * @throws ContinuumException
260      */
261     ContinuumProjectBuildingResult addMavenTwoProject( String metadataUrl, boolean checkProtocol )
262         throws ContinuumException;
263 
264     /**
265      * Add a Maven 2 project to the list of projects.
266      *
267      * @param metadataUrl    url of the pom.xml
268      * @param projectGroupId id of the project group to use
269      * @return a holder with the projects, project groups and errors occurred during the project adding
270      * @throws ContinuumException
271      */
272     ContinuumProjectBuildingResult addMavenTwoProject( String metadataUrl, int projectGroupId )
273         throws ContinuumException;
274 
275     /**
276      * Add a Maven 2 project to the list of projects.
277      *
278      * @param metadataUrl    url of the pom.xml
279      * @param projectGroupId id of the project group to use
280      * @param checkProtocol  check if the protocol is allowed, use false if the pom is uploaded
281      * @return a holder with the projects, project groups and errors occurred during the project adding
282      * @throws ContinuumException
283      */
284     ContinuumProjectBuildingResult addMavenTwoProject( String metadataUrl, int projectGroupId, boolean checkProtocol )
285         throws ContinuumException;
286 
287     /**
288      * Add a Maven 2 project to the list of projects.
289      *
290      * @param metadataUrl         url of the pom.xml
291      * @param projectGroupId      id of the project group to use
292      * @param checkProtocol       check if the protocol is allowed, use false if the pom is uploaded
293      * @param useCredentialsCache whether to use cached scm account credentials or not
294      * @return a holder with the projects, project groups and errors occurred during the project adding
295      * @throws ContinuumException
296      */
297     ContinuumProjectBuildingResult addMavenTwoProject( String metadataUrl, int projectGroupId, boolean checkProtocol,
298                                                        boolean useCredentialsCache )
299         throws ContinuumException;
300 
301 
302     /**
303      * Add a Maven 2 project to the list of projects.
304      *
305      * @param metadataUrl           url of the pom.xml
306      * @param projectGroupId        id of the project group to use
307      * @param checkProtocol         check if the protocol is allowed, use false if the pom is uploaded
308      * @param useCredentialsCache   whether to use cached scm account credentials or not
309      * @param loadRecursiveProjects if multi modules project record all projects (if false only root project added)
310      * @return a holder with the projects, project groups and errors occurred during the project adding
311      * @throws ContinuumException
312      */
313     public ContinuumProjectBuildingResult addMavenTwoProject( String metadataUrl, int projectGroupId,
314                                                               boolean checkProtocol, boolean useCredentialsCache,
315                                                               boolean loadRecursiveProjects )
316         throws ContinuumException;
317 
318     /**
319      * Add a Maven 2 project to the list of projects.
320      *
321      * @param metadataUrl               url of the pom.xml
322      * @param projectGroupId            id of the project group to use
323      * @param checkProtocol             check if the protocol is allowed, use false if the pom is uploaded
324      * @param useCredentialsCache       whether to use cached scm account credentials or not
325      * @param loadRecursiveProjects     if multi modules project record all projects (if false only root project added)
326      * @param buildDefintionTemplateId  buildDefintionTemplateId
327      * @param checkoutInSingleDirectory TODO
328      * @return a holder with the projects, project groups and errors occurred during the project adding
329      * @throws ContinuumException
330      */
331     public ContinuumProjectBuildingResult addMavenTwoProject( String metadataUrl, int projectGroupId,
332                                                               boolean checkProtocol, boolean useCredentialsCache,
333                                                               boolean loadRecursiveProjects,
334                                                               int buildDefintionTemplateId,
335                                                               boolean checkoutInSingleDirectory )
336         throws ContinuumException;
337 
338     /**
339      * Add a Maven 1 project to the list of projects.
340      *
341      * @param metadataUrl    url of the project.xml
342      * @param projectGroupId id of the project group to use
343      * @return a holder with the projects, project groups and errors occurred during the project adding
344      * @throws ContinuumException
345      */
346     ContinuumProjectBuildingResult addMavenOneProject( String metadataUrl, int projectGroupId )
347         throws ContinuumException;
348 
349     /**
350      * Add a Maven 1 project to the list of projects.
351      *
352      * @param metadataUrl    url of the project.xml
353      * @param projectGroupId id of the project group to use
354      * @param checkProtocol  check if the protocol is allowed, use false if the pom is uploaded
355      * @return a holder with the projects, project groups and errors occurred during the project adding
356      * @throws ContinuumException
357      */
358     ContinuumProjectBuildingResult addMavenOneProject( String metadataUrl, int projectGroupId, boolean checkProtocol )
359         throws ContinuumException;
360 
361     /**
362      * Add a Maven 2 project to the list of projects.
363      *
364      * @param metadataUrl         url of the pom.xml
365      * @param projectGroupId      id of the project group to use
366      * @param checkProtocol       check if the protocol is allowed, use false if the pom is uploaded
367      * @param useCredentialsCache whether to use cached scm account credentials or not
368      * @return a holder with the projects, project groups and errors occurred during the project adding
369      * @throws ContinuumException
370      */
371     ContinuumProjectBuildingResult addMavenOneProject( String metadataUrl, int projectGroupId, boolean checkProtocol,
372                                                        boolean useCredentialsCache )
373         throws ContinuumException;
374 
375     ContinuumProjectBuildingResult addMavenOneProject( String metadataUrl, int projectGroupId, boolean checkProtocol,
376                                                        boolean useCredentialsCache, int buildDefintionTemplateId )
377         throws ContinuumException;
378 
379     void updateProject( Project project )
380         throws ContinuumException;
381 
382     void updateProjectGroup( ProjectGroup projectGroup )
383         throws ContinuumException;
384 
385     Project getProjectWithCheckoutResult( int projectId )
386         throws ContinuumException;
387 
388     Project getProjectWithAllDetails( int projectId )
389         throws ContinuumException;
390 
391     Project getProjectWithBuilds( int projectId )
392         throws ContinuumException;
393 
394     // ----------------------------------------------------------------------
395     // Notification
396     // ----------------------------------------------------------------------
397 
398     ProjectNotifier getNotifier( int projectId, int notifierId )
399         throws ContinuumException;
400 
401     ProjectNotifier updateNotifier( int projectId, ProjectNotifier notifier )
402         throws ContinuumException;
403 
404     ProjectNotifier addNotifier( int projectId, ProjectNotifier notifier )
405         throws ContinuumException;
406 
407     void removeNotifier( int projectId, int notifierId )
408         throws ContinuumException;
409 
410     ProjectNotifier getGroupNotifier( int projectGroupId, int notifierId )
411         throws ContinuumException;
412 
413     ProjectNotifier updateGroupNotifier( int projectGroupId, ProjectNotifier notifier )
414         throws ContinuumException;
415 
416     ProjectNotifier addGroupNotifier( int projectGroupId, ProjectNotifier notifier )
417         throws ContinuumException;
418 
419     void removeGroupNotifier( int projectGroupId, int notifierId )
420         throws ContinuumException;
421 
422     // ----------------------------------------------------------------------
423     // Build Definition
424     // ----------------------------------------------------------------------
425 
426     /**
427      * @deprecated
428      */
429     @Deprecated
430     List<BuildDefinition> getBuildDefinitions( int projectId )
431         throws ContinuumException;
432 
433     /**
434      * @deprecated
435      */
436     @Deprecated
437     BuildDefinition getBuildDefinition( int projectId, int buildDefinitionId )
438         throws ContinuumException;
439 
440     /**
441      * @deprecated
442      */
443     @Deprecated
444     void removeBuildDefinition( int projectId, int buildDefinitionId )
445         throws ContinuumException;
446 
447     /**
448      * returns the build definition from either the project or the project group it is a part of
449      *
450      * @param buildDefinitionId
451      * @return
452      */
453     BuildDefinition getBuildDefinition( int buildDefinitionId )
454         throws ContinuumException;
455 
456     /**
457      * returns the default build definition for the project
458      * <p/>
459      * 1) if project has default build definition, return that
460      * 2) otherwise return default build definition for parent project group
461      *
462      * @param projectId
463      * @return
464      * @throws ContinuumException
465      */
466     BuildDefinition getDefaultBuildDefinition( int projectId )
467         throws ContinuumException;
468 
469     public List<BuildDefinition> getDefaultBuildDefinitionsForProjectGroup( int projectGroupId )
470         throws ContinuumException;
471 
472     BuildDefinition addBuildDefinitionToProject( int projectId, BuildDefinition buildDefinition )
473         throws ContinuumException;
474 
475     BuildDefinition addBuildDefinitionToProjectGroup( int projectGroupId, BuildDefinition buildDefinition )
476         throws ContinuumException;
477 
478     List<BuildDefinition> getBuildDefinitionsForProject( int projectId )
479         throws ContinuumException;
480 
481     List<BuildDefinition> getBuildDefinitionsForProjectGroup( int projectGroupId )
482         throws ContinuumException;
483 
484     void removeBuildDefinitionFromProject( int projectId, int buildDefinitionId )
485         throws ContinuumException;
486 
487     void removeBuildDefinitionFromProjectGroup( int projectGroupId, int buildDefinitionId )
488         throws ContinuumException;
489 
490     BuildDefinition updateBuildDefinitionForProject( int projectId, BuildDefinition buildDefinition )
491         throws ContinuumException;
492 
493     BuildDefinition updateBuildDefinitionForProjectGroup( int projectGroupId, BuildDefinition buildDefinition )
494         throws ContinuumException;
495 
496     // ----------------------------------------------------------------------
497     // Schedule
498     // ----------------------------------------------------------------------
499 
500     Schedule getScheduleByName( String scheduleName )
501         throws ContinuumException;
502 
503     Schedule getSchedule( int id )
504         throws ContinuumException;
505 
506     Collection<Schedule> getSchedules()
507         throws ContinuumException;
508 
509     void addSchedule( Schedule schedule )
510         throws ContinuumException;
511 
512     void updateSchedule( Schedule schedule )
513         throws ContinuumException;
514 
515     void updateSchedule( int scheduleId, Map<String, String> configuration )
516         throws ContinuumException;
517 
518     void removeSchedule( int scheduleId )
519         throws ContinuumException;
520 
521     void activePurgeSchedule( Schedule schedule );
522 
523     void activeBuildDefinitionSchedule( Schedule schedule );
524 
525     // ----------------------------------------------------------------------
526     // Working copy
527     // ----------------------------------------------------------------------
528 
529     File getWorkingDirectory( int projectId )
530         throws ContinuumException;
531 
532     String getFileContent( int projectId, String directory, String filename )
533         throws ContinuumException;
534 
535     List<File> getFiles( int projectId, String currentDirectory )
536         throws ContinuumException;
537 
538     // ----------------------------------------------------------------------
539     // Configuration
540     // ----------------------------------------------------------------------
541 
542     ConfigurationService getConfiguration();
543 
544     void reloadConfiguration()
545         throws ContinuumException;
546 
547     // ----------------------------------------------------------------------
548     // Continuum Release
549     // ----------------------------------------------------------------------
550     ContinuumReleaseManager getReleaseManager();
551 
552     // ----------------------------------------------------------------------
553     // Installation
554     // ----------------------------------------------------------------------    
555 
556     InstallationService getInstallationService();
557 
558     ProfileService getProfileService();
559 
560     BuildDefinitionService getBuildDefinitionService();
561 
562     // ----------------------------------------------------------------------
563     // Continuum Purge
564     // ----------------------------------------------------------------------
565     ContinuumPurgeManager getPurgeManager();
566 
567     PurgeConfigurationService getPurgeConfigurationService();
568 
569     // ----------------------------------------------------------------------
570     // Repository Service
571     // ----------------------------------------------------------------------
572     RepositoryService getRepositoryService();
573 
574     // ----------------------------------------------------------------------
575     //
576     // ----------------------------------------------------------------------
577     List<ProjectScmRoot> getProjectScmRootByProjectGroup( int projectGroupId );
578 
579     ProjectScmRoot getProjectScmRoot( int projectScmRootId )
580         throws ContinuumException;
581 
582     ProjectScmRoot getProjectScmRootByProject( int projectId )
583         throws ContinuumException;
584 
585     ProjectScmRoot getProjectScmRootByProjectGroupAndScmRootAddress( int projectGroupId, String scmRootAddress )
586         throws ContinuumException;
587 
588     // ----------------------------------------------------------------------
589     // Task Queue Manager
590     // ----------------------------------------------------------------------
591     TaskQueueManager getTaskQueueManager();
592 
593     // ----------------------------------------------------------------------
594     // Builds Manager
595     // ----------------------------------------------------------------------
596     BuildsManager getBuildsManager();
597 
598     // ----------------------------------------------------------------------
599     // Build Queue
600     // ----------------------------------------------------------------------
601 
602     BuildQueue addBuildQueue( BuildQueue buildQueue )
603         throws ContinuumException;
604 
605     BuildQueue getBuildQueue( int buildQueueId )
606         throws ContinuumException;
607 
608     BuildQueue getBuildQueueByName( String buildQueueName )
609         throws ContinuumException;
610 
611     void removeBuildQueue( BuildQueue buildQueue )
612         throws ContinuumException;
613 
614     BuildQueue storeBuildQueue( BuildQueue buildQueue )
615         throws ContinuumException;
616 
617     List<BuildQueue> getAllBuildQueues()
618         throws ContinuumException;
619 
620     public void startup()
621         throws ContinuumException;
622 
623     ContinuumReleaseResult addContinuumReleaseResult( int projectId, String releaseId, String releaseType )
624         throws ContinuumException;
625 
626     ContinuumReleaseResult addContinuumReleaseResult( ContinuumReleaseResult releaseResult )
627         throws ContinuumException;
628 
629     void removeContinuumReleaseResult( int releaseResultId )
630         throws ContinuumException;
631 
632     ContinuumReleaseResult getContinuumReleaseResult( int releaseResultId )
633         throws ContinuumException;
634 
635     List<ContinuumReleaseResult> getContinuumReleaseResultsByProjectGroup( int projectGroupId );
636 
637     List<ContinuumReleaseResult> getAllContinuumReleaseResults();
638 
639     ContinuumReleaseResult getContinuumReleaseResult( int projectId, String releaseGoal, long startTime, long endTime )
640         throws ContinuumException;
641 
642     String getReleaseOutput( int releaseResultId )
643         throws ContinuumException;
644 
645     DistributedBuildManager getDistributedBuildManager();
646 
647     DistributedReleaseManager getDistributedReleaseManager();
648 }