-
-
Notifications
You must be signed in to change notification settings - Fork 20
feat(maven): Remove Gradle properties after publishing #276
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
Changes from all commits
becb8c0
b99e4cb
7e9d201
f1e6423
296336b
3d2d859
4366a66
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,7 +6,7 @@ import { | |
| import { BaseTarget } from './base'; | ||
| import { homedir } from 'os'; | ||
| import { basename, extname, join, parse } from 'path'; | ||
| import { constants as fsConstants, promises as fsPromises } from 'fs'; | ||
| import { promises as fsPromises } from 'fs'; | ||
| import { checkExecutableIsPresent, extractZipArchive } from '../utils/system'; | ||
| import { retrySpawnProcess } from '../utils/async'; | ||
| import { withTempDir } from '../utils/files'; | ||
|
|
@@ -23,7 +23,7 @@ const GRADLE_PROPERTIES_FILENAME = 'gradle.properties'; | |
| const DEFAULT_GRADLE_USER_HOME = join(homedir(), '.gradle'); | ||
| export const POM_DEFAULT_FILENAME = 'pom-default.xml'; | ||
| const POM_FILE_EXT = '.xml'; // Must include the leading `.` | ||
| const BOM_FILE_KEY_REGEXP = stringToRegexp('/<packaging>pom</packaging>/'); | ||
| const BOM_FILE_KEY_REGEXP = new RegExp('<packaging>pom</packaging>'); | ||
|
|
||
| export const targetSecrets = ['OSSRH_USERNAME', 'OSSRH_PASSWORD'] as const; | ||
| type SecretsType = typeof targetSecrets[number]; | ||
|
|
@@ -186,6 +186,7 @@ export class MavenTarget extends BaseTarget { | |
| await retrySpawnProcess(this.mavenConfig.gradleCliPath, [ | ||
| 'closeAndReleaseRepository', | ||
| ]); | ||
| await this.deleteUserGradlePropsFile(); | ||
| } | ||
|
|
||
| /** | ||
|
|
@@ -205,6 +206,15 @@ export class MavenTarget extends BaseTarget { | |
| ); | ||
| } | ||
|
|
||
| /** | ||
| * Deletes the user's `gradle.properties` file. | ||
| */ | ||
| public deleteUserGradlePropsFile(): Promise<void> { | ||
| return fsPromises.unlink( | ||
| join(this.getGradleHomeDir(), GRADLE_PROPERTIES_FILENAME) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Who creates this file? If it is the
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's created by the target itself (by the method right above it)
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Then at this point, I'd convert this into something like |
||
| ); | ||
| } | ||
|
|
||
| /** | ||
| * Retrieves the Gradle Home path. | ||
| * | ||
|
|
@@ -292,17 +302,10 @@ export class MavenTarget extends BaseTarget { | |
| // the BOM renamed in such a way that isn't handled by the target. | ||
| const filesInDir = await fsPromises.readdir(distDir); | ||
| const potentialPoms = filesInDir | ||
| .filter(f => extname(f) === POM_FILE_EXT) | ||
| .filter(f => f !== POM_DEFAULT_FILENAME) | ||
| .filter(f => f !== POM_DEFAULT_FILENAME && extname(f) === POM_FILE_EXT) | ||
| .map(f => join(distDir, f)); | ||
|
|
||
| for (const f of potentialPoms) { | ||
| if (await this.isBomFile(f)) { | ||
| return f; | ||
| } | ||
| } | ||
|
|
||
| return undefined; | ||
| return potentialPoms.find(f => this.isBomFile(f)); | ||
| } | ||
|
|
||
| /** | ||
|
|
@@ -316,7 +319,6 @@ export class MavenTarget extends BaseTarget { | |
| */ | ||
| public async isBomFile(pomFilepath: string): Promise<boolean> { | ||
| try { | ||
| await fsPromises.access(pomFilepath, fsConstants.R_OK); | ||
| const fileContents = await fsPromises.readFile(pomFilepath, { | ||
| encoding: 'utf8', | ||
| }); | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.