Unidbg打Jar包方式

Unidbg打Jar包

方式一

以先前WebServer为例子,多模块的例子
在这里插入图片描述
配置所有模块,配置启动的Main Class;META-INF选择 Server模块的src目录
在这里插入图片描述
文件路径使用相对路径vm = emulator.createDalvikVM(new File("jstz.apk"));

编译工件
在这里插入图片描述
将apk放在jar包同目录,运行可得结果

方式二

将Unidbg项目打Jar包后引入
在这里插入图片描述
在这里插入图片描述
点击ok

在自己的模块中添加jar包依赖(本地依赖该jar包)

<dependency>
    <groupId>unidbg</groupId>
    <artifactId>unidbg</artifactId>
    <version>0.9.7</version>
    <scope>system</scope>
    <systemPath>/Users/Downloads/unidbg-master_0.97/out/artifacts/unidbg_master_0_97_jar/unidbg-master_0.97.jar</systemPath>
</dependency>

<!-- 如果想关闭log日志打印,需要添加如下 -->
<!-- 
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-web</artifactId>
    **修改一下spring-boot-starter-web,添加exclusions**
    <exclusions>
        <exclusion>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-logging</artifactId>
        </exclusion>
    </exclusions>
</dependency>
 -->
<dependency>
    <groupId>org.slf4j</groupId>
    <artifactId>slf4j-api</artifactId>
    <version>${slf4j.version}</version>
</dependency>
<dependency>
    <groupId>org.slf4j</groupId>
    <artifactId>slf4j-simple</artifactId>
    <version>${slf4j.version}</version>
</dependency>

可在项目中创建lib文件夹,目录填写相对路径(${project.basedir}/lib/unidbg-master_0.97.jar

使用插件

两种,还未搞明白
xxb
<plugin>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-maven-plugin</artifactId>
    <configuration>
        <executable>true</executable>
        <includeSystemScope>true</includeSystemScope>
    </configuration>
    <executions>
        <execution>
            <goals>
                <goal>repackage</goal>
            </goals>
        </execution>
    </executions>
</plugin>

可执行jar
<plugin>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-maven-plugin</artifactId>
    <executions>
        <execution>
            <goals>
                <goal>repackage</goal>
            </goals>
            <configuration>
                <classifier>spring-boot</classifier>
                <mainClass>
                  org.baeldung.executable.ExecutableMavenJar
                </mainClass>
            </configuration>
        </execution>
    </executions>
</plugin>

使用命令进行打包

mvn package -T10 -DskipTests

普通项目打Jar包

IDEA方式

同Unidbg方式一,选择指定模块;META-INF选择 Server模块的src目录

Maven方式

  <build>
    <plugins>
      <!-- Jar包与多个依赖包-->
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-jar-plugin</artifactId>
        <configuration>
          <archive>
            <!-- 生成的jar中,不要包含pom.xml和pom.properties这两个文件-->
            <addMavenDescriptor>true</addMavenDescriptor>
            <manifest>
              <!-- 添加一个依赖路径Classpath-->
              <addClasspath>true</addClasspath>
              <!-- 依赖的是当前目录下的libs/目录(为的是将依赖与主jar区分开)-->
              <classpathPrefix>libs/</classpathPrefix>
              <!-- 要执行的主Class-->
              <mainClass>
                org.example.PRequest
              </mainClass>
            </manifest>
          </archive>
        </configuration>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-dependency-plugin</artifactId>
        <executions>
          <execution>
            <id>copy-dependencies</id>
            <phase>prepare-package</phase>
            <goals>
              <goal>copy-dependencies</goal>
            </goals>
            <configuration>
              <outputDirectory>
                ${project.build.directory}/libs
              </outputDirectory>
            </configuration>
          </execution>
        </executions>
      </plugin>

      <!-- 依赖包与jar包一起-->
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-assembly-plugin</artifactId>
        <executions>
          <execution>
            <phase>package</phase>
            <goals>
              <goal>single</goal>
            </goals>
            <configuration>
              <archive>
                <manifest>
                  <mainClass>
                    org.example.PRequest
                  </mainClass>
                </manifest>
              </archive>
              <descriptorRefs>
                <descriptorRef>jar-with-dependencies</descriptorRef>
              </descriptorRefs>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>

参考 Maven打包可执行jar包方法大全(史上最全)

  • 3
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Forgo7ten

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值