-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SHRINKRES-274 Added support for running maven builds as a daemon (#119)
It is possible to stop the execution of the main thread and wait till some line matches a regex. Useful for cases when maven build triggers some server or other application (eg. using mvn spring-boot:run) The built() method then returns a representation of DaemonBuild - currently, it only returns if the surrounding thread is alive and if not then it can also return an instance of BuiltProject class (as a representation of the built project)
- Loading branch information
1 parent
c4ef61e
commit e095776
Showing
29 changed files
with
772 additions
and
198 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
...edded/src/main/java/org/jboss/shrinkwrap/resolver/api/maven/embedded/StandardBuilder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package org.jboss.shrinkwrap.resolver.api.maven.embedded; | ||
|
||
public interface StandardBuilder { | ||
|
||
/** | ||
* Build project using previously configured project data and environment settings. | ||
* | ||
* @return An instance of @{BuiltProject} as a representation of the built project | ||
*/ | ||
BuiltProject build(); | ||
|
||
/** | ||
* If a failure of a project maven build should be ignored. Default is <code>false</code> | ||
* | ||
* @param ignoreFailure If a failure of a project maven build should be ignored | ||
* @return Modified EmbeddedMaven instance | ||
*/ | ||
StandardBuilder ignoreFailure(boolean ignoreFailure); | ||
|
||
/** | ||
* Sets that a failure of a project maven build should be ignored. | ||
* | ||
* @return Modified EmbeddedMaven instance | ||
*/ | ||
StandardBuilder ignoreFailure(); | ||
} |
26 changes: 26 additions & 0 deletions
26
...ed/src/main/java/org/jboss/shrinkwrap/resolver/api/maven/embedded/daemon/DaemonBuild.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package org.jboss.shrinkwrap.resolver.api.maven.embedded.daemon; | ||
|
||
import org.jboss.shrinkwrap.resolver.api.maven.embedded.BuiltProject; | ||
|
||
/** | ||
* A representation of the daemon Maven build | ||
*/ | ||
public interface DaemonBuild { | ||
|
||
/** | ||
* Checks if this thread containing the Maven build is alive. | ||
* | ||
* @return <code>true</code> if the thread containing the Maven build is alive; | ||
* <code>false</code> otherwise. | ||
*/ | ||
boolean isAlive(); | ||
|
||
/** | ||
* If the thread containing the Maven build is not alive, then it returns an instance of @{BuiltProject} as a | ||
* representation of the built project; {@code null} otherwise | ||
* | ||
* @return If Maven build is not alive then an instance of @{BuiltProject} as a representation of the built project; | ||
* {@code null} otherwise | ||
*/ | ||
BuiltProject getBuiltProject(); | ||
} |
4 changes: 4 additions & 0 deletions
4
...main/java/org/jboss/shrinkwrap/resolver/api/maven/embedded/daemon/DaemonBuildTrigger.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
package org.jboss.shrinkwrap.resolver.api.maven.embedded.daemon; | ||
|
||
public interface DaemonBuildTrigger { | ||
} |
14 changes: 14 additions & 0 deletions
14
...rg/jboss/shrinkwrap/resolver/api/maven/embedded/daemon/DaemonBuildTriggerWithTimeout.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package org.jboss.shrinkwrap.resolver.api.maven.embedded.daemon; | ||
|
||
import java.util.concurrent.TimeoutException; | ||
|
||
public interface DaemonBuildTriggerWithTimeout extends DaemonBuildTrigger { | ||
|
||
/** | ||
* Triggers a build of the project using previously configured project data and environment settings. | ||
* | ||
* @return An instance of {@link DaemonBuild} as a representation of the daemon Maven build. | ||
* @throws TimeoutException if the previously set condition hasn't been met within the set timeout. | ||
*/ | ||
DaemonBuild build() throws TimeoutException; | ||
} |
11 changes: 11 additions & 0 deletions
11
...jboss/shrinkwrap/resolver/api/maven/embedded/daemon/DaemonBuildTriggerWithoutTimeout.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package org.jboss.shrinkwrap.resolver.api.maven.embedded.daemon; | ||
|
||
public interface DaemonBuildTriggerWithoutTimeout extends DaemonBuildTrigger { | ||
|
||
/** | ||
* Triggers a build of the project using previously configured project data and environment settings. | ||
* | ||
* @return An instance of {@link DaemonBuild} as a representation of the daemon Maven build. | ||
*/ | ||
DaemonBuild build(); | ||
} |
11 changes: 11 additions & 0 deletions
11
.../src/main/java/org/jboss/shrinkwrap/resolver/api/maven/embedded/daemon/DaemonBuilder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package org.jboss.shrinkwrap.resolver.api.maven.embedded.daemon; | ||
|
||
public interface DaemonBuilder<DAEMON_TRIGGER_TYPE extends DaemonBuildTrigger> { | ||
|
||
/** | ||
* Ensures that the build of the project will be triggered in separated thread. | ||
* | ||
* @return Instance of some implementation of {@link DaemonBuildTrigger} | ||
*/ | ||
DAEMON_TRIGGER_TYPE useAsDaemon(); | ||
} |
27 changes: 27 additions & 0 deletions
27
...ava/org/jboss/shrinkwrap/resolver/api/maven/embedded/daemon/WithTimeoutDaemonBuilder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package org.jboss.shrinkwrap.resolver.api.maven.embedded.daemon; | ||
|
||
import java.util.concurrent.TimeUnit; | ||
import java.util.concurrent.TimeoutException; | ||
|
||
public interface WithTimeoutDaemonBuilder extends DaemonBuildTriggerWithoutTimeout { | ||
|
||
/** | ||
* Resolver will wait until the specified regex matches some line of the build output. | ||
* If the output is not present within two minutes, then {@link TimeoutException} is thrown | ||
* | ||
* @param regex Regex a line of the build output should match | ||
* @return An instance of {@link DaemonBuildTriggerWithTimeout} | ||
*/ | ||
DaemonBuildTriggerWithTimeout withWaitUntilOutputLineMathes(String regex); | ||
|
||
/** | ||
* Resolver will wait until the specified regex matches some line of the build output. | ||
* If the output is not present within the given time, then {@link TimeoutException} is thrown | ||
* | ||
* @param regex Regex a line of the build output should match | ||
* @param timeout the maximum time to wait | ||
* @param timeoutUnit the time unit of the {@code timeout} argument | ||
* @return An instance of {@link DaemonBuildTriggerWithTimeout} | ||
*/ | ||
DaemonBuildTriggerWithTimeout withWaitUntilOutputLineMathes(String regex, long timeout, TimeUnit timeoutUnit); | ||
} |
4 changes: 4 additions & 0 deletions
4
.../org/jboss/shrinkwrap/resolver/api/maven/embedded/daemon/WithoutTimeoutDaemonBuilder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
package org.jboss.shrinkwrap.resolver.api.maven.embedded.daemon; | ||
|
||
public interface WithoutTimeoutDaemonBuilder extends DaemonBuildTriggerWithoutTimeout { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 3 additions & 1 deletion
4
...s/shrinkwrap/resolver/api/maven/embedded/pom/equipped/ConfigurationDistributionStage.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,12 @@ | ||
package org.jboss.shrinkwrap.resolver.api.maven.embedded.pom.equipped; | ||
|
||
import org.jboss.shrinkwrap.resolver.api.maven.embedded.DistributionStage; | ||
import org.jboss.shrinkwrap.resolver.api.maven.embedded.daemon.WithTimeoutDaemonBuilder; | ||
|
||
/** | ||
* @author <a href="mailto:mjobanek@redhat.com">Matous Jobanek</a> | ||
*/ | ||
public interface ConfigurationDistributionStage | ||
extends ConfigurationStage<ConfigurationDistributionStage>, DistributionStage<ConfigurationStage> { | ||
extends ConfigurationStage<ConfigurationDistributionStage, WithTimeoutDaemonBuilder>, | ||
DistributionStage<ConfigurationStage<ConfigurationDistributionStage, WithTimeoutDaemonBuilder>, WithTimeoutDaemonBuilder> { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.