3

I have an IntelliJ Maven project. Currently, IntelliJ copies resources (such as .js, .css) to the target directory when I debug/run a Tomcat/Jetty configuration. How do I modify IntelliJ to create symbolic links instead of copying files? If this isn't possible with a setting, what does the source code of a plugin look like that provides this behavior?

For example, IntelliJ takes a file like /project/src/main/webapp/js/file.js and copies it to /project/target/war_path/js/file.js.

This is an IntelliJ project backed by a Maven project using the maven-war-plugin. I don't know if this would require changes to Maven also?

There is an annoying delay in IntelliJ that I'm trying to avoid when I modify a resource and hit refresh in a browser. I want the file to be live.

Josh Unger
  • 6,717
  • 6
  • 33
  • 55

2 Answers2

1

I was able to add a Maven plugin to generate a symbolic link. However, there is a bug I'm trying to track down that clears the content of the files if you have them open in Chrome and then automatically build on the IntelliJ. If you figure out the issue, please post it or edit this post.

<plugin>
    <groupId>com.pyx4j</groupId>
    <artifactId>maven-junction-plugin</artifactId>
    <version>1.0.3</version>
    <executions>
        <execution>
            <phase>generate-sources</phase>
            <goals>
                <goal>link</goal>
            </goals>
        </execution>
    </executions>
    <configuration>
        <links>
            <link>
                <!-- add allowLinking="true" to Tomcat's conf/Context.xml; also, disable update in Edit Configuration on frame deactiviation -->
                <dst>${project.build.directory}/${project.build.finalName}/js</dst>
                <src>${basedir}/src/main/webapp/js</src>
            </link>
        </links>
    </configuration>
</plugin>
Josh Unger
  • 6,717
  • 6
  • 33
  • 55
0

Just posted this that may help you as was faced with the same issues you describe in your quetion - Is real time change feedback with Spring/Tomcat/Intellij possible?

Community
  • 1
  • 1
Mannie
  • 1,608
  • 1
  • 21
  • 33
  • Thanks, I'll check it out. I was able to create a symbolic link using a Maven plugin. Check out my answer, this may help you. – Josh Unger Mar 14 '14 at 14:30