Skip to content

fix(gradle): fix gradle tests #30879

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
108 changes: 57 additions & 51 deletions e2e/gradle/src/gradle-import.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { join } from 'path';
import { createGradleProject } from './utils/create-gradle-project';
import { createFileSync } from 'fs-extra';

xdescribe('Nx Import Gradle', () => {
describe('Nx Import Gradle', () => {
const tempImportE2ERoot = join(e2eCwd, 'nx-import');
beforeAll(() => {
newProject({
Expand Down Expand Up @@ -72,31 +72,34 @@ xdescribe('Nx Import Gradle', () => {
const source = '.';
const directory = 'projects/gradle-app-kotlin';

runCLI(
`import ${remote} ${directory} --ref ${ref} --source ${source} --no-interactive`,
{
verbose: true,
}
);

checkFilesExist(
`${directory}/settings.gradle.kts`,
`${directory}/build.gradle.kts`,
`${directory}/gradlew`,
`${directory}/gradlew.bat`
);
const nxJson = readJson('nx.json');
const gradlePlugin = nxJson.plugins.find(
(plugin) => plugin.plugin === '@nx/gradle'
);
expect(gradlePlugin).toBeDefined();
expect(() => {
runCLI(`show projects`);
runCLI('build kotlin-app');
}).not.toThrow();
try {
runCLI(
`import ${remote} ${directory} --ref ${ref} --source ${source} --no-interactive`,
{
verbose: true,
}
);

runCommand(`git add .`);
runCommand(`git commit -am 'import kotlin project'`);
checkFilesExist(
`${directory}/settings.gradle.kts`,
`${directory}/build.gradle.kts`,
`${directory}/gradlew`,
`${directory}/gradlew.bat`
);
const nxJson = readJson('nx.json');
const gradlePlugin = nxJson.plugins.find(
(plugin) => plugin.plugin === '@nx/gradle'
);
expect(gradlePlugin).toBeDefined();
expect(() => {
runCLI(`show projects`);
runCLI('build kotlin-app');
}).not.toThrow();
} finally {
// Cleanup
runCommand(`git add .`);
runCommand(`git commit -am 'import kotlin project'`);
}
});

it('should be able to import a groovy gradle app', () => {
Expand All @@ -123,33 +126,36 @@ xdescribe('Nx Import Gradle', () => {
const source = '.';
const directory = 'projects/gradle-app-groovy';

runCLI(
`import ${remote} ${directory} --ref ${ref} --source ${source} --no-interactive`,
{
verbose: true,
}
);
runCLI(`g @nx/gradle:init --no-interactive`);

checkFilesExist(
`${directory}/build.gradle`,
`${directory}/settings.gradle`,
`${directory}/gradlew`,
`${directory}/gradlew.bat`
);
const nxJson = readJson('nx.json');
const gradlePlugin = nxJson.plugins.find(
(plugin) => plugin.plugin === '@nx/gradle'
);
gradlePlugin.exclude = [];
updateJson('nx.json', () => nxJson);
expect(() => {
runCLI(`show projects`);
runCLI('build groovy-app');
}).not.toThrow();
try {
runCLI(
`import ${remote} ${directory} --ref ${ref} --source ${source} --no-interactive`,
{
verbose: true,
}
);
runCLI(`g @nx/gradle:init --no-interactive`);

runCommand(`git add .`);
runCommand(`git commit -am 'import groovy project'`);
checkFilesExist(
`${directory}/build.gradle`,
`${directory}/settings.gradle`,
`${directory}/gradlew`,
`${directory}/gradlew.bat`
);
const nxJson = readJson('nx.json');
const gradlePlugin = nxJson.plugins.find(
(plugin) => plugin.plugin === '@nx/gradle'
);
gradlePlugin.exclude = [];
updateJson('nx.json', () => nxJson);
expect(() => {
runCLI(`show projects`);
runCLI('build groovy-app');
}).not.toThrow();
} finally {
// Cleanup
runCommand(`git add .`);
runCommand(`git commit -am 'import groovy project'`);
}
});
});

Expand Down
2 changes: 1 addition & 1 deletion e2e/gradle/src/gradle.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ describe('Gradle', () => {
expect(buildOutput).toContain(':utilities:classes');
});

xit('should track dependencies for new app', () => {
it('should track dependencies for new app', () => {
if (type === 'groovy') {
createFile(
`app2/build.gradle`,
Expand Down
2 changes: 1 addition & 1 deletion e2e/gradle/src/utils/create-gradle-project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export function createGradleProject(

e2eConsoleLogger(
execSync(
`${gradleCommand} :project-graph:publishToMavenLocal -x :project-graph:signNxProjectGraphPluginPluginMarkerMavenPublication -x :project-graph:signPluginMavenPublication -x :project-graph:publishNxProjectGraphPluginPluginMarkerMavenPublicationToMavenLocal -x :project-graph:publishPluginMavenPublicationToMavenLocal`,
`${gradleCommand} :project-graph:publishToMavenLocal -PskipSign=true`,
{
cwd: `${__dirname}/../../../..`,
}
Expand Down
14 changes: 9 additions & 5 deletions packages/gradle/project-graph/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -108,13 +108,17 @@ afterEvaluate {
}
}
}
}

signing {
afterEvaluate {
sign(publishing.publications["pluginMaven"])
sign(publishing.publications["nxProjectGraphPluginPluginMarkerMaven"])
val skipSign = project.findProperty("skipSign") == "true"
if (!skipSign) {
signing {
sign(publishing.publications["pluginMaven"])
sign(publishing.publications["nxProjectGraphPluginPluginMarkerMaven"])
}
}

// Even if signing plugin was applied, we can prevent the sign tasks from running
tasks.withType<Sign>().configureEach { onlyIf { !skipSign } }
}

tasks.test { useJUnitPlatform() }
Expand Down