jhipster / generator-jhipster

JHipster is a development platform to quickly generate, develop, & deploy modern web applications & microservice architectures.
https://www.jhipster.tech
Apache License 2.0
21.56k stars 4.02k forks source link

Gradle: build in production fail when there isn't git repo #4087

Closed pascalgrimaud closed 8 years ago

pascalgrimaud commented 8 years ago
Overview of the issue

When using gradle, the build in production fail if the user didn't init a git repo with git init-> no folder .git So @jdubois don't make release before this ticket is resolved plz

Reproduce the error

1) generate a gradle project 2) ./gradlew -Pprod bootRepackage

Here the stacktrace:

╭─pgrimaud@pgrxps  ~/projects/test/04-gradle  
╰─$ jhpack
:cleanResources UP-TO-DATE
:bootBuildInfo
:bower
:nodeSetup SKIPPED
:npmSetup SKIPPED
:npmInstall
npm WARN optional Skipping failed optional dependency /chokidar/fsevents:
npm WARN notsup Not compatible with your operating system or architecture: fsevents@1.0.14
:gulpBuildWithOpts
[23:47:02] Using gulpfile ~/projects/test/04-gradle/gulpfile.js
[23:47:02] Starting 'clean'...
[23:47:02] Finished 'clean' after 6.26 ms
[23:47:02] Starting 'build'...
[23:47:02] Starting 'copy:i18n'...
[23:47:02] Starting 'copy:fonts'...
[23:47:02] Starting 'copy:common'...
[23:47:02] Starting 'inject:vendor'...
[23:47:02] Starting 'ngconstant:prod'...
[23:47:02] Starting 'copy:languages'...
[23:47:02] Finished 'ngconstant:prod' after 40 ms
[23:47:02] Finished 'copy:languages' after 38 ms
[23:47:02] Finished 'copy:common' after 105 ms
[23:47:02] gulp-inject 23 files into index.html.
[23:47:02] Finished 'inject:vendor' after 109 ms
[23:47:02] Finished 'copy:fonts' after 129 ms
[23:47:02] Finished 'copy:i18n' after 146 ms
[23:47:02] Starting 'copy'...
[23:47:02] Finished 'copy' after 7.04 μs
[23:47:02] Starting 'inject:app'...
[23:47:02] gulp-inject 102 files into index.html.
[23:47:02] Finished 'inject:app' after 177 ms
[23:47:02] Starting 'inject:troubleshoot'...
[23:47:02] gulp-inject Nothing to inject into index.html.
[23:47:02] Finished 'inject:troubleshoot' after 3.57 ms
[23:47:02] Starting 'images'...
[23:47:02] Starting 'styles'...
[23:47:02] Starting 'html'...
[23:47:02] Starting 'copy:swagger'...
[23:47:02] Starting 'copy:images'...
[23:47:02] Finished 'copy:images' after 13 ms
[23:47:02] Finished 'styles' after 35 ms
[23:47:02] Finished 'html' after 294 ms
[23:47:02] Finished 'copy:swagger' after 315 ms
[23:47:03] gulp-imagemin: Minified 3 images (saved 0 B - 0%)
[23:47:03] Finished 'images' after 1.15 s
[23:47:03] Starting 'assets:prod'...
[23:47:17] Finished 'assets:prod' after 14 s
[23:47:17] Finished 'build' after 15 s
:processResources
:compileJava
:compileScala UP-TO-DATE
:generateGitProperties FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':generateGitProperties'.
> org.eclipse.jgit.errors.RepositoryNotFoundException: repository not found: /home/pgrimaud/projects/test/04-gradle

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

Total time: 38.141 secs
Related issues

Related to https://github.com/jhipster/generator-jhipster/pull/4018 As you coded this, @PierreBesson can you have a look plz ? Sorry, I didn't have a close look on what you did and what it is used for ^^

JHipster Version(s)
jhgradle@0.0.0 /home/pgrimaud/projects/test/04-gradle
└── generator-jhipster@3.6.1  -> /home/pgrimaud/projects/jhipster/generator-jhipster
JHipster configuration, a .yo-rc.json file generated in the root folder
{
  "generator-jhipster": {
    "jhipsterVersion": "3.6.1",
    "baseName": "jhgradle",
    "packageName": "io.github.pascalgrimaud",
    "packageFolder": "io/github/pascalgrimaud",
    "serverPort": "8080",
    "authenticationType": "session",
    "hibernateCache": "ehcache",
    "clusteredHttpSession": "no",
    "websocket": "no",
    "databaseType": "sql",
    "devDatabaseType": "h2Disk",
    "prodDatabaseType": "mysql",
    "searchEngine": "no",
    "buildTool": "gradle",
    "enableSocialSignIn": false,
    "rememberMeKey": "135923d8f42a1e4c812f3239502e23b1c00f7c50",
    "useSass": false,
    "applicationType": "monolith",
    "testFrameworks": [
      "gatling"
    ],
    "jhiPrefix": "jhi",
    "enableTranslation": true,
    "nativeLanguage": "en",
    "languages": [
      "en"
    ]
  }
}
Entity configuration(s) entityName.json files generated in the .jhipster directory

ls: no such file or directory: .jhipster/*.json

Browsers and Operating System

openjdk version "1.8.0_91" OpenJDK Runtime Environment (build 1.8.0_91-8u91-b14-3ubuntu1~16.04.1-b14) OpenJDK 64-Bit Server VM (build 25.91-b14, mixed mode)

git version 2.7.4

node: v4.5.0

npm: 3.10.6

bower: 1.7.9

gulp: [23:52:14] CLI version 1.2.2 [23:52:14] Local version 3.9.1

yeoman: 1.8.4

Docker version 1.12.1, build 23cf638

docker-compose version 1.8.0, build f3628c7

ruddell commented 8 years ago

This also happens on maven if you do git init and then try to build or run in production. This affects the yo jhipster:heroku subgenerator because it calls git init if a repository does not exist. It works fine as long as you don't have a git repository or have at least one commit in the repository. Error message is below:

[ERROR] Failed to execute goal pl.project13.maven:git-commit-id-plugin:2.2.1:revision (default) on project test-3: Could not complete Mojo execution... Error: Could not get HEAD Ref, are you sure you have some commits in the dotGitDirectory? -> [Help 1]

deepu105 commented 8 years ago

Is this related to the commit info endpoint change recently? Coz there was no such issue before?

Thanks & regards, Deepu

On 7 Sep 2016 04:36, "Jon Ruddell" notifications@github.com wrote:

This also happens on maven if you do git init and then try to build or run in production. This affects the yo jhipster:heroku subgenerator because it calls git init if a repository does not exist. It works fine as long as you don't have a git repository or have at least one commit in the repository. Error message is below:

[ERROR] Failed to execute goal pl.project13.maven:git-commit-id-plugin:2.2.1:revision (default) on project test-3: Could not complete Mojo execution... Error: Could not get HEAD Ref, are you sure you have some commits in the dotGitDirectory? -> [Help 1]

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/jhipster/generator-jhipster/issues/4087#issuecomment-245123603, or mute the thread https://github.com/notifications/unsubscribe-auth/ABDlF8tiPauUPWO7selxby4tR2vOYT8qks5qnfHggaJpZM4J2U-w .

pascalgrimaud commented 8 years ago

Exact @deepu105

jdubois commented 8 years ago

The good thing is that I'll be with the culprit @PierreBesson in 2 hours :-)

deepu105 commented 8 years ago

IMO we shouldn't make git repo mandatory for projects, but if its required then better we init one after generation in our install phase

Thanks & regards, Deepu

On 7 Sep 2016 11:12, "Julien Dubois" notifications@github.com wrote:

The good thing is that I'll be with the culprit @PierreBesson https://github.com/PierreBesson in 2 hours :-)

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/jhipster/generator-jhipster/issues/4087#issuecomment-245180852, or mute the thread https://github.com/notifications/unsubscribe-auth/ABDlFzZM5A3-SGotUuD24eCaNC0b4h2lks5qnk6vgaJpZM4J2U-w .

jdubois commented 8 years ago

No Git should not be mandatory. I have clients with this big entreprise IBM software called Jazz, which in fact is CVS :-)

PierreBesson commented 8 years ago

Agree, there is no question of forcing git onto people. I'm looking into the issue right now. [EDIT] A bit disappointed by https://github.com/n0mer/gradle-git-properties, only 15 stars and so little features, also fails when no git repo is present. We might better do our own custom task for gradle. It should take about 10 lines of code.

PierreBesson commented 8 years ago

The real issue is that ajoberstar/gradle-git has a bug that makes it fail when git is not initialized, see https://github.com/ajoberstar/gradle-git/issues/205 So for now we must remove this feature from the gradle build. Then we will add it back when the issue will be fixed in gradle-git. Also maybe we can write our own generateGitProperties task that uses gradle-git directly.

Really, the only problem is that GrgitPlugin.groovy doesn't catch errors when trying to open a git repo. Maybe we can submit a PR to fix it.

The more I work on this feature, the more I realize thats it's not trivial to set up (at least for gradle) and it will be useful for our users.

PierreBesson commented 8 years ago

Just noticed @ruddell comment, this is bad that it breaks the heroku subgen for maven also. So basically it is causing many problems right now. I think https://github.com/jhipster/generator-jhipster/commit/0ccf6e4d47bb6fc3a88ecc8ed3515030ec4c4d3e must be reverted completely. I will do the feature later and do more testing.

jdubois commented 8 years ago

Yes, can you revert it? Anyway as long as we don't have the UI for it, it's not a big issue.

jdubois commented 8 years ago

Closing as the PR is merged