Hinderance when attempting to add MySQL connector through Maven - java

When I use mvn clean install after adding the dependency in the 'pom.xml', I get the following output, instead of the expected Downloading: https://repo.maven.apache.org/maven2/mysql/mysql-connector-java/6.0.5/mysql-connector-java-6.0.5.pom-type of message.

You've only posted the end of the Maven output -- are you sure the new dependency wasn't downloaded before the tests were run? It finishes with BUILD SUCCESS... how do you know something's not working?
What changes did you make to the pom.xml file? If I could see those, I could offer some thoughts about whether they look correct or not.
In case there's any confusion on this point -- you indicate that you ran mvn clean install. These are lifecycle goals of the project itself. Some of what you posted makes me wonder if you really intended to run (thought you were running) the maven-install-plugin. That would look more like $mvn install:install ....

Related

Maven can't find a module

I've been trying for the last few weeks at this point to get Maven to compile my project and I am so desperate
I am running the following maven command on the root directory:
mvn clean verify -fae -X
And I am getting the following output: log on Pastebin
This clearly means that it cannot find the module that it has already identified, during compile (meaning any goal that includes compile will throw the same error). IntelliJ could even find the source of the module (with find usages) in the MAVEN LOCAL REPO as a compiled JAR, which baffles me because maven doesn't seem to want to figure that one out and now after renaming it can find the sources in this project too, so I don't know where it could be going wrong at all.
I can't provide any relevant code, because I have no clue where the issue might lie. All of my code can be found on my GitHub here, in the IerisLib repository on the experimental branch.
I am extremely frustrated with this issue and at this point I don't know what to do. I have attempted:
Deleting all and cloning again, changing the module's names twice, rewriting the module-info.java files and just playing around with Maven command parameters(that's how I came up with -fae -X instead of just mvn clean verify).
I'm running Maven 3.8.5
Please, any help is appreciated

Maven site fails while building javadoc

I try to build a site for my minecraft plugin but it fails during javadoc generation. I have my pom.xml and the log in this gist.
When I run mvn clean site it fails while generating javadoc because it does not find the dependencies used in my program. The problem is, that these dependencies are usually provided by the server, which tries to run the plugin so it does not make any sense to compile these dependencies. For some dependencies it is even forbidden to compile them. For example the spigot-api, which is part of the io.papermc.paper:paper-api-dependency.
And the weird thing is, it works just fine in IntelliJ. When I run the mvn clean site-command in IntelliJ using a run configuration it works just fine.
I already tried the additionalDependencies option but it did not improve the result.
I could stop it from failing the build by setting failOnError and failOnWarning to false but I still don't want these errors in my log.
Any ideas how to fix it?
Sincerely yours,
Trqhxrd

Maven - how to rebuild .xml files only on a Java EE project

As the title states.
I've made changes to .xml file only. Do I need to mvn clean install the whole project or a simple mvn install? Or maybe mvn generate-sources will do the stuff?
Can anyone elaborate?
To build the artifact, you need to call mvn package. If you do not do a clean, beware that remainders of the previous build might still exist. Changing the code of a class is generally fine, while changing the dependencies in the POM is not (you might end up with both versions of an artifact if you change the version in the POM).
Your hibernate case is somewhere in between, so you probably need to make experiments. Maven does not make any guarantees.

situations where clean install is a must not just install?

I have a question which is pretty straight forward, but hard to find an exact answer.
When we are using mvn build, what are the exact situation where we must go for clean install in order to see latest code changes in our built artifact. i.e. just install would not do that for us.
Thanks in advance.
Basically
mvn clean install
is same as
mvn clean && mvn install
so as to answer your question, its required when cleaning the files and directories generated by Maven is the primary requirement prior to doing another install.
Related to the changes in code, I would assume this is more of cleaning the target folder generated by Maven, hence mostly the files compiled would be overwritten when there is not much of a change.
In cases where one has removed/refactored a class from the previous build. There might be references still left if you don't clean and that would get packaged into the jar created thereafter.
From the official documentation(formatting mine) shared by ernest,
But if we try to build the project with mvn install without any clean lifecycle, then we see 2 bugs
the maven build still succeeds to compile the project maven even
generates a jar which contains broken classes
moduleB does not get recompiled and is thus broken as well.
Also, a preferably suggested way is to instead use
mvn verify

Maven rebuild failure of tests, build does not complete

I have a large project that I am working on. I recently checked out our evolution branch, did a git pull and tried to deploy the app locally. It doesn't seem to recognize some libraries or jars in one Java class, so subsequently errors halt me from running. Basically, the import statements go unrecognized in the class.
Turns out I forgot to rebuild maven. When I ran mvn clean install from the command prompt, the build fails (even when I do mvn clean install -fn) as there are tests that fail. I don't often work with maven, or the command line, but here is my full stack trace when I run mvn clean install -e:
I'm running my project in the IntelliJ environment.
When I ran mvn clean install -fn, 'talent-app' was successful, but talent-core still failed and I still got
[INFO] BUILD FAILURE
Please let me know if you have any input, I appreciate it!
I'm not sure I understand your question correctly.
Basically, regarding your first paragraph, you said you had library issues but that after a clean rebuild - of your project, I suppose not of Maven itself - everything is fine?
Regarding the rest of your post, your build is failing because of a failing test case. This is shown by the line:
talent-core ............................... FAILURE
and by the output:
Failed to execute goal [...]. There are test failures.
If you go into the target/surefire-reports folder, you will find some files containing the output and error traces of each test, including the one that failed.
By scrolling up in your terminal, you should also be able to see which test was failing for talent-core.
From then on, by order of preference:
either look at the test reports as mentioned in the output, and attempt to figure our why the test is failing, and either fix the test or the code;
or skip the tests, you can add -DskipTests to the command-line. But you shouldn't skip your tests, really.

Categories

Resources