Skip to content

Commit

Permalink
Embed BuildInfo in plugin.
Browse files Browse the repository at this point in the history
- Display version, etc. info on startup
- Warn if using an unofficial release
- Determine whether build was clean (git-wise)
- Prevents publishing from unclean working dir

Fixes #394

Uses https://github.com/madvay/git-build-info plugin
  • Loading branch information
advayDev1 committed Aug 23, 2015
1 parent 65a0ac5 commit 6a82d4e
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 7 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ j2objc-gradle.iml
gradlew.bat

local.properties
src-gen/
16 changes: 12 additions & 4 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -236,10 +236,14 @@ published versions on plugins.gradle.org. All branches and tags are on the
`j2objc-contrib/j2objc-gradle` repository, not any forks. The steps are:

1. Determine the version number. Use https://semver.org to guide which
slot in the version number should be bumped. We'll call this `vX.Y.Z`.
2. As a separate commit, bump the version number in `build.gradle` and add a
brief section at the top of [CHANGELOG.md](CHANGELOG.md) indicating key
functionality and quality improvements.
slot in the version number should be bumped. We'll call this `vX.Y.Z`. Note that
this does not have to be the `-SNAPSHOT` version in build.gradle - that number
was auto-incremented after the last release and may not reflect the extent
of API changes which, per semantic versioning, whether to increment major, minor,
or patch numbers.
2. As a separate commit, update the version number in `build.gradle`, removing the
`-SNAPSHOT` suffix if any, and add a brief section at the top of
[CHANGELOG.md](CHANGELOG.md) indicating key functionality and quality improvements.
File a PR, and merge that PR into the release branch.
3. Tag the merge commit where that PR is merged into master as `vX.Y.Z` and push
that tag to the repository. It is important that this is not the commit for the PR.
Expand All @@ -255,6 +259,10 @@ git push upstream v0.4.1-alpha
./gradlew clean build publishPlugins
```

5. Push a new PR that increments build.gradle to `vX.Y.(Z+1)-SNAPSHOT`. `-SNAPSHOT`
is standard convention for marking an unofficial build (if users happen to get their
hands on one built directly from source).

### Hotfixes

Currently the development is manageable, such that release branching can be isolated
Expand Down
13 changes: 11 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/

// Based on https://plugins.gradle.org/docs/publish-plugin

plugins {
id "com.gradle.plugin-publish" version "0.9.0"
id "com.madvay.tools.build.gitbuildinfo" version "0.1.2-alpha"
}
apply plugin: 'groovy'

Expand All @@ -32,7 +32,11 @@ task wrapper(type: Wrapper) {
}

group = 'com.github.j2objccontrib.j2objcgradle'
version = '0.4.2-alpha'

// A suffix of -SNAPSHOT means this is not an official release of the
// system, but built from an intermediate source tree. See
// CONTRIBUTING.md on how to update this version number.
version = '0.4.3-alpha-SNAPSHOT'

test {
testLogging {
Expand Down Expand Up @@ -68,3 +72,8 @@ project.tasks.all {
it.from(project.file('src/main/resources/'))
}
}

buildStamp {
repoBaseUrl "https://github.com/j2objc-contrib/j2objc-gradle/tree/"
packageName "com.github.j2objccontrib.j2objcgradle"
}
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#Thu Jun 04 17:07:20 PDT 2015
#Sun Aug 23 09:54:12 PDT 2015
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,22 @@ class J2objcPlugin implements Plugin<Project> {

@Override
void apply(Project project) {
String version = BuildInfo.VERSION
String commit = BuildInfo.GIT_COMMIT
String url = BuildInfo.URL
String timestamp = BuildInfo.TIMESTAMP
project.logger.info("j2objc-gradle plugin: Version $version, Commit: $commit, Built: $timestamp, URL: $url")
if (!BuildInfo.GIT_IS_CLEAN) {
project.logger.error('j2objc-gradle plugin was built with local modification.\n' +
'If you encounter issues, please use an official release from:\n' +
' https://github.com/j2objc-contrib/j2objc-gradle/releases')
}
if (version.contains('SNAPSHOT')) {
project.logger.warn('j2objc-gradle plugin was built outside of an official release.\n' +
'If you encounter issues, please use an official release from:\n' +
' https://github.com/j2objc-contrib/j2objc-gradle/releases')
}

// This avoids a lot of "project." prefixes, such as "project.tasks.create"
project.with {
Utils.checkMinGradleVersion(GradleVersion.current())
Expand Down

0 comments on commit 6a82d4e

Please sign in to comment.