[ help / maven ] - Calling ${version} to plugin.yml

Discussion in 'Plugin Development' started by WinneonSword, Sep 22, 2013.

Thread Status:
Not open for further replies.
  1. Offline

    WinneonSword

    Hello,

    Here is my situation. I want to take the ${version} from pom.xml and put it into plugin.yml and also I can call ${version} in a string in any of my classes and it replaces it with the project version, so I can control the version number globally just from the pom.xml. I know this is possible due to the fact that VanishNoPacket does this. Here is my pom.xml if you must know:

    Show Spoiler

    Code:java
    1. <project xmlns="[url]http://maven.apache.org/POM/4.0.0[/url]" xmlns:xsi="[url]http://www.w3.org/2001/XMLSchema-instance[/url]" xsi:schemaLocation="[url]http://maven.apache.org/POM/4.0.0[/url] [url]http://maven.apache.org/xsd/maven-4.0.0.xsd[/url]">
    2. <modelVersion>4.0.0</modelVersion>
    3. <groupId>JoinMessages</groupId>
    4. <artifactId>JoinMessages</artifactId>
    5. <version>1.3.1-a</version>
    6. <name>JoinMessages</name>
    7. <url>[url]http://github.com/WinneonSword/Join-Messages</url>[/url]
    8. <properties>
    9. <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    10. <jm-version>${project.version}</jm-version>
    11. </properties>
    12. <dependencies>
    13. <dependency>
    14. <groupId>junit</groupId>
    15. <artifactId>junit</artifactId>
    16. <version>3.8.1</version>
    17. <scope>test</scope>
    18. </dependency>
    19. <dependency>
    20. <groupId>org.bukkit</groupId>
    21. <artifactId>bukkit</artifactId>
    22. <version>1.6.4-R0.1-SNAPSHOT</version>
    23. </dependency>
    24. <dependency>
    25. <groupId>CMAPI</groupId>
    26. <artifactId>CMAPI</artifactId>
    27. <scope>system</scope>
    28. <version>1.0</version>
    29. <systemPath>${basedir}\src\lib\CMAPI.jar</systemPath>
    30. </dependency>
    31. <dependency>
    32. <groupId>VanishNoPacket</groupId>
    33. <artifactId>VanishNoPacket</artifactId>
    34. <scope>system</scope>
    35. <version>1.0</version>
    36. <systemPath>${basedir}\src\lib\VanishNoPacket.jar</systemPath>
    37. </dependency>
    38. <dependency>
    39. <groupId>Vault</groupId>
    40. <artifactId>Vault</artifactId>
    41. <scope>system</scope>
    42. <version>1.0</version>
    43. <systemPath>${basedir}\src\lib\Vault.jar</systemPath>
    44. </dependency>
    45. </dependencies>
    46. <repositories>
    47. <repository>
    48. <id>bukkit-repo</id>
    49. <url>[url]http://repo.bukkit.org/content/repositories/snapshots/</url>[/url]
    50. </repository>
    51. </repositories>
    52. <build>
    53. <sourceDirectory>src</sourceDirectory>
    54. <plugins>
    55. <plugin>
    56. <groupId>org.apache.maven.plugins</groupId>
    57. <artifactId>maven-shade-plugin</artifactId>
    58. <version>2.1</version>
    59. <executions>
    60. <execution>
    61. <phase>package</phase>
    62. <goals>
    63. <goal>shade</goal>
    64. </goals>
    65. <configuration>
    66. <finalName>${artifactId}v${project.version}</finalName>
    67. <artifactSet>
    68. <includes>
    69. <include>*</include>
    70. </includes>
    71. <excludes>
    72. <exclude>org.bukkit:bukkit</exclude>
    73. </excludes>
    74. </artifactSet>
    75. </configuration>
    76. </execution>
    77. </executions>
    78. </plugin>
    79. <plugin>
    80. <groupId>org.apache.maven.plugins</groupId>
    81. <artifactId>maven-compiler-plugin</artifactId>
    82. <configuration>
    83. <source>1.7</source>
    84. <target>1.7</target>
    85. </configuration>
    86. </plugin>
    87. </plugins>
    88. <resources>
    89. <resource>
    90. <directory>src/main/resources</directory>
    91. <filtering>true</filtering>
    92. </resource>
    93. </resources>
    94. </build>
    95. </project>

     
  2. Offline

    tommykins20

    Bump.
    Sorry for the bump but I have been struggling with the same issue. Also, has this already been solved, OP?
     
  3. Offline

    Wolvereness Bukkit Team Member

  4. Offline

    tommykins20

    Thank you very much for your reply Wolvereness but I feel really silly now because after I posted the reply I dug a little deeper in my Google search and found the <filtering> tag on Apache's website. But thank you very much for your reply. It will hopefully help other developers too! :)
     
  5. Offline

    jflory7

    Does anyone know how to do this now? Sorry for the bump, but I noticed Wolverness's code is offline and I was trying to figure out how to do this as well.

    Something about <filtering>? Not sure I understand.

    Edit: For further clarification, I am not trying to do this in my plugin.yml, but rather in my actual class file. I'm not sure if it would be easier to call the information from the plugin.yml, which in turn is called from the pom.xml, or if it can be called directly from the POM file. Thanks!
     
    Last edited: Jan 8, 2015
  6. Offline

    1Rogue Retired Staff

    Use maven shade for yaml files. IMO using maven to filter java files is a little... screwy and unpredictable
     
  7. Offline

    jflory7

Thread Status:
Not open for further replies.

Share This Page