How to generate compiled classes and maintain the. java in Maven?

Asked

Viewed 274 times

3

Guys every time I do Maven install it compiles the classes and generates the xxx.class, so far so good. I would like to know if it is possible to generate . class and also keep all . java, in the application I am doing I will need to show the page and the example code made to create the same logo wanted to read and catch by stream the . java and show on screen.

My problem is that I only have the . class after the install Maven, someone could help me?

1 answer

2


Include the following Resource in the pom.xml:

    <resource>
        <directory>${basedir}/src/main/java</directory>
    </resource>

See more or less how it would look in the general structure of the archive:

<project>
    ...
        <build>
            ...
                 <resources>
                    <resource>
                        <directory>${basedir}/src/main/java</directory>
                    </resource>
                </resources>
        </build>
</project>

If you want to know more about the plugin Resources: https://maven.apache.org/plugins/maven-resources-plugin/

And when you need to consult the general structure of the file to know where a section or plugin can be configured: https://maven.apache.org/guides/introduction/introduction-to-the-pom.html

  • friend, putting this it will generate the . java in this directory ?

  • @Marcusvinicius No. It will copy ("generate") the . java of this local for the destination location of the build. In practice, the files .java will be at destination along with their respective files .class. Take the test. Try!

  • Worked out here, thank you same guy saved my life hehe.

  • Need something too just call me, hug.

  • @Marcusvinicius You can vote and accept the answers that "saved your life" :-)

  • I will vote hehe, in vdd another problem arose, he Gero o . java, I gave a Maven install and saw it, but when I go up the widfly, with this configuration in pom it gives me this error java.lang.Runtimeexception: java.lang.Illegalargumentexception: is Parameter must not be null java.lang.Runtimeexception: java.lang.Illegalargumentexception: is Parameter must not be null

  • @Marcusvinicius I tested here and for me it worked normal in Wildfly. Must be some other problem. Try to remove the configuration without making any other changes, clean the project and install and deploy again - I believe the error will persist (because it is related to something else and not to this configuration).

  • You’re right man, it was a mistake right here, it worked out what you say hehe, how I vote they saved my life?

  • friend, you know why when I put this setting my . xml in meta-inf vanish ?

  • @Marcusvinicius And then, problem solved?

Show 5 more comments

Browser other questions tagged

You are not signed in. Login or sign up in order to post.