Warning about an Android Library project gradle dependencies

时间:2015-05-12 22:46:24

标签: android android-studio gradle android-gradle build.gradle

I am building an Android Library project using Android Studio. The type of the module is 'com.android.library' in gradle.build file. This module has a number of dependencies:

$(document).ready(function(){ 
    $(".tooltipper").click(function(){
        if ($(this).attr('id')==='mepkin'){
            $("#map-img").animate({top: '-47.8%', left: '-10.8%'});   
        }else if ($(this).attr('id')==='biggins'){
            $("#map-img").animate({top: '3.07%', left: '3.70%'});   

    });
    $("#getalertbutton").click(function(){
        var position = $('#map-img').position();
        var percentLeft = position.left/$(window).width() * 100;
        var percentTop = position.top/$(window).height() *100;
        alert("top: "+percentTop+"   "+"left: "+percentLeft);
    }
});

The module builds result in a .aar file. I want the user of the .aar file to be notified/warned about .aar dependencies so his project doesn't successfully builds till these dependencies are set inside his project. Is there a way to do this?

1 个答案:

答案 0 :(得分:1)

  

我希望.aar文件的用户能够收到关于.aar依赖关系的通知/警告,这样他的项目就不会成功构建,直到在他的项目中设置这些依赖关系。

嗯,在某种程度上,这会自动发生,因为他们的编译会失败。

如果将此AAR作为工件存储在存储库中,则存储库元数据(例如,Maven存储库的POM文件)可以包含有关这些依赖关系的信息。许多构建系统(Gradle,Maven等)将使用它来在开发人员使用您的工件时根据需要自动下载这些依赖项。

如果您选择通过其他方式分发此AAR(例如,一个小山的大小的QR码),您将需要告诉开发人员他们需要通过某种文档包含这些依赖项。

预测后续问题......

  

我应该能够通过Maven仓库发布.aar闭源工件吗?

不确定。虽然Maven Central和JCenter是针对开源量身定制的,但您当然可以拥有自己的回购。它只是一个包含特定内容的目录。例如,我有自己的开源库repo,虽然我的库是开源的,但是没有关于需要存储库来保存开源代码的repo。