|
1 | 1 | <?xml version="1.0" encoding="UTF-8"?> |
2 | | -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> |
| 2 | +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> |
3 | 3 | <modelVersion>4.0.0</modelVersion> |
4 | 4 |
|
5 | 5 | <parent> |
6 | 6 | <groupId>org.scijava</groupId> |
7 | 7 | <artifactId>pom-scijava</artifactId> |
8 | | - <version>30.0.0</version> |
| 8 | + <version>31.1.0</version> |
9 | 9 | <relativePath /> |
10 | 10 | </parent> |
11 | 11 |
|
|
179 | 179 | <language>ruby</language> |
180 | 180 | <script> |
181 | 181 | # Append the source plugin annotations to the test plugin annotations |
| 182 | + require 'set' |
| 183 | + |
182 | 184 | # Handle windows paths |
183 | 185 | basedir = '${project.basedir}'.gsub /\\+/, '\\\\' |
184 | | - sourceFile = basedir + '/target/classes/META-INF/json/org.scijava.plugin.Plugin' |
185 | | - destFile = basedir + '/target/test-classes/META-INF/json/org.scijava.plugin.Plugin' |
186 | | - File.open(sourceFile) do |input| |
187 | | - data_to_copy = input.read() |
188 | | - File.open(destFile, 'a') do |output| |
189 | | - output.write(data_to_copy) |
190 | | - end |
| 186 | + |
| 187 | + # Reads plugin metadata into a set of strings, one per plugin declaration. |
| 188 | + def read_plugins(path) |
| 189 | + delim = 'UNIQUE-SEQUENCE-THAT-NO-PLUGIN-WILL-EVER-USE' |
| 190 | + return File.exist?(path) ? File.read(path).sub('}{', '}' + delim + '{').split(delim).to_set : Set.new() |
| 191 | + end |
| 192 | + |
| 193 | + # Read in main and test scope plugin annotations. |
| 194 | + pluginsPath = 'META-INF/json/org.scijava.plugin.Plugin' |
| 195 | + mainPluginsPath = "#{basedir}/target/classes/#{pluginsPath}" |
| 196 | + testPluginsPath = "#{basedir}/target/test-classes/#{pluginsPath}" |
| 197 | + mainPlugins = read_plugins(mainPluginsPath) |
| 198 | + testPlugins = read_plugins(testPluginsPath) |
| 199 | + |
| 200 | + # Write out unioned plugin annotations to test scope plugin annotations. |
| 201 | + # Without this, the test scope code does not know of the main scope plugins. |
| 202 | + allPlugins = mainPlugins.union(testPlugins) |
| 203 | + unless allPlugins.empty?() |
| 204 | + require 'fileutils' |
| 205 | + FileUtils.mkdir_p File.dirname(testPluginsPath) |
| 206 | + File.write(testPluginsPath, allPlugins.to_a.join('')) |
191 | 207 | end |
192 | 208 | </script> |
193 | 209 | </configuration> |
|
205 | 221 | </plugins> |
206 | 222 | </pluginManagement> |
207 | 223 | </build> |
| 224 | + <profiles> |
| 225 | + <!-- |
| 226 | + This profile lets Eclipse M2E work with the script-maven-plugin. |
| 227 | + --> |
| 228 | + <profile> |
| 229 | + <id>only-eclipse-incubator</id> |
| 230 | + <activation> |
| 231 | + <property> |
| 232 | + <name>m2e.version</name> |
| 233 | + </property> |
| 234 | + </activation> |
| 235 | + <build> |
| 236 | + <pluginManagement> |
| 237 | + <plugins> |
| 238 | + <plugin> |
| 239 | + <groupId>org.eclipse.m2e</groupId> |
| 240 | + <artifactId>lifecycle-mapping</artifactId> |
| 241 | + <version>1.0.0</version> |
| 242 | + <configuration> |
| 243 | + <lifecycleMappingMetadata> |
| 244 | + <pluginExecutions> |
| 245 | + <!-- |
| 246 | + NB: Make Eclipse union the metadata indices on every build; see: |
| 247 | + https://www.eclipse.org/m2e/documentation/m2e-execution-not-covered.html |
| 248 | + --> |
| 249 | + <pluginExecution> |
| 250 | + <pluginExecutionFilter> |
| 251 | + <groupId>com.alexecollins.maven.plugin</groupId> |
| 252 | + <artifactId>script-maven-plugin</artifactId> |
| 253 | + <versionRange>${script-maven-plugin.version}</versionRange> |
| 254 | + <goals> |
| 255 | + <goal>execute</goal> |
| 256 | + </goals> |
| 257 | + </pluginExecutionFilter> |
| 258 | + <action> |
| 259 | + <execute> |
| 260 | + <runOnConfiguration>true</runOnConfiguration> |
| 261 | + <!-- |
| 262 | + NB: You might think we could run the annotations |
| 263 | + union script once only, at configuration time. |
| 264 | + Unfortunately, when configuration happens in Eclipse, |
| 265 | + the plugin annotations have not yet been generated. |
| 266 | + So let's redo the union on every incremental build. |
| 267 | + That'll show 'em! |
| 268 | + --> |
| 269 | + <runOnIncremental>true</runOnIncremental> |
| 270 | + </execute> |
| 271 | + </action> |
| 272 | + </pluginExecution> |
| 273 | + </pluginExecutions> |
| 274 | + </lifecycleMappingMetadata> |
| 275 | + </configuration> |
| 276 | + </plugin> |
| 277 | + </plugins> |
| 278 | + </pluginManagement> |
| 279 | + </build> |
| 280 | + </profile> |
| 281 | + </profiles> |
208 | 282 | </project> |
0 commit comments