I have a multi-module maven project that is built by teamcity. This is working and the resulting artifacts are:
/core/target/core-system-1.2.3.war
/plugins/plugin-a/target/plugin-a-1.2.3.jar
/plugins/plugin-b/target/plugin-b-1.2.3.jar
/plugins/plugin-c/target/plugin-c-1.2.3.jar
/plugins/...
Currently, the artifacts are collected using this under general settings:
core/**/target/*.war => dist/core
plugins/**/target/*.jar => dist/plugins
So, I have all needed files in the dist-folder (afterwards they are pushed to a deployment-server via ssh). However, teamcity keeps the "target"-folder (which is also mentioned here [1]):
/dist/core/target/core-system-1.2.3.war
/dist/plugins/plugin-a/target/plugin-a-1.2.3.jar
/dist/plugins/plugin-b/target/plugin-b-1.2.3.jar
/dist/plugins/plugin-c/target/plugin-c-1.2.3.jar
What I need is to remove the target directory from the results:
/dist/core/core-system-1.2.3.war
/dist/plugins/plugin-a/plugin-a-1.2.3.jar
/dist/plugins/plugin-b/plugin-b-1.2.3.jar
/dist/plugins/plugin-c/plugin-c-1.2.3.jar
There are a lot of plugins and they change from time to time, so I don't want define them all with static paths. Therefore, using plugins/plugin-a/target/*.jar => dist/plugins/plugin-a is possible, but not feasible.
So, how can I remove the target directory from the artifact path, without selecting other jars that are not within the target directory?
[1] https://confluence.jetbrains.com/display/TCD10/Configuring+General+Settings#ConfiguringGeneralSettings-artifactPaths
TeamCity is 10.0.4
Have you tried something like this:
core/**/target*/*.war => dist/core
plugins/**/target*/*.jar => dist/plugins
According to TeamCity docs you referenced it's:
[..] That is, TeamCity will create directories starting from the first occurrence of the wildcard in the pattern.
Related
I have a project with multiple modules (gradle modules) and some are depend on some others, for example :modules:backend:core has a project dependency on :modules:libraries:util:core and some others.
In my gitlab CI job I am able to tell when there are changes within some module (e.g. :modules:libraries:util:core) by listening to something like modules/libraries/util/core/**/*, and then triggering a build of that changed module.
Now the issue I have is how to figure out where this module is used, so that I can build the other side also (in this example I would need to build :modules:backend:core once :modules:libraries:util:core is changed).
Is there some way to list all usages of given module ?
https://github.com/vanniktech/gradle-dependency-graph-generator-plugin
You can use this plugin to create "your project module dependency graph"
./gradlew generateProjectDependencyGraph
or "whole dependency graph".
./gradlew generateDependencyGraph
You can find this file from app/build/reports/dependency-graph and app/build/reports/project-dependency-graph directory.
The folder includes three files: png, svg and dot.
In the dot file, you can get the module dependency.
":app" -> ":base" ["style"="dotted"]
":app" -> ":moduleA" ["style"="dotted"]
":moduleA" -> ":base" ["style"="dotted"]
We have a huge monolith application which is build by multiple tools (shell scripts, Ant and Maven). The build process is quite complex:
a lot of manually steps
hidden dependencies between Ant targets
different steps must be executed depending on the used Operating System
We decided to simplify it by creating Gradle scripts which wraps all this logic (it is quite impossible to fix it, so we create a wrapper which standardize the way of executing all the logic). We have to download some files from the Maven repository, but we cannot use the dependencies syntax:
we don't need to always download all files
the versions of the downloaded artifacts are dynamic (depends on configuration located in completely different place)
we need a path to the downloaded files (e.g. we have to unpack an artifact distributed as zip)
How we can achieve it?
The easiest way to achieve it is to create a dynamic configuration with dependencies, and next resolve it. The resolve method returns paths to the dependencies on the local disk. It is important to use a unique name for every configuration. If not, executing the logic twice would fail (cannot overwrite the configuration with XYZ name).
Here is an example method which returns a path to an artifact. If the artifact is already available in the Gradle cache it won't be downloaded for the second time, but of course the path will be returned. In this example all artifacts are downloaded from Maven Central.
Method:
ext.resolveArtifact = { CharSequence identifier ->
def configurationName = "resolveArtifact-${UUID.randomUUID()}"
return rootProject.with {
configurations.create(configurationName)
dependencies.add(configurationName, identifier)
return configurations.getByName(configurationName, {
repositories {
mavenCentral()
}
}).resolve()[0]
}
}
Usage:
def jaCoCoZip = resolveArtifact('org.jacoco:jacoco:0.8.6')
def jaCoCoAgent = resolveArtifact('org.jacoco:org.jacoco.agent:0.8.6')
I'm using gradle for an Android project.
I have a task that downloads some files to put them into the build (as Android assets).
I would like to have a task download some files from the web and put them into a temp directory, from where they are copied (by a separate copy task) into the assets directory during the build.
I would like to make sure that the downloader task will rerun ( and not be considered UP-TO-DATE ) if the output directory changed in any way ( e.g. files changed or missing, directories missing, files in subdirectory missing etc, recursively. ). Currently, I specified the output directory as #OutputDirectory, but it seems to not do what I want:
class AssetDownloaderTask extends DefaultTask {
#OutputDirectory
def File outputDir
#Input
def String databaseChecksum
....
E.g. if I delete a file from one of the subdirectories, gradle still considers the task UP-TO-DATE. Isn't gradle supposed to store a hash of the outputs?
How can I achieve what I want?
I'm not a Gradle expert by any means, but I believe you want to use the #InputDirectory annotation instead.
This will cause the task to be considered out-of-date when the directory location or contents have changed.
https://docs.gradle.org/current/javadoc/org/gradle/api/tasks/InputDirectory.html
EDIT: Wow, didn't notice this was so old. Sorry if necroing is bad SA etiquette.
I have a TeamCity (9.0.2) build configuration which contains the following artefact path pattern:
App\Agent\**\bin\%env.Configuration%\** => Deployment\AgentBuildPackage.%env.ApplicationVersion.EMX%.%system.build.number%.zip
which will create a file named something like AgentBuildPackage.4.5.0.185.zip in an artefact folder named Deployment
The current structure is like this:
Deployment/
AgentBuildPackage.4.5.0.185.zip/
MyFirstServiceFolder/
bin/
Debug|Release/
All the Files
The artefact archive contains all the folders it finds under App\Agent which is great. What I can't figure out is how to flatten those individual folders so they no longer contain the /bin/Release sub-folders.
What I want is
Deployment/
AgentBuildPackage.4.5.0.185.zip/
MyFirstServiceFolder/
All the Files
Can anyone tell me how please?
You can specify target folders within your target archive by using the ! character after the name of the .zip file. Like this:
folderA\** => output.zip!/afolder/
Depending on how many service folders you have, this could be quite verbose, as you'll need to do it for each one, but it should do what you've described:
App\Agent\MyFirstServiceFolder\bin\%env.Configuration%\** => Deployment\AgentBuildPackage.%env.ApplicationVersion.EMX%.%system.build.number%.zip!/MyFirstServiceFolder/
Here's the documentation page on specifying artifact paths if you haven't seen it yet: https://confluence.jetbrains.com/display/TCD9/Configuring+General+Settings#ConfiguringGeneralSettings-PathsPatterns
Can anyone give me an example of what the Artifact paths setting defined for a build configuration could look like if I want to create two artifacts dist and source where I am using the sln 2008 build runner and building my projects using the default bin/Release?
**/Source/Code/MyProject/bin/Release/*.* => dist
**/*.* => source
I get two artifact roots dist and source but under dist I get the whole directory structure (Source/Code/MyProject/bin/Release) which I don't want and under source I get the whole thing along with obj and bin/Release which I do not want.
Can you give some advice on how to do this correctly?
Do I need to change the target location for all the projects I am building to be able to get this thing to work?
So you'll just need:
Source\Code\MyProject\bin\Release\* => dist
Source\**\* => source
This will put all the files in release into a artifact folder called dist and everything in Source into a artifact folder called source.
If you have subfolders in Release try:
Source\Code\MyProject\bin\Release\**\* => dist
According to TeamCity documentation; it should be like this:
file_name|directory_name|Ant-like wildcard [ => target_directory ]
So..
Source\Code\MyProject\bin\Release|**\* => dist (| not \)