matthiasblaesing commented on issue #1209: Interpret profiles and property definitions from .mvn/maven.config when present URL: https://github.com/apache/netbeans/pull/1209#issuecomment-489366309 I extended the unittest a bit and I think it misses cases, and thus the parser also misses cases: - long argument names (I would consider it good practice to use these in config files) - spaces between short option character and value - multiple profiles separated by coma I think this should cover most cases, though is is still missing the handling of quote characters and disabled profiles. ```diff --- a/java/maven/test/unit/src/org/netbeans/modules/maven/NbMavenProjectImplTest.java +++ b/java/maven/test/unit/src/org/netbeans/modules/maven/NbMavenProjectImplTest.java @@ -32,9 +32,11 @@ import org.netbeans.api.project.ProjectManager; import org.netbeans.junit.NbTestCase; import org.netbeans.junit.RandomlyFails; +import org.netbeans.modules.maven.api.NbMavenProject; import org.netbeans.modules.projectapi.nb.TimedWeakReference; import org.netbeans.spi.project.LookupMerger; import org.netbeans.spi.project.ProjectServiceProvider; +import org.netbeans.spi.project.ProjectState; import org.openide.filesystems.FileObject; import org.openide.filesystems.FileUtil; import org.openide.filesystems.test.TestFileUtils; @@ -149,7 +151,10 @@ + "<properties><java>1.5</java></properties>" + "<build><plugins><plugin><artifactId>maven-compiler-plugin</artifactId><version>2.1</version>" + "<configuration><source>${java}</source></configuration></plugin></plugins></build>" - + "<profiles><profile><id>new</id><properties><java>1.6</java></properties></profile></profiles>" + + "<profiles>" + + "<profile><id>new</id><properties><java>1.6</java></properties></profile>" + + "<profile><id>new2</id><properties><java>1.6</java></properties></profile>" + + "</profiles>" + "</project>"); FileObject source = TestFileUtils.writeFile(wd, "src/main/java/p/C.java", "package p; class C {}"); ((NbMavenProjectImpl) ProjectManager.getDefault().findProject(wd)).attachUpdater(); @@ -158,9 +163,25 @@ TestFileUtils.writeFile(wd, ".mvn/maven.config", "-Pnew"); assertEquals("1.6", slqr.getSourceLevel()); wd.getFileObject(".mvn/maven.config").delete(); + TestFileUtils.writeFile(wd, ".mvn/maven.config", "-P new"); + assertEquals("1.6", slqr.getSourceLevel()); + wd.getFileObject(".mvn/maven.config").delete(); + TestFileUtils.writeFile(wd, ".mvn/maven.config", "--activate-profiles new"); + assertEquals("1.6", slqr.getSourceLevel()); + wd.getFileObject(".mvn/maven.config").delete(); + TestFileUtils.writeFile(wd, ".mvn/maven.config", "--activate-profiles new,new2"); + assertEquals("1.6", slqr.getSourceLevel()); + wd.getFileObject(".mvn/maven.config").delete(); assertEquals("1.5", slqr.getSourceLevel()); TestFileUtils.writeFile(wd, ".mvn/maven.config", "-Djava=1.7"); assertEquals("1.7", slqr.getSourceLevel()); + wd.getFileObject(".mvn/maven.config").delete(); + TestFileUtils.writeFile(wd, ".mvn/maven.config", "-D java=1.7"); + assertEquals("1.7", slqr.getSourceLevel()); + wd.getFileObject(".mvn/maven.config").delete(); + TestFileUtils.writeFile(wd, ".mvn/maven.config", "--define java=1.7"); + assertEquals("1.7", slqr.getSourceLevel()); + wd.getFileObject(".mvn/maven.config").delete(); } } ```
---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected] With regards, Apache Git Services --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected] For further information about the NetBeans mailing lists, visit: https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
