Coder Social home page Coder Social logo

cannot serve about jnxplus HOT 13 CLOSED

draylegend avatar draylegend commented on July 29, 2024
cannot serve

from jnxplus.

Comments (13)

asinkxcoswt avatar asinkxcoswt commented on July 29, 2024 2

Do I need to execute the mvn clean install -N only once? E.g. after creating a workspace with yarn create nx-workspace ..., etc.

I am not an expert and don't know much about how maven works internally. But as I inspect its behaviors, I found that the parent installed artifact ~/.m2/repository/your/package/{parent_artifact_id}/{version}/{parent_artifact_id}-{version}.pom contains the list of child modules. If you add a new module and don't re-install the parent pom, this file will not include your new module. Despite that, I have tested adding a new module

nx generate @jnxplus/nx-boot-maven:library --name "my-new-lib" --language java --groupId com.mycompany --projectVersion 1.0.0 --projects "my-app"

and then rebuild my-app without installing the parent artifact.

nx build my-app

It turns out my-new-lib and my-app can build properly without problem. So I think it is not neccessary to re-install parent, but I really don't know if it will break in other scenario.

For my project, my team has decided to always re-install the parent project when

  1. After cloning the source code. (e.g. after running npm install).
  2. After adding a new module.
  3. Always re-install in CI pipeline

from jnxplus.

khalilou88 avatar khalilou88 commented on July 29, 2024 2

@vladimirdrayling now the build should work without running mvn clean install -N. Check the version 1.5.1

from jnxplus.

khalilou88 avatar khalilou88 commented on July 29, 2024 1

Hi @vladimirdrayling Thank you for raising this. You need to build api before serving it.
The api build will also build deps.
I will check if the serve can depends on the build. Like that we will not need to build.

from jnxplus.

asinkxcoswt avatar asinkxcoswt commented on July 29, 2024 1

Hi, could it be related to the problem mentioned in this stackoverflow answer?: https://stackoverflow.com/a/19525334/1078986

I got the same error and can fix by running mvn clean install -N once on the root directory.

What is missing is the artifact for the parent project. After running command above you will find ~/.m2/repository/your/package/{parent_artifact_id} is populated.

from jnxplus.

draylegend avatar draylegend commented on July 29, 2024

Hi @khalilou88 :)

After clearing node_modules/.cache and running nx build api, it didn't built the api. I got this error:

       Nx is waiting on 1 dependent project tasks before running tasks from api...
[INFO] 
[INFO] --------------------------< de.eon:greeting >---------------------------

       Nx is waiting on 1 dependent project tasks before running tasks from api...

       Nx is waiting on 1 dependent project tasks before running tasks from api...
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Using 'UTF-8' encoding to copy filtered properties files.
[INFO] skip non existing resourceDirectory /Users/vladimir.drayling/dev/web/apps/eon/libs/greeting/src/main/resources
[INFO] skip non existing resourceDirectory /Users/vladimir.drayling/dev/web/apps/eon/libs/greeting/src/main/resources

       Nx is waiting on 1 dependent project tasks before running tasks from api...
[INFO] Nothing to compile - all classes are up to date

       Nx is waiting on 1 dependent project tasks before running tasks from api...
[INFO] 
[INFO] --- maven-resources-plugin:3.2.0:testResources (default-testResources) @ greeting ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Using 'UTF-8' encoding to copy filtered properties files.
[INFO] Copying 1 resource
[INFO] 
[INFO] --- maven-compiler-plugin:3.8.1:testCompile (default-testCompile) @ greeting ---
[INFO] Changes detected - recompiling the module!

       Nx is waiting on 1 dependent project tasks before running tasks from api...

       Nx is waiting on 1 dependent project tasks before running tasks from api...
[INFO] Tests are skipped.

       Nx is waiting on 1 dependent project tasks before running tasks from api...
[INFO] Building jar: /Users/vladimir.drayling/dev/web/apps/eon/libs/greeting/target/greeting-0.0.1-SNAPSHOT.jar

       Nx is waiting on 1 dependent project tasks before running tasks from api...
[INFO] Installing /Users/vladimir.drayling/dev/web/apps/eon/libs/greeting/target/greeting-0.0.1-SNAPSHOT.jar to /Users/vladimir.drayling/.m2/repository/de/eon/greeting/0.0.1-SNAPSHOT/greeting-0.0.1-SNAPSHOT.jar
[INFO] Installing /Users/vladimir.drayling/dev/web/apps/eon/libs/greeting/pom.xml to /Users/vladimir.drayling/.m2/repository/de/eon/greeting/0.0.1-SNAPSHOT/greeting-0.0.1-SNAPSHOT.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  6.907 s

       1/1 dependent project tasks succeeded [0 read from cache]

   Hint: you can run the command with --verbose to see the full dependent project outputs

 ——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————


> nx run api:build

Executor ran for Build: {}
[INFO] Scanning for projects...
[INFO] 
[INFO] -----------------------------< de.eon:api >-----------------------------
[INFO] Building api 0.0.1-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  0.675 s
[INFO] Finished at: 2022-03-04T13:46:01+01:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project api: Could not resolve dependencies for project de.eon:api:jar:0.0.1-SNAPSHOT: Failed to collect dependencies at de.eon:greeting:jar:0.0.1-SNAPSHOT: Failed to read artifact descriptor for de.eon:greeting:jar:0.0.1-SNAPSHOT: Could not find artifact de.eon:boot-multi-module:pom:0.0.1-SNAPSHOT -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException

 ——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————

 >  NX   Ran target build for project api and 1 task(s) it depends on (10s)
 
        1/2 failed
        1/2 succeeded [0 read from cache]

from jnxplus.

khalilou88 avatar khalilou88 commented on July 29, 2024

Can you please provide nx.json content?

from jnxplus.

draylegend avatar draylegend commented on July 29, 2024
{
  "npmScope": "eon",
  "affected": {
    "defaultBase": "master"
  },
  "cli": {
    "defaultCollection": "@nrwl/angular",
    "packageManager": "yarn"
  },
  "implicitDependencies": {
    "package.json": {
      "dependencies": "*",
      "devDependencies": "*"
    },
    ".eslintrc.json": "*"
  },
  "tasksRunnerOptions": {
    "default": {
      "runner": "@nrwl/workspace/tasks-runners/default",
      "options": {
        "cacheableOperations": ["build", "lint", "test", "e2e"]
      }
    }
  },
  "targetDependencies": {
    "build": [
      {
        "target": "build",
        "projects": "dependencies"
      }
    ]
  },
  "generators": {
    "@nrwl/angular:application": {
      "style": "scss",
      "linter": "eslint",
      "unitTestRunner": "jest",
      "e2eTestRunner": "cypress"
    },
    "@nrwl/angular:library": {
      "linter": "eslint",
      "unitTestRunner": "jest"
    },
    "@nrwl/angular:component": {
      "style": "scss"
    }
  },
  "defaultProject": "web-client",
  "plugins": ["@jnxplus/nx-boot-maven"]
}

from jnxplus.

khalilou88 avatar khalilou88 commented on July 29, 2024

the nx.json file has the part about building deps:

  "targetDependencies": {
    "build": [
      {
        "target": "build",
        "projects": "dependencies"
      }
    ]
  },

Really, I don't see any problem, try with nx build api --skip-nx-cache
Try to run mvn command directly
You can also share a repo, so we can look together

from jnxplus.

draylegend avatar draylegend commented on July 29, 2024

Unfortunately I didn't get it to work :( So here is the repo

from jnxplus.

khalilou88 avatar khalilou88 commented on July 29, 2024

Could you remove the two tests files from api and test again.
Or remove this deps

    <dependency>
      <groupId>com.h2database</groupId>
      <artifactId>h2</artifactId>
      <scope>runtime</scope>
    </dependency>

    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-data-jpa</artifactId>
    </dependency>

    <dependency>
      <groupId>mysql</groupId>
      <artifactId>mysql-connector-java</artifactId>
      <scope>runtime</scope>
    </dependency>

nx test api didn't work.
the real error is a conflict between deps that you added. maybe you need a database..

from jnxplus.

draylegend avatar draylegend commented on July 29, 2024

@asinkxcoswt I'm a newbie regarding java. But your suggestion worked out! Thank you!

Also thank you @khalilou88 for the help! Together you helped to get this to work! :)

Do I need to execute the mvn clean install -N only once? E.g. after creating a workspace with yarn create nx-workspace ..., etc.

@khalilou88 is there a way to integrate the command into init process of your lib?

from jnxplus.

khalilou88 avatar khalilou88 commented on July 29, 2024

@asinkxcoswt @vladimirdrayling Maybe we can add mvn clean install -N before buildings apps.
Somthing like mvn clean install -N && mvn package spring-boot:repackage -DskipTests=true -pl :api
I need to be sure it's not expensive as an operation.

from jnxplus.

draylegend avatar draylegend commented on July 29, 2024

Unfortunately I'm not a maven spring boot expert, so I can't really answer your question

from jnxplus.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.