将apklib转换为jar

时间:2013-08-29 04:15:42

标签: java android maven

如何将我的apklib转换为jar?我想开源并允许非maven开发人员使用我的代码。我的代码不使用maven特定的任何东西。它不用于xml文件或图像,只用于java。我尝试将包装更换为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>

2 个答案:

答案 0 :(得分:0)

  

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

我认为你最好解决这个问题,导致JAR打包失败,而不是试图从Java字节码转换到Davlik再返回。

如果您提到 失败的原因,我们或许可以帮助您......


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

答案 1 :(得分:0)

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

也许这会对您有所帮助,当我使用命令$re = "/(\sA\d{6})/"; $result= preg_split($re , $str); print_r($result); 时,它会同时创建mvn clean installapklib,并将它们放入我的本地仓库:{{1 }}