I use apache tomcat as a server and container. A running application should "find" its source code and send it by mail. I am interested in how the application can be explained where or how to search for my code.
- and what do you collect war? - Mikhail Vaysman
- maven. project created at InteliJ Idea - Valery
|
2 answers
The source code is compiled and packaged, usually in a jar or war archive. T.ch. application can not find it at all desire.
But there is undoubtedly a way out of this situation - you can put this application together with the source code, putting it in the folder with resources.
If the maven build system then add the plugin:
<build> <plugins> ... <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-resources-plugin</artifactId> <version>2.3</version> </plugin> </plugins> <resources> <resource> <directory>src/main/java</directory> <includes> <include> **/*.java</include> </includes> </resource> </resources> ... </build> Further in the code itself use the following instruction:
InputStream input = getClass() .getResourceAsStream("/com/company/MySuperClass.java"); - And if dependencies? What about pom and project structure? - free_ze
- it is clear that everything is not so trivial. I gave only the direction to move. And the author takes the further rake of the path. - Artem Konovalov
|
You can add this plugin
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-war-plugin</artifactId> <configuration> <webResources> <resource> <directory>${build.sourceDirectory}</directory> <targetPath>WEB-INF/sources</targetPath> </resource> </webResources> </configuration> </plugin> and then the source code of your project will be located inside WEB-INF / sources. You will need to write a servlet or create a jsp to access it. Either change targetPath and move files to open access, but this is not correct from a security point of view.
|