简体   繁体   English

从本地磁盘添加Maven存储库

[英]Adding Maven repository from local disk

I want to use an external folder as a library. 我想将外部文件夹用作库。 That folder(mvnLib) has maven-metadata-local.xml and a .pom and a .aar files in it and documentation says I can use it like this: 该文件夹(mvnLib)中包含maven-metadata-local.xml以及.pom.aar文件,文档说明我可以这样使用它:

allprojects { 
  repositories {
​     maven {
      url "../mvnLib"
     }
  } 
}

But id doesnt work and I get this error: 但是id不起作用,并且出现此错误:

Could not find method ​implementation() for arguments [com.app.two:plib:1.3.2] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.

I cant find this type of Maven repository documentation. 我找不到这种类型的Maven存储库文档。 Can I use a Maven repository on disk? 我可以在磁盘上使用Maven存储库吗? Is this correct? 这个对吗? Why Im getting this error? 为什么我收到此错误? Is there a automatic procedure to adding libraries like this to lower error rate? 是否有自动程序来添加这样的库以降低错误率?

Update: 更新:

mvnLib folder structure is: mvnLib文件夹结构为:

[Project Root]
.gradle
app
mvnLib
   com
     app
        two
           plib
              1.3.2
                   prlib-1.3.2.pom
                   prlib-1.3.2.aar
              maven-metadata-local.xml

Documentation says put the mvnLib in the root of project. 文档说将mvnLib放在项目的根目录中。 then on the project level build.gradle: 然后在项目级别build.gradle:

allprojects { 
  repositories {
​     maven {
      url "../mvnLib"
     }
  } 
}

Then on the app level build.gradle: 然后在应用程序级别build.gradle:

implementation 'com.app.two:plib:1.3.2'

I do all of these but i get that error. 我做了所有这些,但是我得到了那个错误。

You can define directories as Maven repositories as long as they fit the structure (comparable to the local repository). 您可以将目录定义为Maven存储库,只要它们适合结构即可(与本地存储库相比)。 This is described here: https://stackoverflow.com/a/28762617/927493 . 这在这里描述: https : //stackoverflow.com/a/28762617/927493

The error has nothing to do with the repository declaration. 该错误与存储库声明无关。 It complains about the dependency declaration and the fact that implementation is not known. 它抱怨依赖声明和implementation未知的事实。

Did you add the java or java-library plugin to your project? 您是否已将javajava-library插件添加到项目中? Or another plugin for doing JVM based development? 还是用于基于JVM的开发的另一个插件? If you did not, then the error is expected, it just means that a configuration named implementation was not added to the project. 如果您没有这样做,则可能会出现错误,这仅表示未将名为implementation的配置添加到项目中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM