This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 248093 - Compile on save does not work with profiles specifying <webResources>
Summary: Compile on save does not work with profiles specifying <webResources>
Status: REOPENED
Alias: None
Product: javaee
Classification: Unclassified
Component: Maven (show other bugs)
Version: 8.0.1
Hardware: PC Mac OS X
: P3 normal (vote)
Assignee: Martin Janicek
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-10-22 08:27 UTC by brettryan
Modified: 2016-07-08 11:26 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description brettryan 2014-10-22 08:27:33 UTC
Given a maven project that has a custom profile that specifies additional resource paths the compile on save facility does not work when that profile is active.

Consider the following profile:

    <profile>
      <id>dev</id>
      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-war-plugin</artifactId>
            <version>2.4</version>
            <configuration>
              <webResources>
                <resource>
                  <directory>src/dev/resources</directory>
                </resource>
              </webResources>
            </configuration>
          </plugin>
        </plugins>
      </build>
    </profile>

Saving a file in the src/main/webapp/WEB-INF/ path or descendants will not initiate CoS, disable the profile and CoS works as expected.

I can imagine why the additional resources could be harder to manage, however since this condition relates to web resources directly (not classpath resources) I would imagine that it shouldn't be affected.
Comment 1 brettryan 2014-10-22 08:30:20 UTC
One note that could be of interest is the resource path that I have included (as an additional path) includes a file that does target WEB-INF/. In fact there is the single file src/dev/resources/WEB-INF/spring/app-security-impl.xml
Comment 2 Martin Balin 2016-07-07 08:54:51 UTC
This old bug may not be relevant anymore. If you can still reproduce it in 8.2 development builds please reopen this issue.

Thanks for your cooperation,
NetBeans IDE 8.2 Release Boss
Comment 3 brettryan 2016-07-08 11:26:54 UTC
While it does appear that the primary resources will now activate CoS, this appears to now be even more dangerous than previously.

If you have an active profile as mentioned in my OP where your profile overrides a default resource, if you modify the primary resource while the project is running it will actually copy that resource over the already deployed overridden resource.

Steps to Reproduce
==================

1. Create a project with a profile as described below where the profile defines additional resource paths that contain same named files as the default profile.

  <profiles>

    <profile>
      <id>default</id>
      <activation>
        <activeByDefault>true</activeByDefault>
      </activation>
    </profile>

    <profile>
      <id>dev-remote</id>
      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-war-plugin</artifactId>
            <version>2.4</version>
            <configuration>
              <webResources>
                <resource>
                  <directory>src/remotedev/resources</directory>
                  <targetPath>/</targetPath>
                </resource>
              </webResources>
            </configuration>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>

2. Create a file "test.jsp" for both profiles, both with differing content.
3. Activate profile `remote-dev`
4. Run the project
5. Confirm that the test.jsp from `remote-dev` is present in the build
6. Make a change to the default `test.jsp`


Expected Behaviour
==================

Modification of original `test.jsp` should not be present after CoS.


Actual Behaviour
================

`test.jsp` from default profile will overwrite the active profiles version.