简体   繁体   English

Maven的Android pom.xml

[英]maven android pom.xml

I have set up my an in house nexus repository. 我已经建立了一个内部联系存储库。 Now i have changed my settings.xml file to point to my repository, but i also want to include the reference in my project pom.xml file. 现在,我已经更改了settings.xml文件以指向我的存储库,但是我也想在我的项目pom.xml文件中包含引用。 Now is this pom.xml file valid ? 现在,此pom.xml文件有效吗? If i change the password of the repo, maven still downloads the file from the repo ? 如果我更改了存储库的密码,Maven仍会从存储库下载文件? What am i doing wrong ? 我究竟做错了什么 ? Is this configuration correct ? 此配置正确吗?

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
 http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.mycomp</groupId>
    <artifactId>TestAndroid</artifactId>
    <version>1.0.0-SNAPSHOT</version>
    <packaging>apk</packaging>
    <name>Test Android Application</name>
    <servers>
        <server>
            <id>com-repo</id>
            <username>admin</username>
            <password>admin</password>
        </server>
    </servers>
    <repositories>
        <repository>
            <id>com-repo</id>
            <url>http://central</url>
            <releases>
                <enabled>true</enabled>
            </releases>
            <snapshots>
                <enabled>true</enabled>
                <updatePolicy>always</updatePolicy>
            </snapshots>
        </repository>
    </repositories>
    <pluginRepositories>
        <pluginRepository>
            <id>com-repo</id>
            <name>com-repo</name>
            <url>http://10.10.10.230:8081/nexus/content/groups/public/</url>
            <releases>
                <enabled>true</enabled>
            </releases>
            <snapshots>
                <enabled>true</enabled>
            </snapshots>
        </pluginRepository>
    </pluginRepositories>
    <dependencies>
        <dependency>
            <groupId>org.springframework.android</groupId>
            <artifactId>spring-android-rest-template</artifactId>
            <version>1.0.1.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.codehaus.jackson</groupId>
            <artifactId>jackson-mapper-asl</artifactId>
            <version>1.9.8</version>
        </dependency>
        <dependency>
            <groupId>commons-lang</groupId>
            <artifactId>commons-lang</artifactId>
            <version>20030203.000129</version>
        </dependency>
        <dependency>
            <groupId>com.actionbarsherlock</groupId>
            <artifactId>actionbarsherlock</artifactId>
            <version>4.2.0</version>
            <type>apklib</type>
        </dependency>

        <dependency>
            <groupId>org.google</groupId>
            <artifactId>admob</artifactId>
            <version>1.0.0</version>
        </dependency>
        <dependency>
            <groupId>org.mycpmp</groupId>
            <artifactId>1234</artifactId>
            <version>1.0.0</version>
        </dependency>
        <dependency>
            <groupId>com.test</groupId>
            <artifactId>test</artifactId>
            <version>1.0.0</version>
        </dependency>

        <dependency>
            <groupId>org.taptwo.android</groupId>
            <artifactId>widget</artifactId>
            <version>1.0.0</version>
            <type>apklib</type>
        </dependency>
        <dependency>
            <groupId>commons-validator</groupId>
            <artifactId>commons-validator</artifactId>
            <version>1.4.0</version>
        </dependency>

        <dependency>
            <groupId>com.google.android</groupId>
            <artifactId>android</artifactId>
            <version>4.1.1.4</version>
            <scope>provided</scope>
        </dependency>
        <!-- <dependency> -->
        <!-- <groupId>com.google.api-ads</groupId> -->
        <!-- <artifactId>dfp-lib</artifactId> -->
        <!-- <version>0.4.0</version> -->
        <!-- </dependency> -->


    </dependencies>
    <build>
        <finalName>${project.artifactId}</finalName>
        <sourceDirectory>src/main/java</sourceDirectory>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>com.jayway.maven.plugins.android.generation2</groupId>
                    <artifactId>android-maven-plugin</artifactId>
                    <version>3.1.1</version>
                    <extensions>true</extensions>
                </plugin>
            </plugins>
        </pluginManagement>
        <plugins>
            <plugin>
                <groupId>com.jayway.maven.plugins.android.generation2</groupId>
                <artifactId>android-maven-plugin</artifactId>
                <configuration>
                    <attachSources>true</attachSources>
                    <sign>
                        <debug>false</debug>
                    </sign>
                    <sdk>
                        <platform>16</platform>
                    </sdk>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jarsigner-plugin</artifactId>
                <version>1.2</version>
                <executions>
                    <execution>
                        <id>signing</id>
                        <goals>
                            <goal>sign</goal>
                        </goals>
                        <phase>package</phase>
                        <inherited>true</inherited>
                        <configuration>
                            <archiveDirectory></archiveDirectory>
                            <includes>
                                <include>target/*.apk</include>
                            </includes>
                            <keystore>avm.keystore</keystore>
                            <storepass>123</storepass>
                            <keypass>123</keypass>
                            <alias>asdfg</alias>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project> 

The credentials are only for deploying to the repository. 凭据仅用于部署到存储库。 Repositories for deployment are defined in a distributionManagement element; 用于部署的存储库在distributionManagement元素中定义; it's distinct from the repositories element stuff. 它与存储库元素的东西不同。 The repositories element defines repos where your dependencies are resolved from. repositories元素定义了从中解析依赖项的存储库。

Moreover, the pom doesn't support putting the credentials in like this. 而且,pom不支持像这样放置凭据。 Are you getting errors when you execute it? 执行时是否出现错误? I would think so. 我会这样认为。

Your pom is not valid. 您的Pom无效。 As stated in here , you should not put the username and password in the pom.xml. 如规定在这里 ,你不应该把在pom.xml的用户名和密码。

The repositories for download and deployment are defined by the repositories and distributionManagement elements of the POM. 用于下载和部署的存储库由POM的存储库和distributionManagement元素定义。 However, certain settings such as username and password should not be distributed along with the pom.xml. 但是,某些设置(例如用户名和密码)不应与pom.xml一起分发。 This type of information should exist on the build server in the settings.xml. 这种类型的信息应存在于构建服务器的settings.xml中。

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

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