0

我该如何将我的 apklib 转换为 jar?我想开源并允许非 Maven 开发人员使用我的代码。我的代码没有使用任何特定于 Maven 的东西。它不用于 xml 文件或图像,仅用于 java.xml 文件或图像。我尝试将包装更改为 jar,但失败了。

<?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>

    <parent>
        <groupId>org.sonatype.oss</groupId>
        <artifactId>oss-parent</artifactId>
        <version>5</version>
    </parent>

    <version>1.0.0-SNAPSHOT</version>

    <groupId>com.programmingarehard</groupId>
    <artifactId>freshorm</artifactId>
    <packaging>apklib</packaging>
    <name>FreshORM</name>


    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

        <binary.prefix>fresh</binary.prefix>
        <android.version>4.1.1.4</android.version>
        <android.platform>16</android.platform>
        <android.support.version>r7</android.support.version>

        <!-- Test Dependencies -->
        <junit.version>4.10</junit.version>
        <fest.version>2.0M7</fest.version>
        <robolectric.version>2.0-alpha-1</robolectric.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>com.google.android</groupId>
            <artifactId>android</artifactId>
            <version>${android.version}</version>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>${junit.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.easytesting</groupId>
            <artifactId>fest-assert-core</artifactId>
            <version>${fest.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-all</artifactId>
            <version>1.9.5</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.robolectric</groupId>
            <artifactId>robolectric</artifactId>
            <version>${robolectric.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.google.inject</groupId>
            <artifactId>guice</artifactId>
            <version>3.0</version>
            <classifier>no_aop</classifier>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>2.3.2</version>
                <configuration>
                    <source>1.6</source>
                    <target>1.6</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>com.jayway.maven.plugins.android.generation2</groupId>
                <artifactId>android-maven-plugin</artifactId>
                <version>3.6.0</version>
                <configuration>
                    <sdk>
                        <!-- platform or api level (api level 4 = platform 1.6)-->
                        <path>/Users/davidadams/Documents/android-sdk-macosx</path>
                        <platform>16</platform>
                    </sdk>
                    <undeployBeforeDeploy>true</undeployBeforeDeploy>
                </configuration>
                <extensions>true</extensions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.6</version>
                <configuration>
                    <excludes>
                        <exclude>**/Test*.java</exclude>
                    </excludes>
                </configuration>
            </plugin>
        </plugins>
    </build>

</project>
4

2 回答 2

0

我尝试将包装更改为 jar,但失败了。

我认为您最好解决导致 JAR 打包失败的问题,而不是尝试将 Java 字节码转换为 Davlik 并再次返回。

如果您提到它是如何失败的,我们也许可以帮助您...


这是一个想法。使用打包“jar”创建第二个 Maven 项目/POM,并将所有(可重用)Java 代码移到那里。然后使该项目成为该项目的依赖项。

于 2013-08-29T04:55:18.710 回答
0

https://github.com/gitskarios/Gitskarios-core

也许这会对你有所帮助,当我使用命令时mvn clean install,它会同时创建apklibjar,并将它们放入我的本地仓库中:~/m2/path/to/myprojectid

于 2015-10-26T13:10:03.650 回答