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

Allows Customizing Project Location on Gradle Wrapper #73

Merged

Conversation

andreban
Copy link
Member

@JudahGabriel drafted this to enable customizing the Gradle Wrapper.

Copy link
Contributor

@JudahGabriel JudahGabriel left a comment

Choose a reason for hiding this comment

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

Running this code locally, I get a different exception:

FAILURE: Build failed with an exception. 
* What went wrong:
Task 'assembleRelease' not found in root project 'pwabuilder-llamapack'

In other words, even though we've specified the path to gradlew.bat, it's still looking in the process' current directory for the assembleRelease task.

I'll follow up here when I find out the additional changes needed. Perhaps I can submit a PR for it.

@JudahGabriel
Copy link
Contributor

JudahGabriel commented Jan 16, 2020

OK, I think the issue is we should instead be setting the current directory of the node child process.

I think the final code would look like this:

class GradleWrapper {
  constructor(process, androidSdkTools, gradleDirectory) {
    this.process = process;
    this.gradleDirectory = gradleDirectory;
    this.androidSdkTools = androidSdkTools;
    if (process.platform === 'win32') {
      this.gradleCmd = 'gradlew.bat';
    } else {
      this.gradleCmd = './gradlew';
    }
  }

  async assembleRelease() {
    const env = this.androidSdkTools.getEnv();
    await exec(`${this.gradleCmd} assembleRelease --stacktrace`, {
      env: env,
      cwd: this.gradleDirectory
    });
  }

I'll test this first and follow up shortly with the results.

Copy link
Contributor

@JudahGabriel JudahGabriel left a comment

Choose a reason for hiding this comment

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

Instead of appending the directory to the gradle file, we only need to set the working directory option on the child process:

await exec(`${this.gradleCmd} assembleRelease --stacktrace`, {
   env: androidSdkTools.getEnv(),
   cwd: gradleDirectory // set the current directory for the child process
});

Once we do that, everything works. 😎

@andreban
Copy link
Member Author

Ha! Sounds like I was overcomplicating things. Thanks for checking this out. I'll update the PR.

@andreban andreban marked this pull request as ready for review January 17, 2020 18:32
@andreban
Copy link
Member Author

@JudahGabriel does this sound good?

Copy link
Contributor

@JudahGabriel JudahGabriel left a comment

Choose a reason for hiding this comment

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

Looks great! 😎

@andreban andreban merged commit 1a48dc2 into GoogleChromeLabs:master Jan 17, 2020
@andreban andreban deleted the custom-location-gradlewrapper branch February 13, 2020 08:14
@andreban andreban added the enhancement New feature or request label Mar 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants