Maven compiles deleted files - maven

I'm using IntelliJ and Maven. ANTLR has generated some files, I have deleted them and then generated new ones, now every time I clean and compile, Maven will generate the old files but not the new files... Any ideas, please? How is that possible? Those old files are not anywhere in the project anymore.

Activate more logs with a mvn -X clean install: you will see that way which files the ANTLR uses for its AST transformations.
The idea is to check that it is applied on the right source files.

Related

Building open source dependencies using gradle

I really don't have much experience in developing let alone using build tools.
I was assigned a task to build dependencies locally and get the jar files.
say I have a list of deps (GAV) like this:-
1. org.jetbrains.kotlin:kotlin-stdlib:1.6.0-RC
2. com.auth0:java-jwt:3.18.2, etc
3. openapi4j:openapi-operation-validator:1.0.7, etc
So i was able to download the source code url from maven repository and source code from github programmatically, for example :-
org.jetbrains.kotlin:kotlin-stdlib:1.6.0-RC - https://github.com/JetBrains/kotlin
com.auth0:java-jwt:3.18.2 - https://github.com/auth0/java-jwt
openapi4j-openapi-operation-validator-1.0.7 https://github.com/openapi4j/openapi4j
but there are many build.gradle files in different directories, how do I know which directory should I move into before running the gradle build command.
Things I have already tried and failed:-
For deps like this openapi4j:openapi-operation-validator:1.0.7, i can directly go into the openapi-operation-validator folder in the Github repo (https://github.com/openapi4j/openapi4j ) and run the gradle build command, but not all projects are structured like that I guess?
For deps like this com.auth0:java-jwt:3.18.2, the artifactId (java-jwt
) is already present in the github path (https://github.com/auth0/java-jwt), so i can run the gradle build command on the root github repo.
From the spring guides , among all the Gradle.build files available I can check which file has:-
jar {
archiveBaseName = <artifactId>
archiveVersion = <version>
}
, then I can move to that dir and run Gradle build, but not all build.gradle files have this.
None of the above approaches are concrete, is there any other firm approach that I can use to tackle the problem?
Your approach is generally correct.
You need to find the source code in github/gitlab/wherever, read the readme file and try to build it with whatever build tool was used there.
This may or may not work.

Can i make changes to a file in maven builded without building it again?

I am having a maven project where it will build and run through JBOSS. But every time I make a change in any of the project files, I have to build the whole code again which will give a .war file. Is there a way to change the files without having to build the code again?
No.
There may be a way to test your code changes without running a full Maven build, but you cannot change the resulting WAR without rebuilding it.

How is this timestamp file generated from maven build?

I was working on a maven project and this project is generating some weird file.
The file name are like:
[PROJECT]/target/classes.531226305.timestamp
[PROJECT]/target/classes.1241815416.timestamp
[PROJECT]/target/test-classes.-1983166104.timestamp
And the content of the file are only a .(dot) inside it. Anyone has any idea of how this is generated? Thanks!
Does the project use the scala-maven-plugin? The scala-maven-plugin adds ".<hashcode>.timestamp" to files in the target directory. It's used for the incremental compile feature that is available for that plugin.

Problems with Maven default folder

I'm Mohave Mac User.
I installed Maven and created project in Eclipse. Name of the project is "Mavenjava".
When I try to clean, compile, test command from Eclipse it doesn't work because it looking for a POM file in /User/Max/, not from /User/Max/Mavenjava
When I copy my POM file into /User/Max/ - "clean" command works but I can't do "compile" and "test" commands in terminal, because I see mistake like "skip non existing resourceDirectory".
It is still looking this files here /Users/Max/src/main/resources, but not in /User/Max/Mavenjava/src/main/resoursces/
How I could change default folders for Maven?
I spent 3 hours and don't know how to solve this problem.

Maven - Remove Generated Folders

I'm using the maven-compiler plugin to generate my .jar
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.2</version>
When I do a clean install it will generate folders such as "generated-sources", "maven-archiver", "maven-status" amd "classes" in addition to my .jar
How could I automatically deleted those folders after the install or prevent them from being generated?
You cannot prevent those folders from being generated as they are essential to making the build work. generated-sources most likely contains Java source code that was generated during the build and is needed to make the rest of the code compile; classes contains the compiled Java source code that was under src/main/java and is needed to make a subsequent JAR or WAR, etc. So, without those folders, the build cannot properly work.
However, they are inherently temporary. In fact, the whole target folder is temporary. It contains data that is generated / copied at build-time and is needed to make the final artifacts. This is why it is generally a good idea to always clean before building a Maven project: it makes sure that this build folder is cleaned so that new fresh data is created (otherwise, it might rely on old build data, potentially making hard to track down bugs).
Once the final artifacts are created, they will be the only one to be considered when installing or deploying the project. If you really want to get rid of those files after the build (but I don't see why), you could always run mvn clean install clean. This will delete the target folder once the project's artifacts are installed.

Resources