Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
204 views
in Technique[技术] by (71.8m points)

Run lint when building android studio projects

I would like to be able to run the lint task when I'm building projects with the android studio to ensure the lint rules are being followed.

I have tried using task dependencies but with no luck. My TeamCity build server uses the build task which runs the lint task so that works great. However, the android studio appears to use generateDebugSources and compileDebugJava tasks interchangeably when I have selected the debug build variant.

Here is what I have tried in my build.gradle:

assemble.dependsOn lint
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

If you just want to configure your Android Studio project to run the lint check before the default run configuration without affecting how your gradle tasks are configured, you can follow these steps.

  1. Open the run configurations drop down and choose edit

enter image description here

  1. Select your app run configuration

enter image description here

  1. Press the '+' to add a new step

enter image description here

  1. Choose "Gradle-aware Make"

enter image description here

  1. Type 'check' and choose the option with your app module name and check. (Mine is :app:check)

enter image description here

  1. Press the up arrow to move the new check step before the existing Gradle-aware make step

enter image description here

Now, Android Studio will run the lint check and fail the build if any lint errors occur.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...