-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(gradle): add gradle kotlin plugin
- Loading branch information
Showing
74 changed files
with
6,372 additions
and
1,109 deletions.
There are no files selected for viewing
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -62,3 +62,7 @@ target | |
/wasi-sdk* | ||
|
||
vite.config.*.timestamp* | ||
|
||
# Ignore Gradle project-specific cache directory | ||
.gradle | ||
.kotlin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
plugins { | ||
id("dev.nx.gradle.native") version("+") | ||
} | ||
|
||
group = "dev.nx.gradle" | ||
|
||
allprojects { | ||
apply { | ||
plugin("project-report") | ||
plugin("dev.nx.gradle.native") | ||
} | ||
} | ||
|
||
tasks.register("projectReportAll") { | ||
// All project reports of subprojects | ||
allprojects.forEach { | ||
dependsOn(it.tasks.get("projectReport")) | ||
} | ||
|
||
// All projectReportAll of included builds | ||
gradle.includedBuilds.forEach { | ||
dependsOn(it.task(":projectReportAll")) | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
import { | ||
checkFilesExist, | ||
cleanupProject, | ||
createFile, | ||
newProject, | ||
runCLI, | ||
uniq, | ||
updateFile, | ||
updateJson, | ||
} from '@nx/e2e/utils'; | ||
|
||
import { createGradleProject } from './utils/create-gradle-project'; | ||
import { updateProjectFiles } from 'nx/src/utils/workspace-context'; | ||
|
||
describe('Gradle Plugin V1', () => { | ||
describe.each([{ type: 'kotlin' }, { type: 'groovy' }])( | ||
'$type', | ||
({ type }: { type: 'kotlin' | 'groovy' }) => { | ||
let gradleProjectName = uniq('my-gradle-project'); | ||
beforeAll(() => { | ||
newProject(); | ||
createGradleProject(gradleProjectName, type); | ||
runCLI(`add @nx/gradle`); | ||
updateJson('nx.json', (json) => { | ||
json.plugins.find((p) => p.plugin === '@nx/gradle').plugin = | ||
'@nx/gradle-plugin-v1'; | ||
return json; | ||
}); | ||
}); | ||
afterAll(() => cleanupProject()); | ||
|
||
it('should build', () => { | ||
const projects = runCLI(`show projects`); | ||
expect(projects).toContain('app'); | ||
expect(projects).toContain('list'); | ||
expect(projects).toContain('utilities'); | ||
expect(projects).toContain(gradleProjectName); | ||
|
||
const buildOutput = runCLI('build app', { verbose: true }); | ||
expect(buildOutput).toContain('nx run list:'); | ||
expect(buildOutput).toContain(':list:classes'); | ||
expect(buildOutput).toContain('nx run utilities:'); | ||
expect(buildOutput).toContain(':utilities:classes'); | ||
|
||
checkFilesExist( | ||
`app/build/libs/app.jar`, | ||
`list/build/libs/list.jar`, | ||
`utilities/build/libs/utilities.jar` | ||
); | ||
}); | ||
|
||
it('should track dependencies for new app', () => { | ||
if (type === 'groovy') { | ||
createFile( | ||
`app2/build.gradle`, | ||
`plugins { | ||
id 'buildlogic.groovy-application-conventions' | ||
} | ||
dependencies { | ||
implementation project(':app') | ||
}` | ||
); | ||
} else { | ||
createFile( | ||
`app2/build.gradle.kts`, | ||
`plugins { | ||
id("buildlogic.kotlin-application-conventions") | ||
} | ||
dependencies { | ||
implementation(project(":app")) | ||
}` | ||
); | ||
updateFile(`app/build.gradle.kts`, (content) => { | ||
content += `\r\ntasks.register("task1"){ | ||
println("REGISTER TASK1: This is executed during the configuration phase") | ||
}`; | ||
return content; | ||
}); | ||
} | ||
updateFile( | ||
`settings.gradle${type === 'kotlin' ? '.kts' : ''}`, | ||
(content) => { | ||
content += `\r\ninclude("app2")`; | ||
return content; | ||
} | ||
); | ||
|
||
let buildOutput = runCLI('build app2', { verbose: true }); | ||
// app2 depends on app | ||
expect(buildOutput).toContain('nx run app:'); | ||
expect(buildOutput).toContain(':app:classes'); | ||
expect(buildOutput).toContain('nx run list:'); | ||
expect(buildOutput).toContain(':list:classes'); | ||
expect(buildOutput).toContain('nx run utilities:'); | ||
expect(buildOutput).toContain(':utilities:classes'); | ||
|
||
checkFilesExist(`app2/build/libs/app2.jar`); | ||
}); | ||
|
||
it('should run atomized test target', () => { | ||
updateJson('nx.json', (json) => { | ||
json.plugins.find((p) => p.plugin === '@nx/gradle').options[ | ||
'ciTargetName' | ||
] = 'test-ci'; | ||
return json; | ||
}); | ||
|
||
expect(() => { | ||
runCLI('run app:test-ci--MessageUtilsTest', { verbose: true }); | ||
runCLI('run list:test-ci--LinkedListTest', { verbose: true }); | ||
}).not.toThrow(); | ||
}); | ||
} | ||
); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# This file was generated by the Gradle 'init' task. | ||
# https://docs.gradle.org/current/userguide/platforms.html#sub::toml-dependencies-format | ||
|
||
[plugins] | ||
jvm = { id = "org.jetbrains.kotlin.jvm", version = "1.9.20" } | ||
|
||
[versions] | ||
kotlin-gradle-plugin = "2.0.21" | ||
|
||
[libraries] | ||
kotlin-gradle-plugin = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "kotlin-gradle-plugin" } |
Binary file renamed
BIN
+42.4 KB
e2e/gradle/gradle/wrapper/gradle-wrapper.jar → gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
5 changes: 3 additions & 2 deletions
5
.../gradle/wrapper/gradle-wrapper.properties → gradle/wrapper/gradle-wrapper.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip | ||
validateDistributionUrl=false | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.12-bin.zip | ||
networkTimeout=10000 | ||
validateDistributionUrl=true | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Ignore Gradle project-specific cache directory | ||
bin | ||
build |
Oops, something went wrong.