Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gradle multi module, changes to watch child project #917

Merged
merged 9 commits into from
Oct 17, 2024
4 changes: 2 additions & 2 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -154,13 +154,13 @@ jobs:
- name: Run tests that require a minimum of Java 17 or later
if: ${{ matrix.java == '17' || matrix.java == '21' }}
run:
./gradlew clean install check -P"test.include"="**/TestSpringBootApplication30*,**/TestCompileJSPSource17*" -Druntime=${{ matrix.RUNTIME }} -DruntimeVersion="${{ matrix.RUNTIME_VERSION }}" --stacktrace --info --no-daemon
./gradlew clean install check -P"test.include"="**/TestSpringBootApplication30*,**/TestCompileJSPSource17*,**/TestMultiModuleLooseEarWithPages*" -Druntime=${{ matrix.RUNTIME }} -DruntimeVersion="${{ matrix.RUNTIME_VERSION }}" --stacktrace --info --no-daemon
# Run tests
- name: Run tests with Gradle on Windows
working-directory: C:/ci.gradle
# LibertyTest is excluded because test0_run hangs
# For Java 8, TestCreateWithConfigDir is excluded because test_micro_clean_liberty_plugin_variable_config runs out of memory
run: ./gradlew clean install check -P"test.exclude"="${{env.TEST_EXCLUDE}}" -Druntime=${{ matrix.RUNTIME }} -DruntimeVersion="${{ matrix.RUNTIME_VERSION }}" --stacktrace --info --no-daemon
run: ./gradlew clean install check -P"test.include"="**" -Druntime=${{ matrix.RUNTIME }} -DruntimeVersion="${{ matrix.RUNTIME_VERSION }}" --stacktrace --info --no-daemon
timeout-minutes: 75
# Copy build reports and upload artifact if build failed
- name: Copy build/report/tests/test for upload
Expand Down
12 changes: 2 additions & 10 deletions src/main/groovy/io/openliberty/tools/gradle/tasks/DevTask.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -371,15 +371,14 @@ class DevTask extends AbstractFeatureTask {
Map<String, File> libertyDirPropertyFiles = new HashMap<String, File> ();

private ServerTask serverTask = null;
Set<Project> upstreamGradleProjects;
DevTaskUtil(File buildDir, File installDirectory, File userDirectory, File serverDirectory, File sourceDirectory, File testSourceDirectory,
File configDirectory, File projectDirectory, List<File> resourceDirs, boolean changeOnDemandTestsAction,
boolean hotTests, boolean skipTests, boolean skipInstallFeature, String artifactId, int serverStartTimeout,
int verifyAppStartTimeout, int appUpdateTimeout, double compileWait,
boolean libertyDebug, boolean pollingTest, boolean container, File containerfile, File containerBuildContext,
String containerRunOpts, int containerBuildTimeout, boolean skipDefaultPorts, boolean keepTempContainerfile,
String mavenCacheLocation, String packagingType, File buildFile, boolean generateFeatures, List<Path> webResourceDirs,
List<ProjectModule> projectModuleList, Set<Project> gradleProjects
List<ProjectModule> projectModuleList
) throws IOException, PluginExecutionException {
super(buildDir, serverDirectory, sourceDirectory, testSourceDirectory, configDirectory, projectDirectory, /* multi module project directory */ projectDirectory,
resourceDirs, changeOnDemandTestsAction, hotTests, skipTests, false /* skipUTs */, false /* skipITs */, skipInstallFeature, artifactId, serverStartTimeout,
Expand All @@ -388,7 +387,6 @@ class DevTask extends AbstractFeatureTask {
null /* compileOptions not needed since useBuildRecompile is true */, keepTempContainerfile, mavenCacheLocation, projectModuleList /* multi module upstream projects */,
false /* recompileDependencies only supported in ci.maven */, packagingType, buildFile, null /* parent build files */, generateFeatures, null /* compileArtifactPaths */, null /* testArtifactPaths */, webResourceDirs /* webResources */
);
this.upstreamGradleProjects = gradleProjects;
cherylking marked this conversation as resolved.
Show resolved Hide resolved
this.libertyDirPropertyFiles = AbstractServerTask.getLibertyDirectoryPropertyFiles(installDirectory, userDirectory, serverDirectory);
ServerFeatureUtil servUtil = getServerFeatureUtil(true, libertyDirPropertyFiles);
FeaturesPlatforms fp = servUtil.getServerFeatures(serverDirectory, libertyDirPropertyFiles);
Expand Down Expand Up @@ -1216,10 +1214,6 @@ class DevTask extends AbstractFeatureTask {

@TaskAction
void action() {
//all projects contain list of all gradle projects.
// this list of projects is passed to DevTaskUtil constructor
// to be used for recompileBuildFile, updateArtifcatPaths etc
Set<Project> allProjects = new HashSet<Project>()
initializeDefaultValues();

SourceSet mainSourceSet = project.sourceSets.main;
Expand Down Expand Up @@ -1272,16 +1266,14 @@ class DevTask extends AbstractFeatureTask {
// Project modules contain all child modules. This project modules will be present only for multi-module
// used to watch sub project src and test source files
List<ProjectModule> projectModules = getProjectModules()
cherylking marked this conversation as resolved.
Show resolved Hide resolved
allProjects.add(project)
allProjects.addAll(DevTaskHelper.getAllUpstreamProjects(project))
try {
this.util = new DevTaskUtil(project.getLayout().getBuildDirectory().getAsFile().get(), serverInstallDir, getUserDir(project, serverInstallDir),
serverDirectory, sourceDirectory, testSourceDirectory, configDirectory, project.getRootDir(),
resourceDirs, changeOnDemandTestsAction.booleanValue(), hotTests.booleanValue(), skipTests.booleanValue(), skipInstallFeature.booleanValue(), artifactId, serverStartTimeout.intValue(),
verifyAppStartTimeout.intValue(), verifyAppStartTimeout.intValue(), compileWait.doubleValue(),
libertyDebug.booleanValue(), pollingTest.booleanValue(), container.booleanValue(), containerfile, containerBuildContext, containerRunOpts,
containerBuildTimeout, skipDefaultPorts.booleanValue(), keepTempContainerfile.booleanValue(), localMavenRepoForFeatureUtility,
DevTaskHelper.getPackagingType(project), buildFile, generateFeatures.booleanValue(), webResourceDirs, projectModules, allProjects
DevTaskHelper.getPackagingType(project), buildFile, generateFeatures.booleanValue(), webResourceDirs, projectModules
);
} catch (IOException | PluginExecutionException e) {
throw new GradleException("Error initializing dev mode.", e)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,14 +90,14 @@ public class TestMultiModuleLooseEarWithPages extends AbstractIntegrationTest{
nodes = (NodeList) xPath.compile(expression).evaluate(inputDoc, XPathConstants.NODESET);
Assert.assertEquals("Number of <archive/> element ==>", 2, nodes.getLength());
if (OSUtil.isWindows()) {
ejbWar = "//ejb-war-1.0-SNAPSHOT.war"
warWebappsFolder = "//multi-module-loose-ear-pages-test//war//src//main//webapp"
ejbJar = "//WEB-INF//lib//ejb-jar-1.0-SNAPSHOT.jar"
ejbWar = "\\ejb-war-1.0-SNAPSHOT.war"
warWebappsFolder = "\\multi-module-loose-ear-pages-test\\war\\src\\main\\webapp"
ejbJar = "\\WEB-INF\\lib\\ejb-jar-1.0-SNAPSHOT.jar"
}
Assert.assertTrue(List.of(nodes.item(0).getAttributes()
.getNamedItem("targetInArchive").getNodeValue(),
nodes.item(0).getAttributes()
.getNamedItem("targetInArchive").getNodeValue()).contains(ejbWar))
Assert.assertTrue(nodes.item(0).getAttributes()
.getNamedItem("targetInArchive").getNodeValue().equals(ejbWar)||
nodes.item(1).getAttributes()
.getNamedItem("targetInArchive").getNodeValue().equals(ejbWar))

expression = "/archive/archive/dir";
nodes = (NodeList) xPath.compile(expression).evaluate(inputDoc, XPathConstants.NODESET);
Expand Down
Loading