Comments (13)
Do I need to execute the
mvn clean install -N
only once? E.g. after creating a workspace withyarn 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
- After cloning the source code. (e.g. after running npm install).
- After adding a new module.
- Always re-install in CI pipeline
from jnxplus.
@vladimirdrayling now the build should work without running mvn clean install -N
. Check the version 1.5.1
from jnxplus.
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.
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.
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.
Can you please provide nx.json content?
from jnxplus.
{
"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.
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.
Unfortunately I didn't get it to work :( So here is the repo
from jnxplus.
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.
@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.
@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.
Unfortunately I'm not a maven spring boot expert, so I can't really answer your question
from jnxplus.
Related Issues (20)
- {options.outputDirLocalRepo} not working if moved to nx.json HOT 6
- NX remove does not remove Gradle module from settings.gradle.kts HOT 1
- [nx-maven] Hyphen '-' is not removed in @SpringBootApplication(scanBasePackages = "com.acme.sda-example") HOT 1
- THANK YOU
- How to use ktlint for nx-maven and nx-gradle? HOT 6
- nx show projects hangs with @jnxplus/nx-maven:0.24.3 and nx:17.0.2 HOT 17
- Version 1.0.0 with Nx 19 HOT 2
- Project crystal HOT 6
- Logs not visible when running the application HOT 4
- Gradle :projectDependencyTask fails if NX Daemon is not running HOT 3
- {options.outputDirLocalRepo} not caching HOT 11
- Export nx-maven run-task executor HOT 2
- nx-maven:run-task skipProject option HOT 8
- Project not marked as affected if dependency upgraded HOT 5
- Performance and mvnd HOT 7
- 1.2.0 and 1.3.0+ problems HOT 4
- jnxplus and nx remote caches HOT 3
- Exclude src/test from build
- consider profile dependencies in maven graph HOT 4
- Flag to not create a virtual root folder project? HOT 12
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jnxplus.