Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Profiles defined inside tiles don't appear to work. #53

Open
talios opened this issue Feb 9, 2016 · 18 comments
Open

Profiles defined inside tiles don't appear to work. #53

talios opened this issue Feb 9, 2016 · 18 comments

Comments

@talios
Copy link
Member

talios commented Feb 9, 2016

No description provided.

@akanter
Copy link

akanter commented Feb 12, 2016

Really? I have a profile working in my tile just fine...

<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/maven-v4_0_0.xsd">

    <properties>
        <version.maven.compiler.plugin>3.1</version.maven.compiler.plugin>
        <version.java>1.7</version.java>
        <crossCompileJavaArg></crossCompileJavaArg>
    </properties>
    <profiles>
        <profile>
            <activation>
                <jdk>[1.8,]</jdk>
            </activation>
            <properties>
                 <crossCompileJavaArg>-Xbootclasspath/p:${env.JAVA7_HOME}/jre/lib/</crossCompileJavaArg>
            </properties>
        </profile>
    </profiles>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>${version.maven.compiler.plugin}</version>
                <configuration>
                    <source>${version.java}</source>
                    <target>${version.java}</target>
                    <compilerArgs>
                        <arg>-Xlint:unchecked</arg>
                        <arg>${crossCompileJavaArg}</arg>
                    </compilerArgs>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

@talios
Copy link
Member Author

talios commented Feb 15, 2016

Interesting, I don't have any <activiation> section in mine, leaving it up to the command line to request -Psomeprofile which doesn't seem to run. I had thought we'd fixed/tested that ages ago and it worked, maybe there's something else going on that's confusing my builds.

@Tzrlk
Copy link
Contributor

Tzrlk commented Mar 17, 2016

I can't even get it to work when setting the environment variable that triggers the profile activation.

@rvowles
Copy link
Member

rvowles commented Mar 17, 2016

Do you have a sample project for us to check @Tzrlk ?

@stickycode
Copy link

I have a sample project

mvn org.apache.maven.plugins:maven-release-plugin:2.3.2:perform -Ppromote-to-central -DconnectionUrl=scm:git:[email protected]:StickySource/sticky-tile-upload-nexus.git -Dtag=sticky-tile-upload-nexus-1.1

timothysparg pushed a commit to timothysparg/maven-tiles that referenced this issue Jan 6, 2018
illustration of issue with profiles
@timothysparg
Copy link

timothysparg commented Jan 6, 2018

hi all

I've looked at this a little bit as we make use of profiles extensively.

I created a test project in a fork of your repo with a hack that seems to resolve the issue
https://github.com/timothysparg/maven-tiles
The changes I made to TilesMavenLifecycleParticipant.groovy seem to resolve the issue in with the example project that I was using (included as a sub folder)

If you guys could give me some pointers as to where in the lifecycle I should try and implement a solution, I will happily give it a bash - the changes I've made are more for an illustrative point than anything else

@rvowles
Copy link
Member

rvowles commented Jan 7, 2018

your solution looks fine to me @timothysparg - is there a reason we shouldn't just use it?

@timothysparg
Copy link

@rvowles I just wasn't sure if that was the correct place in the project lifecycle to place the code.

I have created a submission via GerritHub If you're happy with it

@timothysparg
Copy link

Please hold on this - I was doing some checking on this this morning, and although I can now see the profiles use help:effective-pom, they still don't seem to activate

@rvowles
Copy link
Member

rvowles commented Jan 9, 2018

ok. They may be appearing too late - Maven does variable resolution before it hits the lifecycle plugin, which is what makes using variables in versions painful. I suspect we may have to run the activation logic ourselves and merge them into the POM.

@udalrich
Copy link

udalrich commented May 17, 2018

With maven 3.5.0 and tiles 2.11, it appears that the profiles are activated, but maven gives a warning that they are unknown:

[WARNING] The requested profile "dev" could not be activated because it does not exist.

This is the last line of output from by build, even though the dev profile exists (inside a tile) and is activated.

If you can inject the profile into the pom model, that would probably fix that warning and also make the profile show up with help:effective-pom.

@talios
Copy link
Member Author

talios commented Jun 29, 2018

@timothysparg Just pulled the review and ran it locally, and still see the warning being mentioned as @udalrich mentions, did you ever manage to resolve that at all?

@timothysparg
Copy link

No, I initially thought this would be a quick fix, but maven seems to handle profile evaluation differently to how it handles other sections of the pom.

I can't remember all the semantic issues right now, but I do remember that my pr did not resolve the issue satisfactorily

@tchlyah
Copy link

tchlyah commented Dec 5, 2018

Do you have any news about this issue? Profiles aren't copied even in the latest version

@rvowles
Copy link
Member

rvowles commented Dec 5, 2018 via email

@talios
Copy link
Member Author

talios commented Dec 16, 2018

From my uses - profiles appear to copy and run as expected - EXCEPT that maven reports that the profile doesn't exist at the end of a build still - even tho it used it. @tchlyah are you seeing different behaviour or?

@hackmann
Copy link

I don't mind the warning as I normally do not select profiles explicitly but activate them based on system properties.

The problem I have is with compound tiles like java_library:

<?xml version="1.0" encoding="UTF-8"?>
<!--suppress MavenModelInspection -->
<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">

  <tiles>
    <tile>net.worldticket.build:profile_deploy_only:@project.version@</tile>
    <tile>net.worldticket.build:enforcer_dependencies:@project.version@</tile>
    <tile>net.worldticket.build:surefire:@project.version@</tile>
    <tile>net.worldticket.build:failsafe:@project.version@</tile>
    <tile>net.worldticket.build:jacoco_prepare:@project.version@</tile>
    <tile>net.worldticket.build:java_attach_sources:@project.version@</tile>
    <tile>net.worldticket.build:java_compiler:@project.version@</tile>
    <tile>net.worldticket.build:java_jar:@project.version@</tile>
  </tiles>
</project>

And then using it together with single tiles:

  <build>
    <plugins>
      <plugin>
        <groupId>io.repaint.maven</groupId>
        <artifactId>tiles-maven-plugin</artifactId>
        <!-- Added java test jar -->
        <configuration>
          <tiles>
            <tile>net.worldticket.build:java_library:${java_dependencies.version}</tile>
            <tile>net.worldticket.build:java_test_jar:${java_dependencies.version}</tile>
            <tile>net.worldticket.build:joda_beans_validate:${java_dependencies.version}</tile>
          </tiles>
        </configuration>
      </plugin>
    </plugins>
  </build>

I cannot get the profile from profile_deploy_only to affect any of the tiles listed directly in the project. It only affects the tiles listed together with it in the compound tile.

I guess this is because tiles are expanded breadth first and not depth first:

 mvn -DdeployOnly validate
[INFO] Scanning for projects...
[INFO] --- tiles-maven-plugin: Injecting 18 tiles as intermediary parent artifacts for net.worldticket.dcs:dcs-gateway...
[INFO] Mixed 'null:dcs-gateway:null' with tile 'net.worldticket.build:java_library:5.54.1-SNAPSHOT' as its new parent.
[INFO] Explicitly set groupId to 'net.worldticket.dcs' from original parent 'net.worldticket.dcs:dcs-parent:5.53.9-SNAPSHOT'.
[INFO] Explicitly set version to '5.53.9-SNAPSHOT' from original parent 'net.worldticket.dcs:dcs-parent:5.53.9-SNAPSHOT'.
[INFO] Mixed 'net.worldticket.build:java_library:5.54.1-SNAPSHOT' with tile 'net.worldticket.build:java_test_jar:5.54.1-SNAPSHOT' as its new parent.
[INFO] Mixed 'net.worldticket.build:java_test_jar:5.54.1-SNAPSHOT' with tile 'net.worldticket.build:joda_beans_validate:5.54.1-SNAPSHOT' as its new parent.
[INFO] Mixed 'net.worldticket.build:joda_beans_validate:5.54.1-SNAPSHOT' with tile 'net.worldticket.build:profile_deploy_only:5.54.1-SNAPSHOT' as its new parent.
[INFO] Mixed 'net.worldticket.build:profile_deploy_only:5.54.1-SNAPSHOT' with tile 'net.worldticket.build:enforcer_dependencies:5.54.1-SNAPSHOT' as its new parent.
[INFO] Mixed 'net.worldticket.build:enforcer_dependencies:5.54.1-SNAPSHOT' with tile 'net.worldticket.build:surefire:5.54.1-SNAPSHOT' as its new parent.
[INFO] Mixed 'net.worldticket.build:surefire:5.54.1-SNAPSHOT' with tile 'net.worldticket.build:failsafe:5.54.1-SNAPSHOT' as its new parent.
[INFO] Mixed 'net.worldticket.build:failsafe:5.54.1-SNAPSHOT' with tile 'net.worldticket.build:jacoco_prepare:5.54.1-SNAPSHOT' as its new parent.
[INFO] Mixed 'net.worldticket.build:jacoco_prepare:5.54.1-SNAPSHOT' with tile 'net.worldticket.build:java_attach_sources:5.54.1-SNAPSHOT' as its new parent.
[INFO] Mixed 'net.worldticket.build:java_attach_sources:5.54.1-SNAPSHOT' with tile 'net.worldticket.build:java_compiler:5.54.1-SNAPSHOT' as its new parent.
[INFO] Mixed 'net.worldticket.build:java_compiler:5.54.1-SNAPSHOT' with tile 'net.worldticket.build:java_jar:5.54.1-SNAPSHOT' as its new parent.
[INFO] Mixed 'net.worldticket.build:java_jar:5.54.1-SNAPSHOT' with tile 'net.worldticket.build:enforcer_ban_dependencies:5.54.1-SNAPSHOT' as its new parent.
[INFO] Mixed 'net.worldticket.build:enforcer_ban_dependencies:5.54.1-SNAPSHOT' with tile 'net.worldticket.build:enforcer_ban_test_dependencies:5.54.1-SNAPSHOT' as its new parent.
[INFO] Mixed 'net.worldticket.build:enforcer_ban_test_dependencies:5.54.1-SNAPSHOT' with tile 'net.worldticket.build:enforcer_require_same_version:5.54.1-SNAPSHOT' as its new parent.
[INFO] Mixed 'net.worldticket.build:enforcer_require_same_version:5.54.1-SNAPSHOT' with tile 'net.worldticket.build:failsafe_integration_test:5.54.1-SNAPSHOT' as its new parent.
[INFO] Mixed 'net.worldticket.build:failsafe_integration_test:5.54.1-SNAPSHOT' with tile 'net.worldticket.build:failsafe_verify:5.54.1-SNAPSHOT' as its new parent.
[INFO] Mixed 'net.worldticket.build:failsafe_verify:5.54.1-SNAPSHOT' with tile 'net.worldticket.build:jacoco_prepare_test:5.54.1-SNAPSHOT' as its new parent.
[INFO] Mixed 'net.worldticket.build:jacoco_prepare_test:5.54.1-SNAPSHOT' with tile 'net.worldticket.build:jacoco_prepare_verify:5.54.1-SNAPSHOT' as its new parent.
[INFO] Mixed 'net.worldticket.build:jacoco_prepare_verify:5.54.1-SNAPSHOT' with original parent 'net.worldticket.dcs:dcs-parent:5.53.9-SNAPSHOT' as its new top level parent.
[INFO] 


If I explicitly list profile_deploy_only as the first tile in the project

  <build>
    <plugins>
      <plugin>
        <groupId>io.repaint.maven</groupId>
        <artifactId>tiles-maven-plugin</artifactId>
        <!-- Added java test jar -->
        <configuration>
          <tiles>
            <tile>net.worldticket.build:profile_deploy_only:${java_dependencies.version}</tile>
            <tile>net.worldticket.build:java_library:${java_dependencies.version}</tile>
            <tile>net.worldticket.build:java_test_jar:${java_dependencies.version}</tile>
            <tile>net.worldticket.build:joda_beans_validate:${java_dependencies.version}</tile>
          </tiles>
        </configuration>
      </plugin>
    </plugins>
  </build>

then it works

@lfvJonas
Copy link

I got a little confused when we started using Maven Tiles, I got the same behaviour profiles work as expected but maven reports they do not exsist.

Is this how it's should behave?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants