2010-06-01 53 views
1

是否有人爲i-Jetty創建了應用程序?我試圖開始使用它,但我不明白我需要做什麼來創建.war文件。當使用DX工具來改變我的.class文件.DEX我得到一個i-Jetty的Web應用程序

UNEXPECTED TOP-LEVEL EXCEPTION: java.lang.RuntimeException:\...\ijetty\hello\HelloWorld.class: file not found
at com.android.dx.util.FileUtils.readFile(FileUtils.java:55)
at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:133) at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:108)
at com.android.dx.command.dexer.Main.processOne(Main.java:247)
at com.android.dx.command.dexer.Main.processAllFiles(Main.java:183)
at com.android.dx.command.dexer.Main.run(Main.java:139)
at com.android.dx.command.dexer.Main.main(Main.java:120)
at com.android.dx.command.Main.main(Main.java:89)
1 error; aborting

是代碼段通常很難正確格式化?我花了10分鐘,以解決這個小方塊......

我知道我需要將我的類文件.DEX和我的庫,然後將轉換爲.WAR

如果任何人都可以指導我在這裏我會非常感謝!

謝謝, 克里斯

+0

我的類文件在那裏,並且dx工具接受也失敗的目錄,並出現此異常。 – Cbudz 2010-06-01 18:55:39

回答

1

我創造了我,碼頭一個Maven構建文件的webapps一段時間回來。以下是web應用程序源代碼的目錄結構:

sampleapp/ 
    |-- pom.xml 
    `-- src 
     `-- main 
      |-- java 
      | `-- {java sources} 
      `-- webapp 
       |-- {html js css sources} 
       `-- WEB-INF 
        `-- web.xml 

在命令行導出兩個環境變量:

$>export ANDROID_HOME=/path/to/android/sdk 
    $>export ANDROID_PLATFORM=7 OR 8 or whatever platform you are using 

你做了之後,類型:(假定您已經Maven的安裝2.1+ )

$>mvn package 

這將在目標目錄中生成sampleapp.war文件。可以在i-jetty中部署。 下面是pom.xml。更改pom.xml中的artifactId和名稱以滿足您的需求。

<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>sampleapp</groupId> 
    <artifactId>sampleapp</artifactId> 
    <packaging>war</packaging> 
    <name>sampleapp</name> 
    <description>Sample Web application</description> 
    <version>1.0-a1</version> 

    <properties> 
     <android.home>${env.ANDROID_HOME}</android.home> 
     <android.platform.version>${env.ANDROID_PLATFORM}</android.platform.version> 
     <android.platform>platforms/android-${android.platform.version}</android.platform> 
     <android.framework.aidl>${android.home}/${android.platform}/framework.aidl</android.framework.aidl> 
     <android.jar>${android.home}/${android.platform}/android.jar</android.jar> 

     <android.tools.aapt>${android.home}/${android.platform}/tools/aapt</android.tools.aapt> 
     <android.tools.dx>${android.home}/${android.platform}/tools/dx</android.tools.dx> 
     <android.tools.apkbuilder>${android.home}/tools/apkbuilder</android.tools.apkbuilder> 
     <android.tools.aidl>${android.home}/${android.platform}/tools/aidl</android.tools.aidl> 
    </properties> 

    <dependencies> 
     <dependency> 
      <groupId>org.mortbay.jetty</groupId> 
      <artifactId>servlet-api</artifactId> 
      <version>2.5-20081211</version>  
      <scope>provided</scope> 
     </dependency> 
     <dependency> 
      <groupId>android</groupId> 
      <artifactId>android</artifactId> 
      <version>2.2_r1</version> 
      <scope>provided</scope> 
     </dependency> 
    </dependencies> 

    <build> 
     <plugins> 
      <plugin> 
       <groupId>org.codehaus.mojo</groupId> 
       <artifactId>build-helper-maven-plugin</artifactId> 
       <version>1.4</version> 
       <executions> 
       <execution> 
        <phase>generate-sources</phase> 
        <goals> 
         <goal>add-source</goal> 
        </goals> 
        <configuration> 
         <sources> 
          <source>${project.build.directory}/generated-sources</source> 
         </sources> 
        </configuration> 
       </execution> 
       </executions> 
      </plugin> 

      <plugin> 
       <groupId>org.apache.maven.plugins</groupId> 
       <artifactId>maven-dependency-plugin</artifactId> 
       <executions> 
       <execution> 
        <id>unpack-dependencies</id> 
        <phase>generate-sources</phase> 
        <goals> 
         <goal>unpack-dependencies</goal> 
        </goals> 
        <configuration> 
         <failOnMissingClassifierArtifact>false</failOnMissingClassifierArtifact> 
         <excludeArtifactIds>servlet-api,android</excludeArtifactIds> 
         <excludeTransitive>true</excludeTransitive> 
         <outputDirectory>${project.build.directory}/generated-classes</outputDirectory> 
        </configuration> 
       </execution> 
       </executions> 
      </plugin> 

      <plugin> 
       <groupId>org.codehaus.mojo</groupId> 
       <artifactId>exec-maven-plugin</artifactId> 
       <version>1.1</version> 
       <executions> 
       <!-- Generate any aidl interfaces --> 
       <!-- 
       <execution> 
        <id>aidl-generate</id> 
        <phase>generate-sources</phase> 
        <goals> 
         <goal>exec</goal> 
        </goals> 
        <configuration> 
         <executable>${android.tools.aidl}</executable> 
         <arguments> 
          <argument>-I${basedir}/src/</argument> 
          <argument>-o${project.build.directory}/generated-sources/</argument> 
          <argument>-p${android.framework.aidl}</argument> 
          <argument>${basedir}/src/main/java/com/mycompany/MyService.aidl</argument> 
         </arguments> 
        </configuration> 
       </execution> 
       --> 

       <!-- Convert the compiled classes into a clases.dex. --> 
       <execution> 
        <id>generate-dex</id> 
        <phase>process-classes</phase> 
        <goals> 
         <goal>exec</goal> 
        </goals> 
        <configuration> 
         <executable>${android.tools.dx}</executable> 
         <arguments> 
          <!--<argument>-JXmx1024M</argument>--> 
          <argument>--dex</argument> 
          <!-- argument>\-\-verbose</argument --> 
          <argument>--core-library</argument> 
          <argument>--output=${project.build.directory}/classes.dex</argument> 
          <argument>--positions=lines</argument> 
          <argument>${project.build.directory}/classes/</argument> 
          <!-- uncomment this line if you have any generated classes such as aidl interfaces --> 
          <!-- argument>${project.build.directory}/generated-classes/</argument --> 
         </arguments> 
        </configuration> 
       </execution> 
       </executions> 
      </plugin> 
      <plugin> 
       <artifactId>maven-antrun-plugin</artifactId> 
       <executions> 
       <execution> 
        <id>copydex</id> 
        <phase>process-classes</phase> 
        <goals> 
         <goal>run</goal> 
        </goals> 
        <configuration> 
         <tasks> 
          <mkdir dir="${project.build.directory}/${project.artifactId}-${project.version}/WEB-INF/lib"/> 
          <jar basedir="${project.build.directory}" update="true" 
           includes="classes.dex" 
           destfile="${project.build.directory}/${project.artifactId}-${project.version}/WEB-INF/lib/classes.zip"/> 
         </tasks> 
        </configuration> 
       </execution> 
       </executions> 
      </plugin> 
     </plugins> 
    </build> 
    </project>