I've problem with Maven. I tried to create archetype, but I don't now how to put source file to directory ${groupId}/${artifactId}. If I try to create project from this archetype, file is stored implicitly in ${groupId} directory. It seems Maven supposes, that group ID is a package name. But I'm using ${groupId}/${artifactId} as package name so I need have the source file stored in ${groupId}/${artifactId} directory. I have seen solution: to put the file into __artifactId__ directory. Double underscore should determine a variable. However it doesn't take any effect. Variable seems to be empty, but in package name inside source file is used succesfully.
Have enybody idea, which trick shall have been done when using double underscore in file name?
When you create a archetype of your project like so:
mvn archetype:create-from-project -Dinteractive
Set the package - in an explicit form to the root of the project.
Then you create a project of this archetype enter your root package ${groupId}.$ {artifactId} in explicit form. example:
mvn archetype: generate
-DarchetypeGroupId = com.test
-DarchetypeArtifactId = my_archetype
-DgroupId = com.test
-DartifactId = app
-Dpackage = com.test.app
-Dversion = 1.0-SNAPHOT
In this case, $ {groupId} = com.test, $ {artifactId} = app and target package = com.test.app
Related
I have a gradle build which generates war file. I want to copy war file to my application servers' dropins directory which is somewhere outside of project directory. I have following copy task to do this.
task copyWarToDropins(type: Copy,dependsOn:[war]) {
from './build/libs/bds-service-token-1.0-SNAPSHOT.war'
into file('/apps/dropins') // want to copy to 'C:/apps/dropins' directory
rename { fileName -> 'bds-service-token.war' }
}
build.dependsOn copyWarToDropin
It evaluates /apps/dropins relative project directory and does copy there. I have tried many ways I can think of but could not make it copy to C:/apps/dropins directory.
Can someone please help?
First, please note that using into file(...) is redundant, as each call to into(...) will be evaluated via Project.file(...) anyhow.
As you can read in the documentation , file(...) handles strings in the following way:
A CharSequence, including String or GString. Interpreted relative to the project directory. A string that starts with file: is treated as a file URL.
So, one way to solve your problem could be using an absolute file URL.
However, if you continue to read the documentation, you will see that Java File objects are supported. So you could simply create such an object:
into new File('C:/your/absolute/path')
As we know, the following maven command will generate a dependency-analysis HTML file in the target folder of the module/component:
mvn dependency:analyze-report -DignoreNonCompile=true
Is there a way to create an HTML file with a customized name instead of the default dependency-analysis name?
I have a multi-project gradle project with following directory structure:
+ project_root
+ module1
+ src
build.gradle
+ module2
+ src
build.gradle
+ web
..
build.gradle
settings.gradle
In module1/build.gradle among other things I have specified:
compileKotlin2Js.kotlinOptions {
outputFile = "web/script.js"
}
It is a special Kotlin JS setting that specifies output file path of compiled JS file.
Now my problem is, that when I build the whole project (project_root/build.gradle) the file ends up in the right directory (project_root/web), but when I accidentally run build on the module alone the file is saved in module directory (project_root/module1/web).
How can I fix paths in my build scripts, so file output will be saved in exactly the same directory no matter which build script I run (without specifying full path, I want a relative path)?
I don't know what Gradle plugin requires the path parameter in your code example, but all regular (non-3rd-party) Gradle plugins evaluate path parameters via Project.files(Object...) to avoid different locations when calling Gradle from various working directories.
I would suggest to use the above method (or its single file version Project.file(Object)) as well. You can even omit the project part, because the build.gradle file gets executed in the project scope:
compileKotlin2Js.kotlinOptions {
outputFile = file('web/script.js')
}
This will always evaluate the path relative to the project directory of the project your build.gradle belongs to. To evaluate a file relative to the project directory of the root project, use rootProject.files(Object...), for a path relative to the project directory of a subproject or any project in the build, use project(':path:to:project').files(Object...).
I tried add new module to project in IntellijIDE 15 and I have error
Failed to create a Maven project
'C:/gitProjects/mayProj/pom.xml' already exists in VFS
And in my project create file moduleName.iml but in IDE not shows module folder and in project structure this module is shows.
When adding the module to an existing module that already has a POM, it is necessary to manually specify that the new module will be in a different directory. This is counter-intuitive, but I think the "Add Module" dialog was not built with maven specifically in mind.
What this means is when you are adding a module to an existing module with a POM, for example, an aggregator project, on the second page of the dialog, you need to manually copy and paste the "Module Name" onto the end of the "Content root" and "Module file locations".
When you create the module manually in the context root in module file location, you must define the module name.
eg. C:\Users\Desktop\Desktop\release\1.2.1-SNAPSHOT\payment\xxx-xxx-xxx
The problem is Intellij will be failing to create module folder for your module,
so you need to specify your content-root path and module-file-location.
just copy and paste your module name to content-root and module-file-location
module-name = learn-example
content-root = xxxx/zubs/learn-example
module-file-location = xxxx/zubs/learn-example
Error when I tried create new maven module in IntellijIDE on MacBook
I am using Maven 3.0.3 and I have a multiple module maven project which I want to use for Archetype creation. Struture is like:
Main_Project
----pom.xml
----Module_1
----pom.xml
----src
----main
----java
----com
----mycompany
----domain
----DomainT.java
----repo
----resources
----webapp
----test
----Module_2
----pom.xml
----src
----main
----java
----com
----mycompany
----web
----WebT.java
----resources
----webapp
----test
Now, when I use the following cmd in the Module_2, archetype is created successfully and correctly i.e.
c:\Main_Project\Module_2>mvn archetype:create-from-project
But, when I run the same command from the main folder (i.e. c:\Main_Project), the package structure is not created (for 'generate' cmd) and still the original package structure exists in the both the modules. What I mean is the package name in java and other files gets replaced with correct variables but the package folder structure is no created .e.g.
The original structure was:
----src
----main
----java
----com
----mycompany
----domain
----DomainT.java
After I run the cmd, mvn archetype:generate -DarchetypeCatalog=local
Define value for property 'groupId': : com.sample
Define value for property 'artifactId': : test_project
Define value for property 'version': 1.0-SNAPSHOT:
Define value for property 'package': com.sample: :
Still the folder structure when generated inside the Module_1\src\main\java folder is same as above (i.e. Module_1\src\main\java\com\mycompany) and not like Module_1\src\main\java\com\sample
Not sure what I can do to make it work?
Fixed now.
In parent pom.xml, the module declaration was inside profiles.