Placeholder substitution in a Maven APT page - maven

I am working on Maven site documentation for some related projects, and I want to create a hyperlink from one site's documentation to another sites documentation. The wrinkle is that the URL for the link target depends on a Maven property.
I tried this:
{{{http://example.com/site/project-${some-prop}/some.html}the documentation}}
but the ${some-prop} placeholder doesn't get replaced, and the APT processor then gets
confused by the first '}'. Escaping the { and } characters (e.g. $\{some-prop\} ) doesn't help, and the following doesn't work either:
{{http://example.com/site/project-${some-prop}/some.html}}
Is there some other way that I can accomplish this task? For example, is there a way to define a Doxia macro that could be used to substitute a URL that had the placeholder expanded?

Are you using version 2.0-beta-6 or later of the site plugin? Also, does your apt filename ends with a .vm extension (as described in the filtering section of Creating Content?

Related

Where is the site.vm of the maven-default-skin?

When I run mvn site with no site.xml on a simple Maven project (meaning it will use the maven-default-skin) which site.vm file site used?
I have looked into maven-site-plugin, maven-project-info-reports-plugin, maven-doxia-sitetools and of course maven-default-skin, but I could not find it anywhere.
For the maven-fluido-skin, I can find the site.vm in src/main/resources/META-INF/maven. But there is no such file for maven-default-skin.
When using maven-site-plugin 4.0.0-M3, the maven-doxia-sitetools version used is 2.0.0-M3. This version provides the default-site.vm file in its resources, which is used as the default template in the DefaultSiteRenderer class if the skin doesn't provide any (e.g. maven-default-skin).
In maven-site-plugin 4.0.0-M4, the version of maven-doxia-sitetools is 2.0.0-M4. In this version, the default-site.vm has been removed and the default skin has been changed to maven-fluido-skin.
This means it's not possible anymore to use a skin that doesn't provide the site.vm template. If one tries to force the use of the maven-default-skin with version 4.0.0-M4, it will fail with the message Skin does not contain template at META-INF/maven/site.vm.
This change has been done in https://issues.apache.org/jira/browse/DOXIASITETOOLS-270. maven-default-skin is unmaintained and will be replaced by maven-fluido-skin, see https://issues.apache.org/jira/browse/MSKINS-196.
For information, the site.vm is a Velocity template file and is rendered by maven-doxia-sitetools (doxia-site-renderer to be precise) on maven-site-plugin's request.

How to add prefix in URI while loading XQuery file using ml-gradle

I am using gradle 6.8 and MarkLogic version is 10.0-5.2,
My XQuery code is in directory \ml-gradle\src\main\common. When I run the command mlLoadModules to load XQuery into the modules database it loads with default URI /common/test.xqy.
I want to add some prefix to the URIs e.g. /rsc/common/test.xqy. How can I achieve that?
Note: I don't want to create an extra folder in my source for prefix "rsc".
It's not supported, though you could write a custom Gradle task to change the URI to whatever you like.
Why do you not want to create an "rsc" folder above "common"? I think other developers would find it much more intuitive that "rsc/common/test.xqy" becomes "/rsc/common/test.xqy" when loaded, rather than "common/test.xqy" becomes "rsc/common/test.xqy", which begs the question - where is "rsc" coming from? And then that developer would need to understand what property / custom code is adding that "rsc".

Maven plugin: copy a file content into another file

I am looking for the appropriate plugin to copy a file content into another file.
My resource.xml has content like this:
<class>my.path.ResourceA</class>
<class>my.path.ResourceB</class>
<class>my.path.ResourceC</class>
and must be copied to destination.xml at the place of ${content}:
<aaa>some info</aaa>
${content}
What the proper maven plugin to do that task, please?
Thank you in advance.
Nic
In general with Maven, you must first thinkg WHAT you want to do. Might seem weird at first sight, but as Maven is an opinionated build tool, it will generally be not simple to do weird/workaround things ;-).
Here, you would need two things:
load that file into a "content" property (before resource filtering starts by binding to an early phase, obviously, see the next point)
just activate resource filtering and be done
Unfortunately, there's no well-known/standard plugin for the (1) able to load a file inside a property.
A possible way, before rewriting it through a dedicated plugin or so, would be by using antrun-maven-plugin (through LoadFile task?) or gmaven plugin to load that file into a property (during the initialize phase, for example, so that it happens before process-resources, see the documentation about lifecycle.)
Then, for (2), you simply have to activate filtering (see the standard documentation of the maven-resources-plugin).
The answer from Baptiste does not work with the antrun plugin, as the properties from the LoadFile task are Ant properties are not accessible in Maven for filtering.
Instead, one can use the readfiles-maven-plugin, which you can find here: https://github.com/chonton/readfiles-maven-plugin

Property Replacement in Maven Site Content

I'm generating maven site content using the site plugin. I want to have a little table that shows my maven group id, artifact id, parent info, etc on the module. I don't see a plugin for it, so I was going to use the APT format and create a content page with a table for it. The documentation says I can use property replacement in the site descriptor via ${project.name} etc. This fails when i use it in both the descriptor and in my index.apt file. Has anybody seen this done or know how to do it?
The mvn site command generates a Project Summary page which has this information on it. Does that work for you?
For example, when I execute mvn site, get an output here target/site/project-summary.html where the page has a section like so:
Build Information
Field Value
GroupId com.a.b
ArtifactId myapp
Version 1.01.13-SNAPSHOT
Type jar
If you want to create pages which use placeholder like ${project.version} etc. you need to use index.apt.vm (velocity files) wher the replacement works. But for the information you have asked the solution which has been described (project-summary.html) is the right way cause it's automatically generated.

Teamcity REST URL for getting tags

I'd like to get the url to access the tags on a build
we're running TeamCity 6.0.2
so far I can get to the build xml with
http://teamcity/httpAuth/app/rest/buildTypes/id:bt12/builds/number:1.0.0.990
but adding /tags to the end won't give me just the tags xml
I've gone thru the REST documentation but haven't found a combination that worked
The end goal is to PUT tags onto a specific build
UPDATE:
you have to specify the buildType in the bit of the url. here's the one that works
http://teamcity/httpAuth/app/rest/builds/buildType:bt12,number:1.0.0.990/tags
I think you misread the spec. The /tags is only allowed for one specific build and therefor I guess the /tags cannot be used on /buildTypes
Can you try this, assuming the id:bt12 gives you a specific build...
http://teamcity/httpAuth/app/rest/builds/id:bt12/tags/

Resources