Changelog path resolving in Liquibase maven plugin - java

I've got one problem with liquibase-maven-plugin 4.2.2. If I specify the path to logs like it was before
changeLogFile= classpath:db/changelog/db.changelog-master.xml
I'm getting an error
Error Reading Changelog File: Found 2 files that match classpath:db/changelog/db.changelog-master.xml: jar:file:/Users/macbook/IdeaProjects/geek-study-eshop/shop-database/target/shop-database-1.0-SNAPSHOT.jar!/db/changelog/db.changelog-master.xml, file:/Users/macbook/IdeaProjects/geek-study-eshop/shop-database/target/classes/db/changelog/db.changelog-master.xml
I understand the reason for this error and it possible to resolve it by changing changeLogFile to target/db/changelog/db.changelog-master.xml. But in this case, I will have target\ prefix in filenames stored in DATABASECHANGELOG table. But I don't want that for some reasons. I want all file names there to be with prefix db/changelog/... or classpath:db/changelog/.... Is that possible to do that somehow without using logicFilePath attribute?

I found the solution! There is no way to change liquibase-maven-plugin behavior but it's possible to change maven phase on which we run liquibase:diff command. Simply use mvn clean compile liquibase:diff! We are doing diff after compilation and resource movement but before the jar packaging.

Related

Error during SonarScanner execution after executing SonarScanner.MSBuild.exe end command

Sonarqube Version -7.9.5
SonarQube Scanner - sonar-scanner-msbuild-5.0.4.24009-net46
Source code contains - C#, angular.js, html5, javascript.
Hi,
I executed the following commands and after executing the 3rd command I am getting execution failure error.
The command I executed in the CMD prompt are browsing to the path where solution is present are,
SonarScanner.MSBuild.exe begin /k:"Demo" /d:sonar.host.url="http://localhost:9000" /d:sonar.login="TokenID_ABC"
MsBuild.exe /t:Rebuild
SonarScanner.MSBuild.exe end /d:sonar.login="TokenID_ABC"
ERROR: Error during SonarScanner execution
org.sonar.java.AnalysisException: Please provide compiled classes of your project with sonar.java.binaries property
I found one similar kind of issue reported where it is said that due to .java file present in the code the issue occurs, in our code as well .java files are present, not sure the use of them. How can I exclude those .java files while SonarQube analysis is performed and in which file do I need to add exclusion code?
Also, if there is some another solution to resolve this issue, then please let me know as I have very limited knowledge of Sonar.
Link of similar issue -
https://community.sonarsource.com/t/error-while-running-sonar-scanner-please-provide-compiled-classes-of-your-project-with-sonar-java-binaries-property/30027/2
You can exclude arbitrary files by going to your project settings in SonarQube -> Analysis Scope -> Source File Exclusions. Use regex to match your java files, i.e. *.java.

Optaplanner - Error when running executable jar but works fine from eclipse

I use eclipse for my optaplanner project development and I am able to execute my code from eclipse without any problem. To make this project as an executable, I exported it as a jar file using eclipse export wizard.
Then I run my jar from terminal using the command java -jar myOptaPlanner.jar, then, I get below error
WARN given scan urls are empty. set urls in the configuration
Exception in thread "main" java.lang.IllegalStateException: The scanAnnotatedClasses
(ScanAnnotatedClassesConfig()) did not find any classes with a PlanningSolution
annotation.
Maybe you forgot to annotate a class with a PlanningSolution annotation.
Maybe you're using special classloading mechanisms (OSGi, ...) and this is a bug.
If you can confirm that, report it to our issue tracker and workaround it by
defining the classes explicitly in the solver configuration.
at org.optaplanner.core.config.domain.ScanAnnotatedClassesConfig.loadSolutionClass(ScanAnnotatedClassesConfig.java:106)
at org.optaplanner.core.config.domain.ScanAnnotatedClassesConfig.buildSolutionDescriptor(ScanAnnotatedClassesConfig.java:86)
at org.optaplanner.core.config.solver.SolverConfig.buildSolutionDescriptor(SolverConfig.java:270)
at org.optaplanner.core.config.solver.SolverConfig.buildSolver(SolverConfig.java:216)
at org.optaplanner.core.impl.solver.AbstractSolverFactory.buildSolver(AbstractSolverFactory.java:57)
at org.roster.app.WorkerRosteringApp.main(WorkerRosteringApp.java:36)
Is this really a bug or am I exporting it wrong?
Update: I tried to export jar using maven-shade-plugin and here also I am getting the same error.
Thanks
scanAnnotatedClasses doesn't seem to work in a jar file. Instead, use following workaround:
<solutionClass>path.to.your.SolutionClass</solutionClass>
<entityClass>path.to.your.EntityClassI</entityClass>
<entityClass>path.to.your.EntityClassII</entityClass>
and delete the scanAnnotatedClasses in your config file.
If you don't want to declare the solution and entity classes manually, including the packages containing the solution and entity classes also works as workaround:
<scanAnnotatedClasses>
<packageInclude>your.package.here</packageInclude>
</scanAnnotatedClasses>
Documentation about <packageInclude> can be found here

Specifying a forward lookup jar in ant file

I need some help in compiling my java project through an ANT file.
Lets there are five subproject in my complete project.
Each subproject has its own ant file to compile it.
for example:
subprojectA
subprojectB
subprojectC
subprojectD
subprojectE
Now the situation is :
I am using some classes of "subprojectC" in "subprojectA" but as my compilation sequence is 1,2 3,4,5, I am getting error as class can not be resolved while compiling subprojectA.
So, the question is, is it possible to somehoe specify or tell ANT file of "subprojectA" that these classes will be present in future in suppose jarx.
I am looking some kind of forward lookup in ant file.
Thank You

Jackson library error calling 'writeValue' function

I'm trying to use Jackson for converting string to JSON object in java. I have both jar file and maven project of the library, with which I tried one by one but both giving error while calling writeValue function. Error says -
The type com.fasterxml.jackson.core.JsonGenerator cannot be resolved. It is indirectly referenced from required .class files
I have correctly added the library to build path.
After looking at eclipse-error-indirectly-referenced-from-required-class-files ,I realized that the problem is because of missing com.fasterxml.jackson.core.JsonGenerator class file.So Which jar file I missed to add to build path?. Tried by adding the maven project on build path too- same error.
To find which jar contains the required file, you can always use http://search.maven.org and search for the class prefixing it with fc:, like this:
http://search.maven.org/#search%7Cga%7C1%7Cfc%3Acom.fasterxml.jackson.core.JsonGenerator
Looks like you're missing jackson-core jar on your classpath.
Make sure that you have in your path jackson-databind and jackson-core
build path is used during compile. You need to set up the Deployment Assembly for run time classpath (under project settings, look for Deployment Assembly )

An ERROR occurred in archiving the artifacts

When I type "build*.jar" into Files to archive filed in Archive the artifacts, the warning red message "build*.jar' doesn't match anything: 'build' exists but not 'build*.jar" appears.
After I ignore it and build, the following ERROR occurred:
Archiving artifacts
ERROR: No artifacts found that match the file pattern "build\*.jar". Configuration error?
ERROR: 'build\*.jar' doesn't match anything: 'build' exists but not 'build\*.jar'
Build step 'Archive the artifacts' changed build result to FAILURE
Finished: FAILURE
If you want to totally ignore the artifact part, you can select the Do not fail build if archiving returns nothing option in Jenkins Post-build Actions > Archive the artifacts > Advanced settings.
Please check if build is a direct folder within your Jenkins Project workspace. For example if , target is a direct folder with your project workspace, target\*.jar will archive all the jars within the target folder. Also, please try clicking on the ? for more details
What's probably happening is that \ is escaping * and it's looking for literally the file named build*.jar.
I assume you are on Windows, hence you are using \ separator. However most Windows versions support /. Try that first:
build/*.jar
If that doesn't work, you can try escaping \ in the first place:
build\\*.jar

Categories

Resources