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.

View | Details | Raw Unified | Return to bug 223682
Collapse All | Expand All

(-)a/maven/arch.xml (+20 lines)
Lines 169-172 Link Here
169
 </answer>
169
 </answer>
170
170
171
171
172
 <answer id="exec-property">
173
  <p>
174
      <api category="devel" group="property" name="dont.use.jdk.bootclasspath" type="export">
175
          The maven support recognizes special tag in <q>maven-compiler-plugin</q> configuration
176
          that instructs the IDE to <em>not</em> put JDK libraries on a classpath. One can use:<pre>
177
    &lt;plugin&gt;
178
        &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
179
        &lt;artifactId&gt;maven-compiler-plugin&lt;/artifactId&gt;
180
        &lt;configuration&gt;
181
            &lt;compilerArguments&gt;
182
                &lt;bootclasspath&gt;dont.use.jdk.bootclasspath&lt;/bootclasspath&gt;
183
            &lt;/compilerArguments&gt;
184
        &lt;/configuration&gt;
185
    &lt;/plugin&gt;
186
          </pre>
187
          section in <code>pom.xml</code> to <em>suppress</em> the JDK libraries.
188
      </api>
189
  </p>
190
 </answer>
191
172
</api-answers>
192
</api-answers>
(-)a/maven/src/org/netbeans/modules/maven/classpath/BootClassPathImpl.java (-4 / +6 lines)
Lines 94-104 Link Here
94
        synchronized (LOCK) {
94
        synchronized (LOCK) {
95
            if (this.resourcesCache == null) {
95
            if (this.resourcesCache == null) {
96
                ArrayList<PathResourceImplementation> result = new ArrayList<PathResourceImplementation> ();
96
                ArrayList<PathResourceImplementation> result = new ArrayList<PathResourceImplementation> ();
97
                result.addAll(ecpImpl.getResources());
97
                boolean[] includeJDK = { true };
98
                result.addAll(ecpImpl.getResources(includeJDK));
98
                lastHintValue = project.getAuxProps().get(Constants.HINT_JDK_PLATFORM, true);
99
                lastHintValue = project.getAuxProps().get(Constants.HINT_JDK_PLATFORM, true);
99
               
100
                if (includeJDK[0]) {
100
                for (ClassPath.Entry entry : findActivePlatform().getBootstrapLibraries().entries()) {
101
                    for (ClassPath.Entry entry : findActivePlatform().getBootstrapLibraries().entries()) {
101
                    result.add(ClassPathSupport.createResource(entry.getURL()));
102
                        result.add(ClassPathSupport.createResource(entry.getURL()));
103
                    }
102
                }
104
                }
103
                resourcesCache = Collections.unmodifiableList (result);
105
                resourcesCache = Collections.unmodifiableList (result);
104
            }
106
            }
(-)a/maven/src/org/netbeans/modules/maven/classpath/EndorsedClassPathImpl.java (+10 lines)
Lines 108-119 Link Here
108
    }
108
    }
109
109
110
    public @Override List<? extends PathResourceImplementation> getResources() {
110
    public @Override List<? extends PathResourceImplementation> getResources() {
111
        boolean[] arr = { false };
112
        return getResources(arr);
113
    }
114
    
115
    final List<? extends PathResourceImplementation> getResources(boolean[] includeJDK) {
111
        assert bcp != null;
116
        assert bcp != null;
112
        synchronized (bcp.LOCK) {
117
        synchronized (bcp.LOCK) {
113
            if (this.resourcesCache == null) {
118
            if (this.resourcesCache == null) {
114
                ArrayList<PathResourceImplementation> result = new ArrayList<PathResourceImplementation> ();
119
                ArrayList<PathResourceImplementation> result = new ArrayList<PathResourceImplementation> ();
115
                String[] boot = getBootClasspath();
120
                String[] boot = getBootClasspath();
116
                if (boot != null) {
121
                if (boot != null) {
122
                    for (String b : boot) {
123
                        if ("dont.use.jdk.bootclasspath".equals(b)) {
124
                            includeJDK[0] = false;
125
                        }
126
                    }
117
                    for (URL u :  stripDefaultJavaPlatform(boot)) {
127
                    for (URL u :  stripDefaultJavaPlatform(boot)) {
118
                        result.add (ClassPathSupport.createResource(u));
128
                        result.add (ClassPathSupport.createResource(u));
119
                    }
129
                    }
(-)a/maven/test/unit/src/org/netbeans/modules/maven/classpath/ClassPathProviderImplTest.java (+40 lines)
Lines 176-181 Link Here
176
        assertRoots(cp);
176
        assertRoots(cp);
177
        assertFalse(bcp.toString(), bcp.toString().contains("override.jar"));
177
        assertFalse(bcp.toString(), bcp.toString().contains("override.jar"));
178
    }
178
    }
179
    
180
    public void testDontIncludeJDK() throws Exception {
181
        TestFileUtils.writeFile(d,
182
                "pom.xml",
183
                "<project xmlns='http://maven.apache.org/POM/4.0.0'>" +
184
                "<modelVersion>4.0.0</modelVersion>" +
185
                "<groupId>grp</groupId>" +
186
                "<artifactId>art</artifactId>" +
187
                "<packaging>jar</packaging>" +
188
                "<version>1.0-SNAPSHOT</version>" +
189
                "<name>Test</name>" +
190
                "<build>\n" +
191
                "  <plugins>\n" +
192
                "    <plugin>\n" +
193
                "      <groupId>org.apache.maven.plugins</groupId>\n" +
194
                "      <artifactId>maven-compiler-plugin</artifactId>\n" +
195
                "      <version>2.3.2</version>\n" +
196
                "      <configuration>\n" +
197
                "        <compilerArguments>\n" +
198
                "          <bootclasspath>dont.use.jdk.bootclasspath</bootclasspath>\n" +
199
                "        </compilerArguments>\n" +
200
                "      </configuration>\n" +
201
                "    </plugin>\n" +
202
                "  </plugins>\n" +
203
                "</build>\n" +
204
                "</project>"
205
        );
206
        FileObject src = FileUtil.createFolder(d, "src/main/java");
207
        ClassPath cp = ClassPath.getClassPath(src, ClassPath.BOOT);
208
        assertNotNull(cp);
209
        for (FileObject fo : cp.getRoots()) {
210
            if (fo.getNameExt().equals("rt.jar")) {
211
                fail("We don't want rt.jar on boot classpath: " + fo);
212
            }
213
            FileObject archive = FileUtil.getArchiveFile(fo);
214
            if (archive != null && archive.getNameExt().equals("rt.jar")) {
215
                fail("We don't want rt.jar on boot classpath: " + archive);
216
            }
217
        }
218
    }
179
219
180
    private static void assertRoots(ClassPath cp, FileObject... files) {
220
    private static void assertRoots(ClassPath cp, FileObject... files) {
181
        assertNotNull(cp);
221
        assertNotNull(cp);

Return to bug 223682