RE: import gson issue

تم تعديل Scarletake Bwi منذ 3 سنوات من الدقائق. Expert المشاركات: 327 تاريخ الإنضمام: 20‏/12‏/10 المشاركات الحديثة

hi 

i try import gson, like how-import-gson-library-corfrectly

i modify build.gradle

compileInclude group: "com.google.code.gson", name: "gson", version: "2.9.0"

bnd.bnd

Bundle-Name: DEM
Bundle-SymbolicName: demo.srg
Bundle-Version: 1.0.0
Export-Package:\
	demo.srg.constants,\
	com.google.gson.*

Import-Package:\
	com.google.gson.*; version='2.9.0',\
    *

but doesn't work

error message from gradle build

error  : Classes found in the wrong directory: {META-INF/versions/9/module-info.class=module-info}

 

error when server run up

2022-07-15 04:44:34.233 ERROR [Framework Event Dispatcher: Equinox Container: 6ea82b61-4cc8-443a-8df4-c91c4c11d9da][Framework:47] FrameworkEvent ERROR
com.liferay.portal.kernel.log.LogSanitizerException: org.osgi.framework.BundleException: Could not resolve module: com.pac.ci.srg [1597]_  Unresolved requirement: Import-Package: com.google.gson; version="[2.9.0,3.0.0)"_ [Sanitized]

is there anything i missed? 

thanks in advance 

تم تعديل Scarletake Bwi منذ 3 سنوات من الدقائق.
RE: import gson issue (الإجابة)
New Member المشاركات: 2 تاريخ الإنضمام: 25‏/4‏/22 المشاركات الحديثة
You need to exclude the packages like this with exclamation sign "!" and read this article

https://liferay.dev/blogs/-/blogs/gradle-compile-vs-compileonly-vs-compileinclude

Import-Package: \    
!com.google.gson,\

*

and don't forgot to put * in the last line.