12

Our Android project is dependent on some external projects over which we do not have control. Therefore I'm trying to setup custom lint.xml file so we can add ignore rules for them. As starting scenario I tried to remove warnings from ActionBarSherlock (no offence Jake)

<?xml version="1.0" encoding="UTF-8"?>
<lint>
  <issue id="FloatMath">
    <ignore path="app/target/classes/com/actionbarsherlock/*" />
  </issue>
  <issue id="DefaultLocale">
    <ignore path="app/target/classes/com/actionbarsherlock/*" />
  </issue>
  <issue id="ViewConstructor">
    <ignore path="app/target/classes/com/actionbarsherlock/*" />
  </issue>
</lint>

with following command in

lint app --disable FloatMath,DefaultLocale,ViewConstructor --xml lint-result.xml

However produced report still included messages from ABS.

Update I changed command to

lint --disable FloatMath,DefaultLocale,ViewConstructor --xml lint-result.xml app

Doesn't make any change for Jenkins still produce same report no matter what is in ignore, however if run in command line it does ignores all issues listed after disable. I wish that there was simple way to say, hey ignore/exclude things in sort of way Maven does...

peter_budo
  • 1,748
  • 4
  • 26
  • 48
  • I placed the `lint.xml` of your answer into the root of my project. No change though. Are you using `mvn android:lint` to run Lint or did you configure `maven-compiler-plugin` to execute Lint within the build process as [described here](http://blog.octo.com/en/add-lint-checks-to-android-maven-builds/)? Please add your configuration. – JJD Jul 09 '13 at 15:49
  • I'm invoking lint from shell on Jenkins as 'lint --config lint.xml --xml lint-result.xml.' or 'lint --config lint.xml' if you run it locally. This way you run android lint tool directly. I did not try it with android maven plugin, but I expect there must be a place in config to add exclusion lint file – peter_budo Jul 10 '13 at 15:50

3 Answers3

10

Now it's possible to do so:

<?xml version="1.0" encoding="UTF-8"?>
<lint>
    <issue id="all">
        <ignore regexp="target/classes/com/actionbarsherlock/.*[.]class" />
    </issue>
</lint>
alex.dorokhov
  • 1,218
  • 12
  • 17
8

Once again answering my own question... lint.xml looks now like this and it will ignore any ActionBarSherlock reports on ASB 4.2.0

<?xml version="1.0" encoding="UTF-8"?>
<lint>
  <issue id="NewApi">
    <ignore path="target/classes/com/actionbarsherlock/internal/ActionBarSherlockNative.class" />
    <ignore path="target/classes/com/actionbarsherlock/internal/ActionBarSherlockNative$ActionModeWrapper.class" />
    <ignore path="target/classes/com/actionbarsherlock/internal/app/ActionBarWrapper.class" />
    <ignore path="target/classes/com/actionbarsherlock/internal/app/ActionBarWrapper$TabWrapper.class" />
    <ignore path="target/classes/com/actionbarsherlock/internal/view/ActionProviderWrapper.class" />
    <ignore path="target/classes/com/actionbarsherlock/internal/view/menu/ActionMenuItemView.class" />
    <ignore path="target/classes/com/actionbarsherlock/internal/view/menu/MenuItemWrapper.class" />
    <ignore path="target/classes/com/actionbarsherlock/internal/view/menu/ActionMenuPresenter$HasPermanentMenuKey.class" />
    <ignore path="target/classes/com/actionbarsherlock/internal/widget/IcsAdapterView.class" />
    <ignore path="target/classes/com/actionbarsherlock/internal/widget/IcsProgressBar.class" />
    <ignore path="target/classes/com/actionbarsherlock/internal/widget/ActionBarView$HomeView.class" />
    <ignore path="target/classes/com/actionbarsherlock/widget/SearchView.class" />
    <ignore path="target/classes/com/actionbarsherlock/internal/nineoldandroids/widget/NineFrameLayout.class" />
    <ignore path="target/classes/com/actionbarsherlock/internal/nineoldandroids/widget/NineHorizontalScrollView.class" />
    <ignore path="target/classes/com/actionbarsherlock/internal/nineoldandroids/widget/NineLinearLayout.class" />
    <ignore path="target/classes/com/actionbarsherlock/internal/nineoldandroids/view/NineViewGroup.class" />
    <ignore path="target/classes/com/actionbarsherlock/internal/view/menu/BaseMenuPresenter.class" />
    <ignore path="target/classes/com/actionbarsherlock/internal/widget/AbsActionBarView.class" />
    <ignore path="target/classes/com/actionbarsherlock/internal/widget/ActionBarContextView.class" />
    <ignore path="target/classes/com/actionbarsherlock/internal/widget/ActionBarView.class" />
    <ignore path="target/classes/com/actionbarsherlock/internal/widget/CapitalizingButton.class" />
    <ignore path="target/classes/com/actionbarsherlock/internal/widget/CapitalizingTextView.class" />
    <ignore path="target/classes/com/actionbarsherlock/internal/widget/IcsAbsSpinner.class" />
    <ignore path="target/classes/com/actionbarsherlock/internal/widget/IcsLinearLayout.class" />
    <ignore path="target/classes/com/actionbarsherlock/internal/widget/IcsListPopupWindow.class" />
    <ignore path="target/classes/com/actionbarsherlock/internal/widget/ScrollingTabContainerView.class" />
    <ignore path="target/classes/com/actionbarsherlock/widget/ActivityChooserView$SetActivated.class" />
    <ignore path="target/classes/com/actionbarsherlock/app/SherlockActivity.class" />
    <ignore path="target/classes/com/actionbarsherlock/app/SherlockExpandableListActivity.class" />
    <ignore path="target/classes/com/actionbarsherlock/app/SherlockListActivity.class" />
    <ignore path="target/classes/com/actionbarsherlock/app/SherlockPreferenceActivity.class" />
    <ignore path="target/classes/com/actionbarsherlock/internal/ActionBarSherlockNative$ActionModeCallbackWrapper.class" />
    <ignore path="target/classes/com/actionbarsherlock/internal/app/ActionBarImpl$1.class" />
    <ignore path="target/classes/com/actionbarsherlock/internal/app/ActionBarImpl.class" />
  </issue>

  <issue id="FloatMath">
    <ignore path="target/classes/com/actionbarsherlock/internal/nineoldandroids/view/animation/AnimatorProxy.class" />
  </issue>

  <issue id="DefaultLocale">
    <ignore path="target/classes/com/actionbarsherlock/internal/widget/CapitalizingTextView.class" />
    <ignore path="target/classes/com/actionbarsherlock/internal/widget/CapitalizingButton.class" />
  </issue>

  <issue id="ViewConstructor">
    <ignore path="target/classes/com/actionbarsherlock/internal/widget/CollapsibleActionViewWrapper.class" />
  </issue>

  <issue id="WrongCall">
    <ignore path="target/classes/com/actionbarsherlock/internal/widget/IcsAdapterView.class" />
  </issue>
</lint>

Shell execution command that we now use is

lint --config lint.xml --xml lint-results.xml .;

PS: Please be aware that this will not remove all reports of excluded APKLIB like in this case ABS as so far there is no way to exclude reports to unused resources of R.class. On compile process R.class of linked library and your project do get merged and Lint has no way to know this. It does only see single R.class with some references that are not used and reports them.

peter_budo
  • 1,748
  • 4
  • 26
  • 48
  • Snicolas I do agree, Google need to polish it more because listing all the classes for project "add-on" libraries is just mad house. Secondly that doesn't solve problem of R.class reports of unused resource that was brought over by the library – peter_budo Feb 25 '13 at 14:36
1

I've completed the lint.xml file to exclude more actionbarsherlock errors. However, it would be nice to have an exclude package mechanism.

<?xml version="1.0" encoding="UTF-8"?>
<lint>
  <issue id="NewApi">
    <ignore path="target/classes/com/actionbarsherlock/internal/ActionBarSherlockNative.class"/>
    <ignore path="target/classes/com/actionbarsherlock/internal/ActionBarSherlockNative$ActionModeWrapper.class"/>
    <ignore path="target/classes/com/actionbarsherlock/internal/app/ActionBarWrapper.class"/>
    <ignore path="target/classes/com/actionbarsherlock/internal/app/ActionBarWrapper$TabWrapper.class"/>
    <ignore path="target/classes/com/actionbarsherlock/internal/view/ActionProviderWrapper.class"/>
    <ignore path="target/classes/com/actionbarsherlock/internal/view/menu/ActionMenuItemView.class"/>
    <ignore path="target/classes/com/actionbarsherlock/internal/view/menu/MenuItemWrapper.class"/>
    <ignore path="target/classes/com/actionbarsherlock/internal/view/menu/ActionMenuPresenter$HasPermanentMenuKey.class"/>
    <ignore path="target/classes/com/actionbarsherlock/internal/widget/IcsAdapterView.class"/>
    <ignore path="target/classes/com/actionbarsherlock/internal/widget/IcsProgressBar.class"/>
    <ignore path="target/classes/com/actionbarsherlock/internal/widget/ActionBarView$HomeView.class"/>
    <ignore path="target/classes/com/actionbarsherlock/widget/SearchView.class"/>
    <ignore path="target/classes/com/actionbarsherlock/internal/widget/AbsActionBarView.class"/>
    <ignore path="target/classes/com/actionbarsherlock/internal/widget/ActionBarContextView.class"/>
    <ignore path="target/classes/com/actionbarsherlock/internal/app/ActionBarImpl$1.class"/>
    <ignore path="target/classes/com/actionbarsherlock/internal/app/ActionBarImpl.class"/>
    <ignore path="target/classes/com/actionbarsherlock/internal/ActionBarSherlockNative$ActionModeCallbackWrapper.class"/>
    <ignore path="target/classes/com/actionbarsherlock/internal/widget/ActionBarView.class"/>
    <ignore path="target/classes/com/actionbarsherlock/widget/ActivityChooserView$SetActivated.class"/>
    <ignore path="target/classes/com/actionbarsherlock/internal/view/menu/BaseMenuPresenter.class"/>
    <ignore path="target/classes/com/actionbarsherlock/internal/widget/CapitalizingButton.class"/>
    <ignore path="target/classes/com/actionbarsherlock/internal/widget/CapitalizingTextView.class"/>
    <ignore path="target/classes/com/actionbarsherlock/internal/widget/IcsAbsSpinner.class"/>
    <ignore path="target/classes/com/actionbarsherlock/internal/widget/IcsLinearLayout.class"/>
    <ignore path="target/classes/com/actionbarsherlock/internal/widget/IcsListPopupWindow.class"/>
    <ignore path="target/classes/com/actionbarsherlock/internal/nineoldandroids/widget/NineHorizontalScrollView.class"/>
    <ignore path="target/classes/com/actionbarsherlock/internal/nineoldandroids/widget/NineLinearLayout.class"/>
    <ignore path="target/classes/com/actionbarsherlock/internal/nineoldandroids/view/NineViewGroup.class"/>
    <ignore path="target/classes/com/actionbarsherlock/internal/widget/ScrollingTabContainerView.class"/>
    <ignore path="target/classes/com/actionbarsherlock/app/SherlockActivity.class"/>
    <ignore path="target/classes/com/actionbarsherlock/app/SherlockExpandableListActivity.class"/>
    <ignore path="target/classes/com/actionbarsherlock/app/SherlockListActivity.class"/>
    <ignore path="target/classes/com/actionbarsherlock/app/SherlockPreferenceActivity.class"/>
    <ignore path="target/classes/com/actionbarsherlock/internal/nineoldandroids/widget/NineFrameLayout.class"/>
    <ignore path="target/classes/com/viewpagerindicator/IcsLinearLayout.class"/>
</issue>

<issue id="FloatMath">
    <ignore path="target/classes/com/actionbarsherlock/internal/nineoldandroids/view/animation/AnimatorProxy.class"/>
</issue>

<issue id="DefaultLocale">
    <ignore path="target/classes/com/actionbarsherlock/internal/widget/CapitalizingTextView.class"/>
    <ignore path="target/classes/com/actionbarsherlock/internal/widget/CapitalizingButton.class"/>
</issue>

<issue id="ViewConstructor">
    <ignore path="target/classes/com/actionbarsherlock/internal/widget/CollapsibleActionViewWrapper.class"/>
</issue>
</lint>
Jerome VDL
  • 3,376
  • 4
  • 32
  • 33
  • as I said, this does only takes care of classes. If you check lint result report you will find there plenty of unused resources linked to R class – peter_budo Feb 26 '13 at 11:40