Obfuscate library project

本文介绍如何在主工程中配置ProGuard来混淆LibraryProject,提供多个参考资料链接帮助理解具体操作步骤。
部署运行你感兴趣的模型镜像
对library project的混淆需要在主工程的混淆配置文件中设置
参考:https://stackoverflow.com/questions/10982344/is-proguard-cfg-needed-for-library-projects#10992604
https://stackoverflow.com/questions/8088958/how-to-obfuscate-an-android-library-jar-file-using-proguard-in-eclipse
https://www.guardsquare.com/en/proguard/manual/introduction

您可能感兴趣的与本文相关的镜像

ComfyUI

ComfyUI

AI应用
ComfyUI

ComfyUI是一款易于上手的工作流设计工具,具有以下特点:基于工作流节点设计,可视化工作流搭建,快速切换工作流,对显存占用小,速度快,支持多种插件,如ADetailer、Controlnet和AnimateDIFF等

<plugin> <groupId>com.github.wvengen</groupId> <artifactId>proguard-maven-plugin</artifactId> <version>2.7.0</version> <executions> <execution> <phase>package</phase> <goals> <goal>proguard</goal> </goals> </execution> </executions> <configuration> <injar>${project.build.finalName}.jar</injar> <outjar>${project.build.finalName}-obfuscated.jar</outjar> <putLibraryJarsInTempDir>true</putLibraryJarsInTempDir> <!-- 恢复库路径配置 --> <libraryjars> <!-- JDK 核心库 --> <libraryjar>${java.home}/lib/rt.jar</libraryjar> <libraryjar>${java.home}/jmods/java.base.jmod(!**.jar;!module-info.class)</libraryjar> <!-- Spring Boot Loader --> <libraryjar>${org.springframework.boot:spring-boot-loader:jar}</libraryjar> </libraryjars><obfuscate>true</obfuscate> <options> <option>-dontoptimize</option> <option>-ignorewarnings</option> <!-- 增强Spring Boot Loader保留规则 --> <option>-keep class org.springframework.boot.loader.** { *; }</option> <option>-keep class org.springframework.boot.loader.jar.** { *; }</option> <option>-keep class org.springframework.boot.loader.launcher.** { *; }</option> <option>-keep class org.springframework.boot.loader.util.** { *; }</option> <!-- 保留IO和Zip相关类 --> <option>-keep class java.io.** { *; }</option> <option>-keep class java.util.zip.** { *; }</option> <!-- 保留主启动类 --> <option>-keep class com.jeeplus.JeeplusWebApplication { public static void main(java.lang.String[]); }</option> <!-- 其他保留规则保持不变 --> <option>-keep class com.jeeplus.ureport.** { *; }</option> <option>-keep class com.bstek.ureport.** { *; }</option> <option>-keepattributes *Annotation*,EnclosingMethod,Signature</option> <option>-keep @org.springframework.stereotype.** class * { *; }</option> <option>-keep @org.springframework.context.annotation.** class * { *; }</option> <option>-keep @org.springframework.context.annotation.Configuration class * { *; }</option> <option>-keep @org.springframework.boot.autoconfigure.SpringBootApplication class * { *; }</option> <option>-keep @org.springframework.web.bind.annotation.** class * { *; }</option> <option>-keepclassmembers class * { @org.springframework.beans.factory.annotation.Autowired *; @org.springframework.beans.factory.annotation.Value *; @org.springframework.context.annotation.Bean *; @org.springframework.web.bind.annotation.* *; }</option> <option>-keepclassmembers class * implements java.io.Serializable { static final long serialVersionUID; private static final java.io.ObjectStreamField[] serialPersistentFields; private void writeObject(java.io.ObjectOutputStream); private void readObject(java.io.ObjectInputStream); java.lang.Object writeReplace(); java.lang.Object readResolve(); }</option> <option>-keepclassmembers class * { public static ** getResource(java.lang.String); public static ** getResourceAsStream(java.lang.String); }</option> </options> </configuration> </plugin>
09-17
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file LICENSE.rst or https://cmake.org/licensing for details. cmake_minimum_required(VERSION ${CMAKE_VERSION}) project(FortranCInterface C Fortran) include(${FortranCInterface_BINARY_DIR}/Input.cmake OPTIONAL) # Check if the C compiler supports &#39;$&#39; in identifiers. include(CheckSourceCompiles) check_source_compiles(C "extern int dollar$(void); int main() { return 0; }" C_SUPPORTS_DOLLAR) # List manglings of global symbol names to try. set(global_symbols my_sub # VisualAge my_sub_ # GNU, Intel, HP, SunPro, PGI my_sub__ # GNU g77 MY_SUB # Intel on Windows mysub # VisualAge mysub_ # GNU, Intel, HP, SunPro, PGI MYSUB # Intel on Windows ${FortranCInterface_GLOBAL_SYMBOLS} ) list(REMOVE_DUPLICATES global_symbols) # List manglings of module symbol names to try. set(module_symbols __my_module_MOD_my_sub # GNU 4.3 __my_module_NMOD_my_sub # VisualAge __my_module__my_sub # GNU 4.2 __mymodule_MOD_mysub # GNU 4.3 __mymodule_NMOD_mysub # VisualAge __mymodule__mysub # GNU 4.2 my_module$my_sub # HP my_module_mp_my_sub_ # Intel MY_MODULE_mp_MY_SUB # Intel on Windows my_module_my_sub_ # PGI my_module_MP_my_sub # NAG mymodule$mysub # HP mysub$mymodule_ # Cray my_sub$my_module_ # Cray mymodule_mp_mysub_ # Intel MYMODULE_mp_MYSUB # Intel on Windows mymodule_mysub_ # PGI mymodule_MP_mysub # NAG _QMmy_modulePmy_sub # LLVMFlang _QMmymodulePmysub # LLVMFlang __module_my_module_my_sub # LFortran __module_mymodule_mysub # LFortran ${FortranCInterface_MODULE_SYMBOLS} ) list(REMOVE_DUPLICATES module_symbols) # Note that some compiler manglings cannot be invoked from C: # SunPro uses "my_module.my_sub_" # PathScale uses "MY_SUB.in.MY_MODULE" # Add module symbols only with Fortran90. if(CMAKE_Fortran_COMPILER_SUPPORTS_F90) set(myfort_modules mymodule.f90 my_module.f90) set(call_mod call_mod.f90) set_property(SOURCE main.F PROPERTY COMPILE_DEFINITIONS CALL_MOD) else() set(module_symbols) endif() # Generate C symbol sources. set(symbol_sources) if(NOT CMAKE_Fortran_COMPILER_ID MATCHES "^(PathScale)$") # Provide mymodule_ and my_module_ init symbols because: # - PGI Fortran uses module init symbols # - Cray Fortran >= 7.3.2 uses module init symbols # but not for: # - PathScale Fortran uses module init symbols but module symbols # use &#39;.in.&#39; so we cannot provide them anyway. list(APPEND symbol_sources mymodule_.c my_module_.c MY_MODULE.c MYMODULE.c) endif() foreach(symbol IN LISTS global_symbols module_symbols) # Skip symbols with &#39;$&#39; if C cannot handle them. if(C_SUPPORTS_DOLLAR OR NOT "${symbol}" MATCHES "\\$") if("${symbol}" MATCHES "SUB") set(upper "-UPPER") else() set(upper) endif() string(REPLACE "$" "S" name "${symbol}") set(source ${CMAKE_CURRENT_BINARY_DIR}/symbols/${name}${upper}.c) configure_file(${CMAKE_CURRENT_SOURCE_DIR}/symbol.c.in ${source} @ONLY) list(APPEND symbol_sources ${source}) endif() endforeach() # Provide symbols through Fortran. add_library(myfort STATIC mysub.f my_sub.f ${myfort_modules}) # Provide symbols through C but fall back to Fortran. add_library(symbols STATIC ${symbol_sources}) target_link_libraries(symbols PUBLIC myfort) # In case the Fortran compiler produces PIC by default make sure # the C compiler produces PIC even if it is not its default. set_property(TARGET symbols PROPERTY POSITION_INDEPENDENT_CODE 1) if(CMAKE_Fortran_COMPILER_ID STREQUAL "LFortran") if(CMAKE_Fortran_COMPILER_VERSION VERSION_GREATER_EQUAL "0.55") set(_LFORTRAN_SC_FLAG --separate-compilation) else() set(_LFORTRAN_SC_FLAG --generate-object-code) endif() add_compile_options(--implicit-interface ${_LFORTRAN_SC_FLAG}) endif() # Require symbols through Fortran. add_executable(FortranCInterface main.F call_sub.f ${call_mod}) target_link_libraries(FortranCInterface PUBLIC symbols) # If IPO is enabled here, GCC gfortran >= 12.0 will obfuscate # the strings of the return values in the compiled executable, # which we use to regex match against later. # The static libraries must be build with IPO and non-IPO objects, # as that will ensure the verify step will operate on IPO objects, # if requested by the system compiler flags. if(CMAKE_Fortran_COMPILER_ID STREQUAL "GNU" AND CMAKE_Fortran_COMPILER_VERSION VERSION_GREATER_EQUAL 12) target_compile_options(FortranCInterface PRIVATE "-fno-lto") if(NOT APPLE) target_compile_options(myfort PRIVATE "-flto=auto" "-ffat-lto-objects") endif() endif() if(CMAKE_C_COMPILER_ID STREQUAL "GNU" AND CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 12) if(NOT APPLE) target_compile_options(symbols PRIVATE "-flto=auto" "-ffat-lto-objects") endif() endif() file(GENERATE OUTPUT exe-$<CONFIG>.cmake CONTENT [[ set(FortranCInterface_EXE "$<TARGET_FILE:FortranCInterface>") ]])
10-21
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值