有没有人为i-Jetty创建过应用程序?我正在尝试开始使用它,但我不明白我需要做什么来创建.war文件。当使用dx工具将我的.class文件更改为.dex时,我得到了一个
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 :(得分:1)
我曾经为i-jetty webapps创建了一个maven构建文件。以下是webapp源的目录结构:
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和name以满足您的需要。
<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>