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

Consolidate build #87

Merged
merged 23 commits into from
Jul 6, 2021
Merged

Consolidate build #87

merged 23 commits into from
Jul 6, 2021

Conversation

melix
Copy link
Collaborator

@melix melix commented Jul 1, 2021

This pull request consolidates the build in order to avoid tedious build stages. In particular:

  • it introduces a top-level Gradle build which coordinates the builds of all subprojects
  • every subproject can be built independently, or imported separatetely in the IDE if needed to focus on a specific project
  • it centralizes all dependency versions in a root gradle/libs.versions.toml file
  • it builds the Maven plugin using Gradle instead of Maven

work in progress

Fixes #82

melix added 5 commits July 1, 2021 15:08
This commit introduces a parent build which is responsible for coordinating the
build of every subproject, independently of what they are using (Maven or Gradle).
It's a Gradle composite build, which takes the responsibility of publishing
subprojects artifacts into a "common" local repository, which can be used to
verify by hand what is produced by the builds easily.

On the root project, you can now run
    `./gradlew publishAllPublicationsToCommonRepository`

which will trigger the dependent builds and publish all artifacts to:

    ./build/common-repo
It was difficult to integrate with the Maven build of the plugin in a consistent
way. Therefore, this plugin rewrites the Maven plugin build so that it is using
Gradle instead. The advantages are that now:

- versions can be shared for all projects using a single file, which is now
the `gradle/libs.versions.toml` file on the root project
- all modules can be consistently built and published using a single command
(`publishAllPublicationsToCommonRepository`)
- there's no need to publish anything to Maven Local to get started
- every project of the composite can also be built independently if needed
Before this commit, both the Maven and Gradle plugins had an identical
VersionInfo class. Instead of this, we now introduce a `utils` project
which generates this class statically at build time.

This project will be used to share common code between the Gradle and
Maven plugins, even if today it only contains a single class.
@melix
Copy link
Collaborator Author

melix commented Jul 1, 2021

Publish all artifacts, clean build, no build cache: https://scans.gradle.com/s/7nwhko7377va6
Publish all artifacts, clean build, cached: https://scans.gradle.com/s/iuwm5tb6ihtgu

melix added 8 commits July 1, 2021 17:27
It was possible that the `utils` project dependency wasn't published
to the common repository before we compute the plugin descriptors.
so that the examples can be executed properly.
Testing the Maven plugin was complicated. Not because we build it with Gradle,
but because running any build with Maven can accidentally pass because of the
presence of stale files in the local Maven repository.

In this case, we avoid the problem by completely isolating the Maven plugin
tests by running them in containers, using test containers. Because spawning
an image and re-downloading all dependencies can be pretty slow, we proceed
in multiple steps:

1. we build the plugin, and all its dependencies, and publish the result in
the local "common repository"
2. we create a docker image which base is the GraalVM image for the version
we want to test
3. we inject a "bootstrapping" Maven project in that image, which is going
to be responsible for triggering the download of the dependencies required
at test execution time, so that all dependencies are present in the image
when we want to run the tests
4. because the project needs the plugin to be built, we also inject a fake
Maven repository, the one we built at step 1, into the image
5. we use a custom settings file for Maven so that the repository is
injected in the build
6. now we can build the Docker image
7. integration tests spawn the test image and perform some verifications

It's worth noting that at this stage, there's a *single* functional test
for Maven. This test is very similar to the one done in Gradle, so, instead
of providing examples in the examples directory, we will refactor the
build so that the samples used for integration testing are also samples
that can be shown to users.
This commit consolidates the samples so that they are used for both
testing purposes, in functional testing, and for documentation.
This commit adds a task, `releaseZip` which will build all artifacts
and create a zip in `build/distributions`. This task makes sure that
the repository is pruned before building, so that it only contains
what we want to release.

The task will _not_ update the version, which needs to be done
separately if needed.
This is mostly for CI, since locally we'd get test reports.
and move the checkstyle configuration to top level, so that we can
consistently verify code.
@melix melix force-pushed the cc/consolidate-build branch 3 times, most recently from a84a0c9 to 1770df9 Compare July 2, 2021 18:58
@melix melix marked this pull request as ready for review July 2, 2021 19:17
@melix melix requested a review from lazar-mitrovic July 2, 2021 19:17
Copy link
Collaborator

@lazar-mitrovic lazar-mitrovic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall looks good, I'm glad we are getting rid of hacky shell scripts :)

README.md Outdated Show resolved Hide resolved
build-logic/build.gradle.kts Outdated Show resolved Hide resolved
common/scripts/updateVersions.sh Show resolved Hide resolved
common/utils/buildSrc/build.gradle.kts Show resolved Hide resolved
native-maven-plugin/README.md Outdated Show resolved Hide resolved
native-maven-plugin/build.gradle.kts Show resolved Hide resolved
melix added 7 commits July 3, 2021 10:18
In order to try to reduce the memory pressure for Maven tests
execution.
Since logs contains lots of garbage we don't care about. The full
log is still captured so that we can make assertions on it.
Copy link
Collaborator

@lazar-mitrovic lazar-mitrovic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maven build fails due to CI runner using Java 8 as default.
This can be fixed by adding

- uses: actions/setup-java@v1
        with:
          java-version: '11'

to the CI config file. You can then merge this PR when ready.

When running the `updateSamples` task, Gradle will now process the `samples`
directory and update the versions in those samples. This should typically
be done before a release, to make sure that what we display in samples
match what we release.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Reorganize this repository as a Gradle project with multiple subprojects
4 participants