Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Download cn1libs doesn't working in Settings app #3882

Closed
hrugani opened this issue Mar 7, 2025 · 9 comments
Closed

Download cn1libs doesn't working in Settings app #3882

hrugani opened this issue Mar 7, 2025 · 9 comments

Comments

@hrugani
Copy link

hrugani commented Mar 7, 2025

Describe the bug
We created a new codenameone app using the starter web app (for Java, intellij-idea, hello would template). so far so good. But when we try to install the CN1JSON using condenameone settings app, It says that the common pom was updated with the necessary new dependency. Then, we added a little bit of code that imports ca.weblite.codename1.json.JSONObject, When We try to compile the app using maven goals (in Intellij), the compiler launches an error saying it cannot find ca.weblite.codename1.json.JSONObject.

To Reproduce
Steps to reproduce the behavior:

  1. Create new codenameone project using the starter (Java, intellij, yellow would template'
  2. Added any amount of Java code that imports ca.weblite.codename1.json.JSONObject
  3. Start the codenameone settings app
  4. Select the option that allows downloading cn1libs and select CN1JSON cn1lib
  5. press download. See the bottom message saying the dependency was added to the common pom file
  6. close the Codenameone Settings app.
  7. In intellij Maven options execute the goal clean compile, or clean package
  8. Intelij will show an error that it cannot find ca.weblite.codename1.json.JSONObject

Expected behavior
The maven goals ( compile or package) should be executed with no errors

Screenshots
not applicable.

Desktop (please complete the following information):

  • OS: the device OS doesn't matter in this case. But my host that is running IntelliJ is a Linux Ubuntu 22.04)
  • Browser: chrome
  • Version: we believe that browser version isn't an useful info here

Smartphone (please complete the following information):

  • Device: [e.g. iPhone6]
  • OS: [e.g. iOS8.1]
  • Browser [e.g. stock browser, safari]
  • Version [e.g. 22]

Additional context
We believe that all the information is present above.
Our production app uses several cn1libs.
Any help to fix that will be well appreciated.

@shai-almog
Copy link
Collaborator

In the maven side bar did you refresh the maven project using the sync/reload button?

Image

@hrugani
Copy link
Author

hrugani commented Mar 8, 2025

Hi Shai,
The image in the link below gives you what my Codenameone settings app launched inside my project says about the CN1JSON cn1lib:
image

As you can see, the codenameone-settings-app says that the json library is installed and up to date (version 5)

Now, below you are the video showing what happens in my IntelliJ IDE:
video

I executed the maven sync option, as you oriented.
The video also shows the json library cannot be found in the maven central.
Could something be wrong with the dependency injection from codename-one-settings-app?

Please, reopen this issue. The problem in my project hasn't been solved yet. I remain frozen and cannot make either fixes or new features in my production app.

@hrugani hrugani closed this as completed Mar 8, 2025
@shai-almog
Copy link
Collaborator

We didn't close the issue. Did you modify your pom.xml in any way or let a tool other than ours modify the pom.xml?

Can you include a listing of the pom.xml for the top level project?

@shai-almog shai-almog reopened this Mar 9, 2025
@hrugani
Copy link
Author

hrugani commented Mar 9, 2025

Hi Shai. Good to see you here.
I initially left all pom files manipulations to the Codenameone Settings App.
Exactly as I described in this issue.
This approach doesn't work as you can verify in the issue description.
Then, I tried some manual insertions in the poms. All of them didn´t work.

I am concerned with the message the IntelliJ community returns when it executes the Maven clear package (see the video). The message says the package CN1JSON doesn't exist in the Meven Central registry. Is it true?
This package doesn't present in the Maven Central Registry. Are the GroupID or ArtifactID wrong? Is it possible the Codenameone Settings App wrote wrong package names in the pom files?

Attending what you requested, below you are my common pom.xml:
common pom.xml

Comparing with the same pom.xml before Codenameone Settings modifications, I saw this XML snippet below was inserted:

<dependency>
  <artifactId>iwcareapp-CN1JSON</artifactId>
  <groupId>com.iw.mobile</groupId>
  <version>1.0-SNAPSHOT</version>
  <type>pom</type>
</dependency> 

After, executing the Intellij maven sync option, this message is launched:
Could not find artifact com.iw.mobile:iwcareapp-CN1JSON:pom:1.0-SNAPSHOT.

Even after Try to run Maven import with -U flag (force update snapshots),
The error remains the same.

@Eric-Chomba
Copy link
Contributor

Hi Shai. Good to see you here. I initially left all pom files manipulations to the Codenameone Settings App. Exactly as I described in this issue. This approach doesn't work as you can verify in the issue description. Then, I tried some manual insertions in the poms. All of them didn´t work.

I am concerned with the message the IntelliJ community returns when it executes the Maven clear package (see the video). The message says the package CN1JSON doesn't exist in the Meven Central registry. Is it true? This package doesn't present in the Maven Central Registry. Are the GroupID or ArtifactID wrong? Is it possible the Codenameone Settings App wrote wrong package names in the pom files?

Attending what you requested, below you are my common pom.xml: common pom.xml

Comparing with the same pom.xml before Codenameone Settings modifications, I saw this XML snippet below was inserted:

iwcareapp-CN1JSON com.iw.mobile 1.0-SNAPSHOT pom After, executing the Intellij maven sync option, this message is launched: Could not find artifact com.iw.mobile:iwcareapp-CN1JSON:pom:1.0-SNAPSHOT.

Even after Try to run Maven import with -U flag (force update snapshots), The error remains the same.

Have you tried to run it in simulator already?

When you run in simulator while connected to internet, it will download all dependencies in common/pom.xml if it hasn't downloaded them yet.

@shai-almog
Copy link
Collaborator

That dependency seems deeply incorrect, @shannah do you understand why that dependency was generated by the settings?

@hrugani what's the content of the top level pom xml file? What's the plugin version?

Did you generate the project via the migration tool or through start.codenameone.com?

If the former then I suggest starting a fresh project with start and manually copying over the code and settings.

@hrugani
Copy link
Author

hrugani commented Mar 12, 2025

Hi Shai and Shannah,

I am using the plugin version 7.0.174

In the link below you will find the content of my top level pom.xml:
my top level pom.xml content

My project was started as a fresh project, using the starter web app from Code Name One. I described it in this issue description.
After that, I opened it in my Intellij IDE. Just so, all works fine. The project (Hello World!) compiles and runs correctly.
Then I open the Codenameone App Settings and download the cn1json. I noticed the Codenameone Settings app, only inserted a dependency in the common pom.xml.
Then I added a new Java class that only imports ca...JSONOBJECT
Then executed maven sync
Then executed maven clean compile
the error below occurs:
Failed to execute goal on project iwcareapp-common: Could not resolve dependencies for project com.iw.mobile:iwcareapp-common:jar:1.0-SNAPSHOT: Could not find artifact com.iw.mobile:iwcareapp-CN1JSON:pom:1.0-SNAPSHOT

Additional info:
I made a research in Central Maven.
I don't find anything using CN1JSON and cn1json as search arguments.

@shai-almog
Copy link
Collaborator

@shannah I was able to reproduce this with a clean download from the initilizr:

  • Download a fresh maven project from initilizr
  • Launch Codename One Settings
  • In Extensions install "Codename One JSON Library"
  • Press the refresh maven button

The problem seems to be due to the 7.0.86 version of the plugin that's the default from Initializr...

@hrugani the workaround is to download a fresh version of the project from initilizr. Before you do anything open the main pom.xml file and update the version of the plugin to:

<cn1.plugin.version>7.0.175</cn1.plugin.version>

Once you do that refresh the project in Sync -> Reload all maven projects.

Then proceed as usual and select Reload all maven projects again after the installation.

@shannah
Copy link
Collaborator

shannah commented Mar 13, 2025

I have updated the Initializr to use 7.0.175 by default now, which should resolve this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants