-
Notifications
You must be signed in to change notification settings - Fork 169
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Adds support for generating `lint_*` `genrule`s for `android_library` targets - Hooks are in place to let lint rules be generated for any jvm library targets. Theoretically lint can be run on java, kotlin or scala etc with some small tweaks. Lint can also be run on test sources with a few small tweaks as well. These changes will be part of a subsequent PR - Supports custom lint jars embedded in aars - Supports custom lint project/external dependencies. For example, a java library that defines custom lint rules can be added to another library as a linter by making it a dependency of the `buckLint` configuration - Fully incremental, parallel and buck cache/network cache friendly - Supports many android dsl options specified in `lintOptions` - Ability to pin lint api version and not be surprised when android gradle plugin pulls in new checks on updates - Requires an updated `buckw` by running the `buckWrapper` to watch for changes to `lint.xml` files and run `okbuck` again as needed - Lint on all android rules can be run like `buck query "filter('lint_*', kind('genrule', '//...'))" | xargs buck build`
- Loading branch information
Showing
37 changed files
with
567 additions
and
45 deletions.
There are no files selected for viewing
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 |
---|---|---|
|
@@ -24,6 +24,10 @@ android { | |
|
||
test.setRoot('test') | ||
} | ||
|
||
lintOptions { | ||
disable 'HardcodedDebugMode' | ||
} | ||
} | ||
|
||
dependencies { | ||
|
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
1 change: 0 additions & 1 deletion
1
buildSrc/src/main/groovy/com/uber/okbuck/composer/AndroidLibraryRuleComposer.groovy
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
1 change: 0 additions & 1 deletion
1
buildSrc/src/main/groovy/com/uber/okbuck/composer/AndroidTestRuleComposer.groovy
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
1 change: 0 additions & 1 deletion
1
...dSrc/src/main/groovy/com/uber/okbuck/composer/ExopackageAndroidLibraryRuleComposer.groovy
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
1 change: 0 additions & 1 deletion
1
buildSrc/src/main/groovy/com/uber/okbuck/composer/JavaLibraryRuleComposer.groovy
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
1 change: 0 additions & 1 deletion
1
buildSrc/src/main/groovy/com/uber/okbuck/composer/JavaTestRuleComposer.groovy
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
45 changes: 45 additions & 0 deletions
45
buildSrc/src/main/groovy/com/uber/okbuck/composer/LintRuleComposer.groovy
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,45 @@ | ||
package com.uber.okbuck.composer | ||
|
||
import com.uber.okbuck.core.model.JavaTarget | ||
import com.uber.okbuck.core.model.Target | ||
import com.uber.okbuck.core.util.LintUtil | ||
import com.uber.okbuck.extension.LintExtension | ||
import com.uber.okbuck.generator.LintWrapperGenerator | ||
import com.uber.okbuck.rule.LintRule | ||
|
||
final class LintRuleComposer extends JavaBuckRuleComposer { | ||
|
||
private LintRuleComposer() { | ||
// no instance | ||
} | ||
|
||
static LintRule compose(JavaTarget target) { | ||
Set<String> inputs = [] | ||
if (target.lintOptions.lintConfig != null && target.lintOptions.lintConfig.exists()) { | ||
inputs.add(LintUtil.getLintwConfigRule(target.project, target.lintOptions.lintConfig)) | ||
} | ||
|
||
LintExtension lintExtension = target.rootProject.okbuck.lint | ||
LintWrapperGenerator.generate(target, lintExtension.jvmArgs) | ||
|
||
Set<String> customLintTargets = [] as Set | ||
Set<Target> lintJarTargets = target.lint.targetDeps.findAll { | ||
(it instanceof JavaTarget) && (it.hasLintRegistry()) | ||
} | ||
|
||
customLintTargets.addAll(targets(lintJarTargets)) | ||
customLintTargets.addAll(external(target.main.packagedLintJars)) | ||
|
||
Set<String> lintDeps = [] as Set | ||
lintDeps.addAll(LintUtil.LINT_DEPS_RULE) | ||
lintDeps.addAll(targets(lintJarTargets)) | ||
|
||
return new LintRule( | ||
lint(target), | ||
inputs, | ||
LintUtil.getLintwRule(target), | ||
customLintTargets, | ||
lintDeps, | ||
target.main.sources.empty ? null : ":${src(target)}") | ||
} | ||
} |
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
8 changes: 8 additions & 0 deletions
8
buildSrc/src/main/groovy/com/uber/okbuck/core/dependency/InValidDependencyException.groovy
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,8 @@ | ||
package com.uber.okbuck.core.dependency | ||
|
||
class InValidDependencyException extends IllegalStateException { | ||
|
||
InValidDependencyException(String msg) { | ||
super(msg) | ||
} | ||
} |
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
Oops, something went wrong.