Skip to content

Commit

Permalink
Merge pull request #2 from Zedorff/feature/swift-lint-task
Browse files Browse the repository at this point in the history
Add SwiftLint task
  • Loading branch information
andriydruk authored Jul 28, 2022
2 parents 5d32675 + f813956 commit 5b507a7
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ ext {
// Provide your own coordinates here
PUBLISH_GROUP_ID = 'com.readdle.android.swift'
PUBLISH_ARTIFACT_ID = 'gradle'
PUBLISH_VERSION = '1.4.1'
PUBLISH_VERSION = '1.4.2'
}

apply from: "${rootProject.projectDir}/publish-module.gradle"
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ class SwiftAndroidPlugin implements Plugin<Project> {
project.afterEvaluate {
installToolsTask = createInstallSwiftToolsTask(project)

if (extension.swiftLintEnabled) {
installToolsTask.dependsOn(createSwiftLintTask(project))
}

createSwiftUpdateTask(project)

Task swiftClean = createCleanTask(project, extension.usePackageClean)
Expand Down Expand Up @@ -281,6 +285,24 @@ class SwiftAndroidPlugin implements Plugin<Project> {
}
}

private static Task createSwiftLintTask(Project project) {
return project.task(type: Exec, "swiftLint") {
workingDir "src/main/swift"
commandLine "swiftlint", "--strict", "--reporter", "xcode"

ignoreExitValue = true
errorOutput = new ByteArrayOutputStream()
standardOutput = new ByteArrayOutputStream()

doLast {
def output = standardOutput.toString()
if (!output.empty) {
throw new GradleException(output)
}
}
}
}

private static Path generatedSourcesPath(Project project, ApplicationVariant variant) {
def extension = project.extensions.getByType(SwiftAndroidPluginExtension)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ class SwiftAndroidPluginExtension {

boolean cleanEnabled = true
boolean usePackageClean = true
boolean swiftLintEnabled = false
boolean useKapt = false

SwiftAndroidPluginExtension(Project project) {
Expand Down

0 comments on commit 5b507a7

Please sign in to comment.