Skip to content

Commit

Permalink
Move to unified gradle build (#1835)
Browse files Browse the repository at this point in the history
- also upgrades gradle to 5.2.1
- all builds should happen from root :<project>:<task>, build.sh removed
- tests that run the plugin may not work in IDEs unless correct setup
task run first
- special eclipse helpers to clear up classpath
- adds protections for transitive dependency overrides
  • Loading branch information
loosebazooka committed Aug 27, 2019
1 parent 00a8cfe commit af34d9f
Show file tree
Hide file tree
Showing 53 changed files with 585 additions and 2,237 deletions.
1 change: 1 addition & 0 deletions .gitignore
@@ -1,6 +1,7 @@
build
target
out
bin
*.iml
*.ipr
*.iws
Expand Down
6 changes: 1 addition & 5 deletions .travis.yml
Expand Up @@ -16,11 +16,7 @@ env:

install: true
script:
- (cd jib-core; ./gradlew --stacktrace build)
- (cd jib-plugins-common; ./gradlew --stacktrace build)
- (cd jib-gradle-plugin; ./gradlew --stacktrace build)
# unset _JAVA_OPTIONS to avoid spurious test failures
- (cd jib-maven-plugin; unset _JAVA_OPTIONS; ./mvnw -B verify -U)
- ./gradlew clean build --stacktrace

# cobbled together from
# https://docs.travis-ci.com/user/languages/java/#projects-using-gradle
Expand Down
70 changes: 21 additions & 49 deletions CONTRIBUTING.md
Expand Up @@ -6,7 +6,7 @@ just a few small guidelines you need to follow.
## Contributor License Agreement

Contributions to this project must be accompanied by a Contributor License
Agreement. You (or your employer) retain the copyright to your contribution;
Agreement. You (or your employer) retain the copyright to your contribution;
this simply gives us permission to use and redistribute your contributions as
part of the project. Head over to <https://cla.developers.google.com/> to see
your current agreements on file or to sign a new one.
Expand All @@ -17,16 +17,19 @@ again.

## Building Jib

Jib comes as 3 components:
Jib comes as 3 public components:

- `jib-core`: a library
- `jib-plugins-common`: a library with helpers for plugin builders
- `jib-core`: a library for building containers
- `jib-maven-plugin`: a Maven plugin that uses `jib-core` and `jib-plugins-common`
- `jib-gradle-plugin`: a Gradle plugin that uses `jib-core` and `jib-plugins-common`

To build, use the provided `build.sh` which builds and tests each of the
components into your local `~/.m2/repository`. Note that this script does
not run integration tests.
And 1 internal component:

- `jib-plugins-common`: a library with helpers for maven/gradle plugins

The project is configured as a single gradle build. Run `./gradlew build` to build the
whole project. Run `./gradlew install` to install all public components into the
local maven repository.

## Code Reviews

Expand All @@ -40,10 +43,7 @@ not run integration tests.
3. We follow our own [Java style guide](STYLE_GUIDE.md) that extends the [Google Java Style Guide](https://google.github.io/styleguide/javaguide.html).
3. Please include unit tests (and integration tests if applicable) for all new code.
4. Make sure all existing tests pass (but see the note below about integration tests).
* In `jib-core`, run `./gradlew clean goJF build integrationTest`
* In `jib-gradle-plugin`, run `./gradlew clean goJF build integrationTest`
* In `jib-plugins-common`, run `./gradlew clean goJF build`
* In `jib-maven-plugin`, run `./mvnw clean fmt:format verify -PintegrationTest`
* run `./gradlew clean goJF build integrationTest`
5. Associate the change with an existing issue or file a [new issue](../../issues).
6. Create a pull request!

Expand All @@ -63,64 +63,37 @@ integration tests will create local registries on ports 5000 and 6000.

## Configuring Eclipse

Jib is a mix of Gradle and Maven projects. But since we do not
publish all artifacts, we instead have the projects reference
source from their dependencies directly using `sourceSets` and
`build-helper-maven-plugin`. This complicates importing these projects
as the Gradle and Maven tooling for Eclipse faithfully replicate the
direct source references. This has a side-effect that classes
appear both in the originating project _and_ in the subprojects,
and can interfere with Eclipse's incremental compilation.

The following instructions first import the projects, and then replaces
the source-set-style references to use Eclipse's project references
instead.
Although jib is a mix of Gradle and Maven projects, we build everything using one
unifed gradle build. There is special code to include some projects directly as
source, but importing your project should be pretty straight forward.

1. Ensure you have installed the Gradle tooling for Eclipse, called
_Buildship_ (available from [the Eclipse
Marketplace](https://marketplace.eclipse.org/content/buildship-gradle-integration)).
2. **Import the Maven project:** Use _File &rarr; Open Projects from File System..._
to use the Eclipe Smart Import feature and specify the root of the Jib project.
Import the `jib-maven-plugin` project.
3. **Import the Gradle projects:** Buildship does [not yet support
1. **Import the Gradle project:** Buildship does [not yet support
Eclipse Smart Import](https://github.com/eclipse/buildship/issues/356).
Use _File &rarr; Import &rarr; Gradle &rarr; Existing Gradle Project_
and import each of `jib-core`, `jib-plugins-common`, and `jib-gradle-plugin`.
4. **Turn source-set references to project references:** For each of
`jib-plugins-common`, `jib-maven-plugin`, and `jib-gradle-plugin`:
- Right-click on the correponding project and select _Properties &rarr; Java Build Path_
- Open the _Source_ panel and remove all _linked_ source folders: these are like
symbolic links to other locations and appear like
`jib-plugins-common/main-java - /path/to/jib-core/src/main/java`.
Only folders within the project should remain when complete.
- you may wish to remove `jib-gradle-plugin`'s `src/test/resources` and
`src/integration-test/resources` too as these contain test projects,
and are not linked in as separate projects and so seem have compilation errors
- Open the _Projects_ panel and click _Add_ to select the dependencies:
- `jib-plugins-common` depends on `jib-core`
- `jib-maven-plugin` depends on `jib-core` and `jib-plugins-common`
- `jib-gradle-plugin` depends on `jib-core` and `jib-plugins-common`
and import `jib`.

Note that you will likely need to re-apply these changes whenever
you refresh or update these projects.

## Debugging the Jib Maven Plugin (`jib-maven-plugin`)

### Build and use a local snapshot
### Build and use a local snapshot

To use a local build of the `jib-maven-plugin`:

1. Build and install `jib-maven-plugin` into your local `~/.m2/repository`
with `(cd jib-maven-plugin && ./mvnw install)`; this also builds `jib-core`.
Alternatively, use the provided `build.sh` which performs an `install`.
with `./gradlew jib-maven-plugin:install`;
1. Modify your test project's `pom.xml` to reference the `-SNAPSHOT`
version of the `com.google.cloud.tools.jib` plugin.

If developing from within Eclipse with M2Eclipse (the Maven tooling for Eclipse):

1. Modify your test project's `pom.xml` to reference the `-SNAPSHOT`
version of the `com.google.cloud.tools.jib` plugin.
2. Create and launch a _Maven Build_ launch configuration for the
1. Create and launch a _Maven Build_ launch configuration for the
test project, and ensure the _Resolve Workspace artifacts_ is checked.

### Attaching a debugger
Expand All @@ -131,13 +104,12 @@ If developing with Eclipse and M2Eclipse (the Maven tooling for Eclipse), just l

## Debugging the Jib Gradle Plugin (`jib-gradle-plugin`)

### Build and use a local snapshot
### Build and use a local snapshot

To use a local build of the `jib-gradle-plugin`:

1. Build and install `jib-gradle-plugin` into your local `~/.m2/repository`
with `(cd jib-gradle-plugin && ./gradlew build install)`; this also builds `jib-core`.
Alternatively, use the provided `build.sh` which performs an `install`.
with `./gradlew jib-gradle-plugin:install`;
1. Modify your test project's `build.gradle` to look like the following:
```groovy
buildscript {
Expand Down

0 comments on commit af34d9f

Please sign in to comment.